diff --git a/component-docs/public/mdx/component/chip-tabs.mdx b/component-docs/public/mdx/component/chip-tabs.mdx index 8b4ef180a..0585c6b6e 100644 --- a/component-docs/public/mdx/component/chip-tabs.mdx +++ b/component-docs/public/mdx/component/chip-tabs.mdx @@ -11,8 +11,8 @@ import { useLazyContents, type UseLazyContentsProps, } from "@seed-design/react-tabs"; -import { chipTabs } from "@seed-design/recipe/chipTabs"; -import { chipTab } from "@seed-design/recipe/chipTab"; +import { chipTabs, ChipTabsVariant } from "@seed-design/recipe/chipTabs"; +import { chipTab, ChipTabVariant } from "@seed-design/recipe/chipTab"; import "@seed-design/stylesheet/chipTab.css"; import "@seed-design/stylesheet/chipTabs.css"; @@ -23,6 +23,7 @@ interface ChipTabsContextValue { api: ReturnType; classNames: ReturnType; shouldRender: (value: string) => boolean; + variant: ChipTabsVariant["variant"]; } const ChipTabsContext = React.createContext(null); @@ -37,12 +38,15 @@ const useChipTabsContext = () => { export interface ChipTabsProps extends Assign, Omit>, + ChipTabsVariant, Omit {} export const ChipTabs = React.forwardRef((props, ref) => { - const { className, lazyMode, isLazy } = props; + const { className, lazyMode, isLazy, variant } = props; const api = useTabs(props); - const classNames = chipTabs(); + const classNames = chipTabs({ + variant, + }); const { rootProps, value, restProps } = api; const { shouldRender } = useLazyContents({ currentValue: value, lazyMode, isLazy }); @@ -53,6 +57,7 @@ export const ChipTabs = React.forwardRef((props, api, classNames, shouldRender, + variant, }} > {props.children} @@ -102,9 +107,11 @@ export interface ChipTabTriggerProps export const ChipTabTrigger = React.forwardRef( ({ className, children, value, ...otherProps }, ref) => { - const { api } = useChipTabsContext(); + const { api, variant } = useChipTabsContext(); const { getTabTriggerProps } = api; - const { label, root } = chipTab(); + const { label, root } = chipTab({ + variant, + }); const { rootProps, labelProps } = getTabTriggerProps({ value }); return ( diff --git a/component-docs/public/mdx/react/chip-tabs-preview.mdx b/component-docs/public/mdx/react/chip-tabs-preview.mdx index c4916c298..2483cd4e6 100644 --- a/component-docs/public/mdx/react/chip-tabs-preview.mdx +++ b/component-docs/public/mdx/react/chip-tabs-preview.mdx @@ -6,7 +6,12 @@ export default function ChipTabsPreview() { const [value, setValue] = React.useState("1"); return ( <> - setValue(value)}> + setValue(value)} + > 라벨1 라벨2 diff --git a/component-docs/public/mdx/react/chip-tabs-variant-brand-weak.mdx b/component-docs/public/mdx/react/chip-tabs-variant-brand-weak.mdx new file mode 100644 index 000000000..6b9ef7674 --- /dev/null +++ b/component-docs/public/mdx/react/chip-tabs-variant-brand-weak.mdx @@ -0,0 +1,28 @@ +```tsx copy +import * as React from "react"; +import { ChipTabs, ChipTabTrigger, ChipTabTriggerList } from "seed-design/ui/chip-tabs"; + +export default function ChipTabsVariantBrandWeak() { + const [value, setValue] = React.useState("1"); + return ( + <> + setValue(value)} + > + + 라벨1 + 라벨2 + 라벨3 + + + {value === "1" &&
content 1
} + {value === "2" &&
content 2
} + {value === "3" &&
content 3
} + + ); +} + +``` diff --git a/component-docs/public/mdx/react/chip-tabs-variant-neutral-solid.mdx b/component-docs/public/mdx/react/chip-tabs-variant-neutral-solid.mdx new file mode 100644 index 000000000..5a0c8a3fb --- /dev/null +++ b/component-docs/public/mdx/react/chip-tabs-variant-neutral-solid.mdx @@ -0,0 +1,28 @@ +```tsx copy +import * as React from "react"; +import { ChipTabs, ChipTabTrigger, ChipTabTriggerList } from "seed-design/ui/chip-tabs"; + +export default function ChipTabsVariantNeutralSolid() { + const [value, setValue] = React.useState("1"); + return ( + <> + setValue(value)} + > + + 라벨1 + 라벨2 + 라벨3 + + + {value === "1" &&
content 1
} + {value === "2" &&
content 2
} + {value === "3" &&
content 3
} + + ); +} + +``` diff --git a/component-docs/public/mdx/stackflow/chip-tabs-basic-activity.mdx b/component-docs/public/mdx/stackflow/chip-tabs-basic-activity.mdx index 7a94ec361..d4190500c 100644 --- a/component-docs/public/mdx/stackflow/chip-tabs-basic-activity.mdx +++ b/component-docs/public/mdx/stackflow/chip-tabs-basic-activity.mdx @@ -27,7 +27,12 @@ const ChipTabsBasicActivity: ActivityComponentType<"ChipTabsBasic"> = () => { return ( - setValue(value)}> + setValue(value)} + > 라벨1 라벨2 diff --git a/component-docs/public/registry/component/chip-tabs.json b/component-docs/public/registry/component/chip-tabs.json index cb0578707..c773165fa 100644 --- a/component-docs/public/registry/component/chip-tabs.json +++ b/component-docs/public/registry/component/chip-tabs.json @@ -6,7 +6,7 @@ "registries": [ { "name": "chip-tabs.tsx", - "content": "\"use client\";\n\nimport clsx from \"clsx\";\nimport * as React from \"react\";\nimport {\n useTabs,\n type UseTabsProps,\n type TriggerProps,\n type ContentProps,\n useLazyContents,\n type UseLazyContentsProps,\n} from \"@seed-design/react-tabs\";\nimport { chipTabs } from \"@seed-design/recipe/chipTabs\";\nimport { chipTab } from \"@seed-design/recipe/chipTab\";\n\nimport \"@seed-design/stylesheet/chipTab.css\";\nimport \"@seed-design/stylesheet/chipTabs.css\";\n\ntype Assign = Omit & U;\n\ninterface ChipTabsContextValue {\n api: ReturnType;\n classNames: ReturnType;\n shouldRender: (value: string) => boolean;\n}\n\nconst ChipTabsContext = React.createContext(null);\n\nconst useChipTabsContext = () => {\n const context = React.useContext(ChipTabsContext);\n if (!context) {\n throw new Error(\"Tabs cannot be rendered outside the Tabs\");\n }\n return context;\n};\n\nexport interface ChipTabsProps\n extends Assign, Omit>,\n Omit {}\n\nexport const ChipTabs = React.forwardRef((props, ref) => {\n const { className, lazyMode, isLazy } = props;\n const api = useTabs(props);\n const classNames = chipTabs();\n const { rootProps, value, restProps } = api;\n const { shouldRender } = useLazyContents({ currentValue: value, lazyMode, isLazy });\n\n return (\n
\n \n {props.children}\n \n
\n );\n});\nChipTabs.displayName = \"ChipTabs\";\n\nexport const ChipTabTriggerList = React.forwardRef<\n HTMLDivElement,\n React.HTMLAttributes\n>(({ className, children, ...otherProps }, ref) => {\n const { api, classNames } = useChipTabsContext();\n const { tabTriggerListProps, triggerSize } = api;\n const { left } = triggerSize;\n const { triggerList } = classNames;\n\n const containerRef = React.useRef(null);\n React.useImperativeHandle(ref, () => containerRef.current as HTMLDivElement);\n\n React.useEffect(() => {\n if (containerRef.current) {\n containerRef.current?.scrollTo({\n // NOTE: 27px is half of tab's min-width\n left: left - 27,\n behavior: \"smooth\",\n });\n }\n }, [left]);\n\n return (\n \n {children}\n \n );\n});\nChipTabTriggerList.displayName = \"ChipTabTriggerList\";\n\nexport interface ChipTabTriggerProps\n extends Assign, Omit> {}\n\nexport const ChipTabTrigger = React.forwardRef(\n ({ className, children, value, ...otherProps }, ref) => {\n const { api } = useChipTabsContext();\n const { getTabTriggerProps } = api;\n const { label, root } = chipTab();\n const { rootProps, labelProps } = getTabTriggerProps({ value });\n\n return (\n \n );\n },\n);\nChipTabTrigger.displayName = \"ChipTabTrigger\";\n\nexport const ChipTabContent = React.forwardRef<\n HTMLDivElement,\n Assign, ContentProps>\n>(({ className, children, value, ...otherProps }, ref) => {\n const { api, classNames, shouldRender } = useChipTabsContext();\n const { getTabContentProps } = api;\n const { content } = classNames;\n const tabContentProps = getTabContentProps({ value });\n const isRender = shouldRender(value);\n\n return (\n
\n {isRender && children}\n
\n );\n});\nChipTabContent.displayName = \"ChipTabContent\";\n" + "content": "\"use client\";\n\nimport clsx from \"clsx\";\nimport * as React from \"react\";\nimport {\n useTabs,\n type UseTabsProps,\n type TriggerProps,\n type ContentProps,\n useLazyContents,\n type UseLazyContentsProps,\n} from \"@seed-design/react-tabs\";\nimport { chipTabs, ChipTabsVariant } from \"@seed-design/recipe/chipTabs\";\nimport { chipTab, ChipTabVariant } from \"@seed-design/recipe/chipTab\";\n\nimport \"@seed-design/stylesheet/chipTab.css\";\nimport \"@seed-design/stylesheet/chipTabs.css\";\n\ntype Assign = Omit & U;\n\ninterface ChipTabsContextValue {\n api: ReturnType;\n classNames: ReturnType;\n shouldRender: (value: string) => boolean;\n variant: ChipTabsVariant[\"variant\"];\n}\n\nconst ChipTabsContext = React.createContext(null);\n\nconst useChipTabsContext = () => {\n const context = React.useContext(ChipTabsContext);\n if (!context) {\n throw new Error(\"Tabs cannot be rendered outside the Tabs\");\n }\n return context;\n};\n\nexport interface ChipTabsProps\n extends Assign, Omit>,\n ChipTabsVariant,\n Omit {}\n\nexport const ChipTabs = React.forwardRef((props, ref) => {\n const { className, lazyMode, isLazy, variant } = props;\n const api = useTabs(props);\n const classNames = chipTabs({\n variant,\n });\n const { rootProps, value, restProps } = api;\n const { shouldRender } = useLazyContents({ currentValue: value, lazyMode, isLazy });\n\n return (\n
\n \n {props.children}\n \n
\n );\n});\nChipTabs.displayName = \"ChipTabs\";\n\nexport const ChipTabTriggerList = React.forwardRef<\n HTMLDivElement,\n React.HTMLAttributes\n>(({ className, children, ...otherProps }, ref) => {\n const { api, classNames } = useChipTabsContext();\n const { tabTriggerListProps, triggerSize } = api;\n const { left } = triggerSize;\n const { triggerList } = classNames;\n\n const containerRef = React.useRef(null);\n React.useImperativeHandle(ref, () => containerRef.current as HTMLDivElement);\n\n React.useEffect(() => {\n if (containerRef.current) {\n containerRef.current?.scrollTo({\n // NOTE: 27px is half of tab's min-width\n left: left - 27,\n behavior: \"smooth\",\n });\n }\n }, [left]);\n\n return (\n \n {children}\n \n );\n});\nChipTabTriggerList.displayName = \"ChipTabTriggerList\";\n\nexport interface ChipTabTriggerProps\n extends Assign, Omit> {}\n\nexport const ChipTabTrigger = React.forwardRef(\n ({ className, children, value, ...otherProps }, ref) => {\n const { api, variant } = useChipTabsContext();\n const { getTabTriggerProps } = api;\n const { label, root } = chipTab({\n variant,\n });\n const { rootProps, labelProps } = getTabTriggerProps({ value });\n\n return (\n \n );\n },\n);\nChipTabTrigger.displayName = \"ChipTabTrigger\";\n\nexport const ChipTabContent = React.forwardRef<\n HTMLDivElement,\n Assign, ContentProps>\n>(({ className, children, value, ...otherProps }, ref) => {\n const { api, classNames, shouldRender } = useChipTabsContext();\n const { getTabContentProps } = api;\n const { content } = classNames;\n const tabContentProps = getTabContentProps({ value });\n const isRender = shouldRender(value);\n\n return (\n
\n {isRender && children}\n
\n );\n});\nChipTabContent.displayName = \"ChipTabContent\";\n" } ], "type": "component" diff --git a/component-docs/seed-design/ui/chip-tabs.tsx b/component-docs/seed-design/ui/chip-tabs.tsx index 1c1ad65bf..3441fb2d5 100644 --- a/component-docs/seed-design/ui/chip-tabs.tsx +++ b/component-docs/seed-design/ui/chip-tabs.tsx @@ -3,13 +3,13 @@ import { useLazyContents, useTabs, + type ContentProps, type TriggerProps, type UseLazyContentsProps, type UseTabsProps, - type ContentProps, } from "@seed-design/react-tabs"; import { chipTab } from "@seed-design/recipe/chipTab"; -import { chipTabs } from "@seed-design/recipe/chipTabs"; +import { ChipTabsVariant, chipTabs } from "@seed-design/recipe/chipTabs"; import clsx from "clsx"; import * as React from "react"; @@ -22,6 +22,7 @@ interface ChipTabsContextValue { api: ReturnType; classNames: ReturnType; shouldRender: (value: string) => boolean; + variant: ChipTabsVariant["variant"]; } const ChipTabsContext = React.createContext(null); @@ -36,12 +37,15 @@ const useChipTabsContext = () => { export interface ChipTabsProps extends Assign, Omit>, + ChipTabsVariant, Omit {} export const ChipTabs = React.forwardRef((props, ref) => { - const { className, lazyMode, isLazy } = props; + const { className, lazyMode, isLazy, variant } = props; const api = useTabs(props); - const classNames = chipTabs(); + const classNames = chipTabs({ + variant, + }); const { rootProps, value, restProps } = api; const { shouldRender } = useLazyContents({ currentValue: value, lazyMode, isLazy }); @@ -52,6 +56,7 @@ export const ChipTabs = React.forwardRef((props, api, classNames, shouldRender, + variant, }} > {props.children} @@ -97,14 +102,16 @@ export const ChipTabTriggerList = React.forwardRef< ChipTabTriggerList.displayName = "ChipTabTriggerList"; export interface ChipTabTriggerProps - extends Assign, TriggerProps> {} + extends Assign, Omit> {} export const ChipTabTrigger = React.forwardRef( - ({ className, children, value, isDisabled, ...otherProps }, ref) => { - const { api } = useChipTabsContext(); + ({ className, children, value, ...otherProps }, ref) => { + const { api, variant } = useChipTabsContext(); const { getTabTriggerProps } = api; - const { label, root } = chipTab(); - const { rootProps, labelProps } = getTabTriggerProps({ value, isDisabled }); + const { label, root } = chipTab({ + variant, + }); + const { rootProps, labelProps } = getTabTriggerProps({ value }); return (