-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #136 from newnivers/feat/qa
QA
- Loading branch information
Showing
4 changed files
with
94 additions
and
46 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,56 +1,81 @@ | ||
import { useMemo } from "react"; | ||
import styled from "styled-components"; | ||
import Typography from "@/components/common/text/Typography"; | ||
|
||
export function ProgressCircle({ leftDate = 0 }: { leftDate: number }) { | ||
export function ProgressCircle({ leftDay = 0 }: { leftDay: number }) { | ||
const isValidDate = (day: number) => { | ||
return day < 5 && day > 0; | ||
}; | ||
|
||
const calculatedPercentage = useMemo(() => { | ||
if (!isValidDate(leftDay)) { | ||
return 0; | ||
} else { | ||
const progress = ((5 % leftDay) * 20) / 100; | ||
|
||
return 2 * Math.PI * 90 * (1 - progress); | ||
} | ||
}, [leftDay]); | ||
|
||
return ( | ||
<Wrapper> | ||
<InnerCircle> | ||
<LeftDay>{`D-${leftDate}`}</LeftDay> | ||
</InnerCircle> | ||
<OuterCircle count={2} /> | ||
<LeftDay>{`D-${leftDay}`}</LeftDay> | ||
<CircleSvg | ||
className="circle_progress" | ||
width="200" | ||
height="200" | ||
viewBox="0 0 200 200" | ||
> | ||
<Outer | ||
className="progress__meter" | ||
cx="100" | ||
cy="100" | ||
r="90" | ||
strokeWidth="12" | ||
stroke={isValidDate(leftDay) ? "#e6e6e6" : "none"} | ||
/> | ||
{} | ||
{isValidDate(leftDay) && ( | ||
<Bar | ||
dash={calculatedPercentage} | ||
className="progress__ing" | ||
cx="100" | ||
cy="100" | ||
r="90" | ||
strokeWidth={"12"} | ||
/> | ||
)} | ||
</CircleSvg> | ||
</Wrapper> | ||
); | ||
} | ||
|
||
const makeBorder = (count: number) => { | ||
let result = ""; | ||
for (let i = 0; i < 4; i += 1) { | ||
if (count > i) { | ||
result += `#F90 `; | ||
} else { | ||
result += `white `; | ||
} | ||
} | ||
|
||
return result; | ||
}; | ||
const CircleSvg = styled.svg` | ||
transform: rotate(-90deg); | ||
`; | ||
|
||
const Wrapper = styled.div` | ||
position: relative; | ||
const Bar = styled.circle<{ dash: number }>` | ||
stroke: ${({ theme }) => theme.colors.primary.point}; | ||
fill: none; | ||
stroke-dasharray: ${2 * Math.PI * 90}; | ||
stroke-dashoffset: ${({ dash }) => dash}; | ||
`; | ||
|
||
const InnerCircle = styled.div` | ||
width: 200px; | ||
height: 200px; | ||
border: 9px solid; | ||
border-radius: 50%; | ||
background: rgba(10, 10, 10, 0.8); | ||
display: flex; | ||
align-items: center; | ||
justify-content: center; | ||
const Outer = styled.circle` | ||
fill: rgba(10, 10, 10, 0.8); | ||
`; | ||
|
||
const OuterCircle = styled.div<{ count: number }>` | ||
position: absolute; | ||
top: 0; | ||
const Wrapper = styled.div` | ||
position: relative; | ||
width: 200px; | ||
height: 200px; | ||
border: 9px solid; | ||
border-radius: 50%; | ||
border-color: ${({ count }) => makeBorder(count)}; | ||
rotate: 45deg; | ||
`; | ||
|
||
const LeftDay = styled(Typography)` | ||
z-index: 1; | ||
color: white; | ||
position: absolute; | ||
top: 50%; | ||
left: 50%; | ||
transform: translate(-50%, -50%); | ||
`; |
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