Skip to content

Na-hyunwoo/segmented-controls

Repository files navigation

์‹คํ–‰ ํ™˜๊ฒฝ

๋ถˆํ•„์š”ํ•œ ๋…ธ๋“œ๋ฅผ ์ตœ์†Œํ™” ํ•˜๊ธฐ ์œ„ํ•ด webpack์œผ๋กœ React + Typescript + Styled Components + Storybook์„ ์„ธํŒ…ํ–ˆ์Šต๋‹ˆ๋‹ค. ๊ทธ๋ฆฌ๊ณ  ๊ฐ„๋‹จํ•œ lint, prettier ์„ค์ •๋„ ์ถ”๊ฐ€ํ–ˆ์Šต๋‹ˆ๋‹ค.

label๊ณผ input์„ ์—ฐ๊ฒฐํ•ด ์›น ์ ‘๊ทผ์„ฑ์„ ๊ณ ๋ คํ•œ ๊ฐœ๋ฐœ์„ ํ•˜์˜€์Šต๋‹ˆ๋‹ค.

framer-motion ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ ์• ๋‹ˆ๋ฉ”์ด์…˜์„ ์ ์šฉํ•˜์˜€์Šต๋‹ˆ๋‹ค.

๋ชจ๋ฐ”์ผ ํ™˜๊ฒฝ์—์„œ๋„ ๋™์ผํ•œ ์‚ฌ์šฉ๊ฐ์„ ์ œ๊ณตํ•ฉ๋‹ˆ๋‹ค.

๊ฐœ๋ฐœ์ž ๊ฒฝํ—˜์„ ์œ„ํ•ด tsDoc์„ ์ถ”๊ฐ€ํ•˜์˜€์Šต๋‹ˆ๋‹ค.

์„œ๋ฐ”์‚ฌ์ด๋“œ ๋ Œ๋”๋ง ์ง€์› -> ํ•ด๋‹น ๊ธฐ๋Šฅ ์ž ์‹œ ๋ณด๋ฅ˜์ž…๋‹ˆ๋‹ค.

์‹คํ–‰ ๋ฐฉ๋ฒ•

  1. package install
  • npm i (or yarn)
  1. run dev server
  • npm run dev (or yarn dev)๋ฅผ ํ†ตํ•ด ๊ตฌํ˜„๋œ ์ปดํฌ๋„ŒํŠธ๋ฅผ localhost:3000์—์„œ ํ™•์ธํ•˜์‹ค ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.
  1. 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"}
      />
    </>
  );
};

๊ฒฐ๊ณผ๋ฌผ

Demo

์†์„ฑ

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

About

A good-lookin' segmented control React component ๐Ÿ”ฅ

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages