diff --git a/src/core/components/Select/SelectBubble/SelectBubble/SelectBubble.stories.tsx b/src/core/components/Select/SelectBubble/SelectBubble/SelectBubble.stories.tsx new file mode 100644 index 0000000..0ebe6d9 --- /dev/null +++ b/src/core/components/Select/SelectBubble/SelectBubble/SelectBubble.stories.tsx @@ -0,0 +1,41 @@ +import { Meta } from "@storybook/react"; +import { useState } from "react"; + +import SelectBubble from "./index"; + +const meta = { + title: "core/Select/SelectBubble/SelectBubble", + component: SelectBubble, + argTypes: {}, +} satisfies Meta; + +export default meta; + +export const Default = () => { + const [ currentValue, setCurrentValue ] = useState("A"); + const data = [ + { key: "A", label: "A반" }, + { key: "B", label: "B반" }, + { key: "C", label: "C반" }, + ]; + + const items = data.map(item => ( + ) => { + const { value } = e.target; + + setCurrentValue(value); + }} + /> + )); + + return ( +
+ +
+ ); +}; diff --git a/src/core/components/Select/SelectBubble/SelectBubble/index.tsx b/src/core/components/Select/SelectBubble/SelectBubble/index.tsx new file mode 100644 index 0000000..6ccb888 --- /dev/null +++ b/src/core/components/Select/SelectBubble/SelectBubble/index.tsx @@ -0,0 +1,34 @@ +import { forwardRef } from "react"; + +import { FormLabel } from "@/index"; +import clsx from "clsx"; +import SelectBubbleItem from "../SelectBubbleItem"; +import { ReturnType, SelectBubbleProps } from "./types"; + +const SelectBubble = forwardRef(( + { + items, + label, + labelColor, + required, + feedback, + ...props + }: SelectBubbleProps, + ref: React.Ref, + ) => { + const { className, ...rest } = props; + + return ( +
+ +
    + {items} +
+
+ ); +}) as unknown as ReturnType; + +export default SelectBubble; + +SelectBubble.displayName = "SelectBubble"; +SelectBubble.Item = SelectBubbleItem; diff --git a/src/core/components/Select/SelectBubble/SelectBubble/types/index.ts b/src/core/components/Select/SelectBubble/SelectBubble/types/index.ts new file mode 100644 index 0000000..f3d7a28 --- /dev/null +++ b/src/core/components/Select/SelectBubble/SelectBubble/types/index.ts @@ -0,0 +1,13 @@ +import { FormLabelProps } from "@/core/components/FormLabel/types"; +import SelectBubbleItem from "../../SelectBubbleItem"; + +export interface SelectBubbleProps extends React.HTMLAttributes, FormLabelProps { + items: React.ReactNode[] +} + +type TableTabComponent = (props: SelectBubbleProps) => React.ReactElement; + +export type ReturnType = TableTabComponent & { + displayName: string; + Item: typeof SelectBubbleItem; +}; diff --git a/src/core/components/Select/SelectBubble/SelectBubbleItem/SelectBubbleItem.stories.tsx b/src/core/components/Select/SelectBubble/SelectBubbleItem/SelectBubbleItem.stories.tsx new file mode 100644 index 0000000..848ca61 --- /dev/null +++ b/src/core/components/Select/SelectBubble/SelectBubbleItem/SelectBubbleItem.stories.tsx @@ -0,0 +1,28 @@ +import { Meta } from "@storybook/react"; + +import SelectBubble from "../SelectBubble"; +import SelectBubbleItem from "./index"; +import { SelectButtonItemProps } from "./types"; + +const meta = { + title: "core/Select/SelectBubble/SelectBubbleItem", + component: SelectBubbleItem, + argTypes: { + label: { + control: "text", + description: "Bubble Label", + }, + }, +} satisfies Meta; + +export default meta; + +export const Default = (props: SelectButtonItemProps) => { + const { label, ...rest } = props; + + return ( +
    + +
+ ); +}; diff --git a/src/core/components/Select/SelectBubble/SelectBubbleItem/index.tsx b/src/core/components/Select/SelectBubble/SelectBubbleItem/index.tsx new file mode 100644 index 0000000..19972cc --- /dev/null +++ b/src/core/components/Select/SelectBubble/SelectBubbleItem/index.tsx @@ -0,0 +1,38 @@ +import { forwardRef, useId } from "react"; + +import { Typography } from "@/index"; +import { SelectButtonItemProps } from "./types"; + +const SelectBubbleItem = forwardRef(( + { + label, + ...props + }: Omit, + ref: React.Ref, + ) => { + const id = useId(); + + return ( +
  • + +
  • + ); +}); + +export default SelectBubbleItem; + +SelectBubbleItem.displayName = "SelectBubbleItem"; diff --git a/src/core/components/Select/SelectBubble/SelectBubbleItem/types/index.ts b/src/core/components/Select/SelectBubble/SelectBubbleItem/types/index.ts new file mode 100644 index 0000000..262a0a1 --- /dev/null +++ b/src/core/components/Select/SelectBubble/SelectBubbleItem/types/index.ts @@ -0,0 +1,7 @@ +import { InputHTMLAttributes } from "react"; + +import { TypographyProps } from "@/core/components/Typography"; + +export interface SelectButtonItemProps extends InputHTMLAttributes { + label: TypographyProps<"span">["text"] +} diff --git a/src/index.ts b/src/index.ts index f607727..945a5e5 100644 --- a/src/index.ts +++ b/src/index.ts @@ -16,6 +16,8 @@ export { default as ModalBase } from "@/core/components/Modal/ModalBase"; export { default as ModalPopUp } from "@/core/components/Modal/ModalPopUp"; export { default as ModalPortal } from "@/core/components/Modal/ModalPortal"; export { default as Section } from "@/core/components/Section"; +export { default as SelectBubble } from "@/core/components/Select/SelectBubble/SelectBubble"; +export { default as SelectBubbleItem } from "@/core/components/Select/SelectBubble/SelectBubbleItem"; export { default as SelectOnset } from "@/core/components/Select/SelectOnset/SelectOnset"; export { default as GeneralTab } from "@/core/components/Tab/GeneralTab/GeneralTab"; export { default as GeneralTabItem } from "@/core/components/Tab/GeneralTab/GeneralTabItem";