Skip to content

Commit 4d96b1c

Browse files
author
Roshan Jossy
committed
add progress bar to next level
1 parent 5a3039e commit 4d96b1c

File tree

2 files changed

+33
-9
lines changed

2 files changed

+33
-9
lines changed

src/components/UserDetails/Badges/Badge.tsx

Lines changed: 31 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,37 @@ const Badge = ({badge}: any) => {
1414
)
1515

1616
return (
17-
<>
18-
<h4>{data.displayName}</h4>
19-
<Hexagon size={60} color="red" >
20-
<BadgeIcon displayName={data.displayName} />
21-
</Hexagon>
22-
{data.currentLevel}
23-
</>
17+
<div className="flex items-center ">
18+
<Hexagon size={60} color="red" >
19+
<BadgeIcon displayName={data.displayName} />
20+
</Hexagon>
21+
<div className=" ml-8">
22+
<span className="font-bold block">Level: {data.currentLevel}</span>
23+
<span className="text-sm block">524 lines to next level</span>
24+
<div className="progress-bar">
25+
<style jsx>
26+
{`
27+
.progress-bar {
28+
position: relative;
29+
height: 10px;
30+
width: 120px;
31+
background-color: #ccc;
32+
border-radius: 5px;
33+
box-shadow: inset 0.3em 0.3em 1em rgba(0,0,0,0.3);
34+
}
35+
.progress-bar:after {
36+
content: '';
37+
position: absolute;
38+
width: ${1.2 * data.progressPercentageToNextLevel}px;
39+
height: inherit;
40+
background-color: red;
41+
border-radius: 5px;
42+
}
43+
`}
44+
</style>
45+
</div>
46+
</div>
47+
</div>
2448
)
2549
}
2650

src/components/UserDetails/Badges/BadgeList.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,13 @@ const BadgeList = ({user}: any) => {
2929
}
3030

3131
return (
32-
<>
32+
<div className="space-y-4">
3333
{
3434
data.badges.edges.map((badge)=> (<Badge key={badge.node.id} badge={badge.node}/>))
3535
}
3636
{hasNext? <button onClick={()=>{loadNext(2)}}>Load more</button>: null}
3737

38-
</>
38+
</div>
3939
)
4040
}
4141

0 commit comments

Comments
 (0)