-
Notifications
You must be signed in to change notification settings - Fork 9
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 #50 from nan-noo/issue42
Issue42 별 컴포넌트 구현
- Loading branch information
Showing
8 changed files
with
67 additions
and
28 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import styled from "styled-components"; | ||
|
||
const StarContainer = styled.span` | ||
font-size: 1.5rem; | ||
color: ${({ theme }) => theme.yellow}; | ||
`; | ||
|
||
const EMPTY_STAR_ICON = "\u2606"; | ||
const FILLED_STAR_ICON = "\u2605"; | ||
|
||
function Star({ isFilled = false }) { | ||
return ( | ||
<StarContainer> | ||
{isFilled ? FILLED_STAR_ICON : EMPTY_STAR_ICON} | ||
</StarContainer> | ||
); | ||
} | ||
|
||
export default Star; |
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
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,28 @@ | ||
import Star from "../components/Star"; | ||
|
||
export default { | ||
title: "Component/Star", | ||
component: Star, | ||
argTypes: { | ||
isFilled: { controls: "boolean" }, | ||
}, | ||
}; | ||
|
||
const Template = (args) => <Star {...args} />; | ||
|
||
export const Default = Template.bind({}); | ||
Default.args = { | ||
isFilled: true, | ||
}; | ||
|
||
export const FilledStar = Template.bind({}); | ||
FilledStar.args = { | ||
isFilled: true, | ||
}; | ||
FilledStar.parameters = { controls: { exclude: ["isFilled"] } }; | ||
|
||
export const OutlinedStar = Template.bind({}); | ||
OutlinedStar.args = { | ||
isFilled: false, | ||
}; | ||
OutlinedStar.parameters = { controls: { exclude: ["isFilled"] } }; |
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,10 +1,15 @@ | ||
import { useState } from "react"; | ||
|
||
import StarRating from "../components/StarRating"; | ||
|
||
export default { | ||
title: "Component/StarRating", | ||
component: StarRating, | ||
}; | ||
|
||
const Template = (args) => <StarRating />; | ||
const Template = () => { | ||
const [rating, setRating] = useState(4); | ||
return <StarRating rating={rating} setRating={setRating} />; | ||
}; | ||
|
||
export const Default = Template.bind({}); |
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