-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move streakblock to separate component
- Loading branch information
1 parent
067daaa
commit 5ac2c5c
Showing
4 changed files
with
111 additions
and
108 deletions.
There are no files selected for viewing
52 changes: 52 additions & 0 deletions
52
src/components/StreakView/User/StreakBlock/StreakBlock.less
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
.streak-block { | ||
position: relative; | ||
width: 200px; | ||
color: rgb(255, 255, 255); | ||
|
||
.container { | ||
border-radius: 16px; | ||
display: flex; | ||
overflow: hidden; | ||
padding: 10px 5px; | ||
|
||
background-color: rgb(255, 200, 0); | ||
background-image: url("https://d35aaqx5ub95lt.cloudfront.net/images/profile/92bd1526f88a4bea08ff2d5ad9783311.svg"); | ||
background-repeat: no-repeat; | ||
background-size: 100% 100%; | ||
border-color: rgb(255, 200, 0); | ||
border-style: solid solid none; | ||
|
||
.icon { | ||
border-style: none; | ||
} | ||
|
||
.star-position-a { | ||
position: absolute; | ||
bottom: 8px; | ||
height: 21px; | ||
left: 18px; | ||
width: 21px; | ||
} | ||
.star-position-b { | ||
position: absolute; | ||
height: 27px; | ||
right: 12px; | ||
top: 12px; | ||
width: 27px; | ||
} | ||
|
||
.flame-position { | ||
align-self: start; | ||
margin-left: 10px; | ||
width: 21px; | ||
height: 40px; | ||
width: 40px; | ||
} | ||
|
||
.streak-number-wrapper { | ||
align-self: center; | ||
flex: 1 0 auto; | ||
text-align: left; | ||
} | ||
} | ||
} |
57 changes: 57 additions & 0 deletions
57
src/components/StreakView/User/StreakBlock/StreakBlock.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
import "./StreakBlock.less"; | ||
|
||
type StreakBlockProps = { | ||
days: number; | ||
}; | ||
export const StreakBlock = (props: StreakBlockProps) => { | ||
const isActive = props.days > 0; | ||
|
||
return ( | ||
<div className="streak-block"> | ||
<div className="container"> | ||
{isActive && ( | ||
<> | ||
<Star positionClass="star-position-a" /> | ||
<Star positionClass="star-position-b" /> | ||
</> | ||
)} | ||
{isActive ? ( | ||
<Flame positionClass="flame-position" /> | ||
) : ( | ||
<DisabledFlame positionClass="flame-position" /> | ||
)} | ||
<div className="streak-number-wrapper"> | ||
<h1>{props.days}</h1> | ||
<span>Day streak</span> | ||
</div> | ||
</div> | ||
</div> | ||
); | ||
}; | ||
|
||
const Star = (props: { positionClass: string }) => { | ||
return ( | ||
<img | ||
className={`icon ${props.positionClass}`} | ||
src="https://d35aaqx5ub95lt.cloudfront.net/images/profile/f68d647fdc1536870945a5c84f3b3b82.svg" | ||
/> | ||
); | ||
}; | ||
|
||
const Flame = (props: { positionClass: string }) => { | ||
return ( | ||
<img | ||
className={`icon ${props.positionClass}`} | ||
src="https://d35aaqx5ub95lt.cloudfront.net/images/profile/8a6dca76019d059a81c4c7c1145aa7a4.svg" | ||
/> | ||
); | ||
}; | ||
|
||
const DisabledFlame = (props: { positionClass: string }) => { | ||
return ( | ||
<img | ||
className={`icon ${props.positionClass}`} | ||
src="https://d35aaqx5ub95lt.cloudfront.net/images/icons/ba95e6081679d9d7e8c132da5cfce1ec.svg" | ||
/> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters