diff --git a/src/component/common/Radio.tsx b/src/component/common/RadioButton/Radio.tsx similarity index 94% rename from src/component/common/Radio.tsx rename to src/component/common/RadioButton/Radio.tsx index 40916f29..2cab4d64 100644 --- a/src/component/common/Radio.tsx +++ b/src/component/common/RadioButton/Radio.tsx @@ -1,8 +1,7 @@ import { css } from "@emotion/react"; import { useContext } from "react"; -import ListItemCard from "./Card/ListItemCard"; - +import ListItemCard from "@/component/common/Card/ListItemCard"; import { RadioContext } from "@/store/context/RadioContext"; type RadioProps = { diff --git a/src/component/common/RadioButton/RadioButtonGroup.tsx b/src/component/common/RadioButton/RadioButtonGroup.tsx new file mode 100644 index 00000000..32253b6f --- /dev/null +++ b/src/component/common/RadioButton/RadioButtonGroup.tsx @@ -0,0 +1,31 @@ +import { css } from "@emotion/react"; +import { useState } from "react"; + +import Radio from "./Radio"; + +import { RadioContext } from "@/store/context/RadioContext"; + +type RadioButtonGroupProps = { + items: { value: string; text: string }[]; +}; + +const RadioButtonGroup = ({ items }: RadioButtonGroupProps) => { + const [selectedValue, setSelectedValue] = useState(); + return ( +
+ setSelectedValue(val) }}> + {items.map(({ value, text }) => { + return ; + })} + +
+ ); +}; + +export default RadioButtonGroup; diff --git a/src/store/context/RadioContext.ts b/src/store/context/RadioContext.ts new file mode 100644 index 00000000..dd4bc54d --- /dev/null +++ b/src/store/context/RadioContext.ts @@ -0,0 +1,8 @@ +import { createContext } from "react"; + +type RadioContextState = { + selectedValue?: string; + onChange?: (value: string) => void; +}; + +export const RadioContext = createContext(undefined);