Skip to content

Commit d8cbe27

Browse files
committed
feat: Add user streak display to GeneralSettings component
1 parent 5a2faa1 commit d8cbe27

2 files changed

Lines changed: 79 additions & 1 deletion

File tree

src/features/settings/components/GeneralSettings/GeneralSettings.tsx

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import React, { useState } from 'react'
2-
import { FaGithub } from 'react-icons/fa'
2+
import { FaFire, FaGithub } from 'react-icons/fa'
33
import { FcGoogle } from 'react-icons/fc'
4+
import { IoCheckmarkOutline } from 'react-icons/io5'
45
import Toggle from 'react-toggle'
56
import 'react-toggle/style.css'
67
import { Button, ChipsSet, ConfirmModal } from 'src/components/Elements'
@@ -58,6 +59,32 @@ const UserInfo = ({ user }: UserInfoProps) => {
5859
</Button>
5960
</div>
6061
</div>
62+
63+
<div className="streaks">
64+
<p className="title">
65+
You're on{' '}
66+
<span>
67+
{' '}
68+
<FaFire color="orange" size={18} /> <b>{user.streak || 1} days streak</b>
69+
</span>
70+
</p>
71+
<div>
72+
<ul className="streaksWeek">
73+
{Array.from({ length: 5 }, (_, i) => {
74+
const streak = user.streak || 1
75+
if (i < streak) {
76+
return (
77+
<li className="day checked">
78+
<IoCheckmarkOutline />
79+
</li>
80+
)
81+
} else {
82+
return <li className="day"></li>
83+
}
84+
})}
85+
</ul>
86+
</div>
87+
</div>
6188
</div>
6289
)
6390
}

src/features/settings/components/GeneralSettings/generalSettings.css

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,3 +129,54 @@ Select styles
129129
align-items: center;
130130
column-gap: 4px;
131131
}
132+
133+
.streaks {
134+
display: flex;
135+
flex-direction: column;
136+
row-gap: 16px;
137+
align-self: flex-start;
138+
}
139+
.streaks .title {
140+
margin: 0;
141+
padding: 0;
142+
font-size: 0.9em;
143+
}
144+
145+
.streaks ul.streaksWeek::before {
146+
content: '';
147+
display: block;
148+
width: 100%;
149+
height: 1px;
150+
background-color: var(--card-content-divider);
151+
z-index: 1;
152+
position: absolute;
153+
margin-top: 9px;
154+
}
155+
.streaks ul.streaksWeek {
156+
position: relative;
157+
margin: 0;
158+
padding: 0;
159+
display: flex;
160+
flex-direction: row;
161+
gap: 20px;
162+
list-style-type: none;
163+
overflow: hidden;
164+
}
165+
166+
.streaks .day {
167+
color: white;
168+
display: flex;
169+
align-items: center;
170+
justify-content: center;
171+
width: 16px;
172+
height: 16px;
173+
border-radius: 20px;
174+
border: 1px solid var(--card-content-divider);
175+
background-color: var(--card-content-divider);
176+
z-index: 2;
177+
}
178+
179+
.streaks .day.checked {
180+
border: 2px solid #18bc2d;
181+
background-color: #18bc2d;
182+
}

0 commit comments

Comments
 (0)