์คํ ํ๊ฒฝ
๋ถํ์ํ ๋ ธ๋๋ฅผ ์ต์ํ ํ๊ธฐ ์ํด webpack์ผ๋ก React + Typescript + Styled Components + Storybook์ ์ธํ ํ์ต๋๋ค. ๊ทธ๋ฆฌ๊ณ ๊ฐ๋จํ lint, prettier ์ค์ ๋ ์ถ๊ฐํ์ต๋๋ค.
label๊ณผ input์ ์ฐ๊ฒฐํด ์น ์ ๊ทผ์ฑ์ ๊ณ ๋ คํ ๊ฐ๋ฐ์ ํ์์ต๋๋ค.
framer-motion ๋ผ์ด๋ธ๋ฌ๋ฆฌ๋ฅผ ์ฌ์ฉํ์ฌ ์ ๋๋ฉ์ด์ ์ ์ ์ฉํ์์ต๋๋ค.
๋ชจ๋ฐ์ผ ํ๊ฒฝ์์๋ ๋์ผํ ์ฌ์ฉ๊ฐ์ ์ ๊ณตํฉ๋๋ค.
์คํ ๋ฐฉ๋ฒ
- package install
- npm i (or yarn)
- run dev server
- npm run dev (or yarn dev)๋ฅผ ํตํด ๊ตฌํ๋ ์ปดํฌ๋ํธ๋ฅผ localhost:3000์์ ํ์ธํ์ค ์ ์์ต๋๋ค.
- build
- npm run build (or yarn build)
์ฌ์ฉ๋ฒ
const App = () => {
return (
<>
<SegmentedControls
options={[
{ value: "one", disabled: true },
{ value: "two" },
{ value: "three" },
]}
defaultIndex={1}
setValue={(val) => console.log(val)}
size={"large"}
name={"one"}
/>
<SegmentedControls
options={[
{ value: "one", disabled: true },
{ value: "two" },
{ value: "three" },
{ value: "four" },
]}
defaultIndex={1}
setValue={(val) => console.log(val)}
size={"small"}
name={"two"}
/>
</>
);
};
๊ฒฐ๊ณผ๋ฌผ
์์ฑ
Name | Type | Default | Description |
---|---|---|---|
options | { value: string, disabled?: boolean }[] |
Enter the label of segments | |
setValue | Dispatch<SetStateAction<string>> |
callback on input change, passed the value string. Called once initially with the default value on mount. | |
size | large or small |
Enter the size of component you want | |
name | string |
Enter name of the radio s | |
defaultIndex | number |
You could set default value through this property |