-
Notifications
You must be signed in to change notification settings - Fork 2
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 #47 from gunganghaljido/feature/정성혜
- Loading branch information
Showing
9 changed files
with
623 additions
and
43 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
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
67 changes: 67 additions & 0 deletions
67
src/components/CourseDetails/RatingStar/StarInput/index.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,67 @@ | ||
import styled from '@emotion/styled'; | ||
import { css } from '@emotion/react'; | ||
import { FaStar, FaStarHalf } from 'react-icons/fa'; | ||
import React from 'react'; | ||
|
||
interface StarInputProps { | ||
onClickRating: (value: number) => void; | ||
value: number; | ||
isHalf: boolean; | ||
} | ||
|
||
const Input = styled.input` | ||
display: none; | ||
`; | ||
|
||
const Label = styled.label<{ isHalf: boolean }>` | ||
cursor: pointer; | ||
font-size: 24px; | ||
color: #f1f2f4; | ||
${({ isHalf }) => | ||
isHalf && | ||
css` | ||
position: absolute; | ||
width: 12px; | ||
overflow: hidden; | ||
&:nth-of-type(10) { | ||
transform: translate(-108px); | ||
} | ||
&:nth-of-type(8) { | ||
transform: translate(-84px); | ||
} | ||
&:nth-of-type(6) { | ||
transform: translate(-60px); | ||
} | ||
&:nth-of-type(4) { | ||
transform: translate(-36px); | ||
} | ||
&:nth-of-type(2) { | ||
transform: translate(-12px); | ||
} | ||
`} | ||
`; | ||
|
||
export default function StarInput({ | ||
onClickRating, | ||
value, | ||
isHalf, | ||
}: StarInputProps) { | ||
const handleClickRatingInput = () => { | ||
onClickRating(value); | ||
}; | ||
|
||
return ( | ||
<> | ||
<Input type="radio" name="rating" id={`star${value}`} value={value} /> | ||
<Label | ||
onClick={() => handleClickRatingInput()} | ||
isHalf={isHalf} | ||
htmlFor={`star${value}`} | ||
> | ||
{isHalf ? <FaStarHalf /> : <FaStar />} | ||
</Label> | ||
</> | ||
); | ||
} |
50 changes: 50 additions & 0 deletions
50
src/components/CourseDetails/RatingStar/StarRating/index.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,50 @@ | ||
import styled from '@emotion/styled'; | ||
import StarInput from '../StarInput'; | ||
|
||
interface StarRatingProps { | ||
currentRating: number; | ||
onRatingChange: (value: number) => void; | ||
isNormal: boolean; | ||
} | ||
|
||
const Base = styled.section<{ isNormal: boolean }>` | ||
display: flex; | ||
align-items: center; | ||
gap: 8px; | ||
`; | ||
|
||
const RatingField = styled.fieldset<{ isNormal: boolean }>` | ||
position: relative; | ||
display: flex; | ||
align-items: center; | ||
flex-direction: row-reverse; | ||
border: none; | ||
transform: translateY(2px); | ||
input:checked ~ label, | ||
label:hover, | ||
label:hover ~ label { | ||
transition: 0.2s; | ||
color: ${({ isNormal }) => (isNormal ? '#75abff' : '#76c663')}; | ||
} | ||
`; | ||
|
||
export default function StarRating({ | ||
onRatingChange, | ||
isNormal, | ||
}: StarRatingProps) { | ||
return ( | ||
<Base isNormal={isNormal}> | ||
<RatingField isNormal={isNormal}> | ||
{[5, 4.5, 4, 3.5, 3, 2.5, 2, 1.5, 1, 0.5].map(value => ( | ||
<StarInput | ||
key={value} | ||
onClickRating={onRatingChange} | ||
value={value} | ||
isHalf={value % 1 !== 0} | ||
/> | ||
))} | ||
</RatingField> | ||
</Base> | ||
); | ||
} |
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 |
---|---|---|
|
@@ -74,7 +74,7 @@ | |
.card { | ||
display: flex; | ||
flex-direction: column; | ||
gap: 16px; | ||
gap: 28px; | ||
} | ||
|
||
.reviewItem { | ||
|
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
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