diff --git a/src/components/ui/Tag/Tag.module.scss b/src/components/ui/Tag/Tag.module.scss new file mode 100644 index 0000000..ae5273c --- /dev/null +++ b/src/components/ui/Tag/Tag.module.scss @@ -0,0 +1,46 @@ +.Tag { + border-radius: 0.75rem; + height: 2.5rem; + background-color: var(--color-white); + + &.Selected { + background-color: var(--color-gray600); + } + + &.style-primary { + width: fit-content; + padding: 0.5rem 0.875rem; + } + + &.style-add { + width: 2.5rem; + padding: 0.625rem; + } + + & > span { + line-height: 1.5rem; + } + + & > svg > path { + fill: var(--color-gray500); + } +} + +.TagStory { + display: flex; + flex-direction: column; + gap: 1rem; + + .Wrapper { + display: flex; + gap: 1rem; + justify-content: center; + align-items: center; + width: 300px; + } + + .Text { + font-size: 1.125rem; + width: 120px; + } +} diff --git a/src/components/ui/Tag/Tag.stories.tsx b/src/components/ui/Tag/Tag.stories.tsx new file mode 100644 index 0000000..68c0ea4 --- /dev/null +++ b/src/components/ui/Tag/Tag.stories.tsx @@ -0,0 +1,44 @@ +import Tag from "@/components/ui/Tag/Tag"; +import styles from "@/components/ui/Tag/Tag.module.scss"; +import type { TagProps } from "@/components/ui/Tag/Tag.types"; + +import type { Meta, StoryObj } from "@storybook/react"; + +const meta: Meta = { + title: "Example/Tag", + component: Tag, + parameters: { + layout: "centered", + }, + tags: ["!autodocs"], +}; + +export default meta; + +export const Primary: StoryObj = { + args: { + text: "태그", + variant: "primary", + isSelect: false, + }, +}; + +export const VariantProps: StoryObj = { + render: () => ( +
+
+

primary

+ +
+
+

add

+ + +
+
+

isSelect

+ +
+
+ ), +}; diff --git a/src/components/ui/Tag/Tag.tsx b/src/components/ui/Tag/Tag.tsx new file mode 100644 index 0000000..a65701b --- /dev/null +++ b/src/components/ui/Tag/Tag.tsx @@ -0,0 +1,35 @@ +import { forwardRef } from "react"; + +import classNames from "classnames"; + +import Icon from "@/components/ui/Icon/Icon"; +import styles from "@/components/ui/Tag/Tag.module.scss"; +import type { TagProps } from "@/components/ui/Tag/Tag.types"; +import Text from "@/components/ui/Text/Text"; + +const Tag = forwardRef( + ({ variant = "primary", text, isSelect, className, ...props }, ref) => { + return ( +
+ {variant === "primary" && ( + + {text} + + )} + + {variant === "add" && } +
+ ); + }, +); + +export default Tag; diff --git a/src/components/ui/Tag/Tag.types.ts b/src/components/ui/Tag/Tag.types.ts new file mode 100644 index 0000000..e7e962d --- /dev/null +++ b/src/components/ui/Tag/Tag.types.ts @@ -0,0 +1,7 @@ +type TagVariant = "primary" | "add"; + +export interface TagProps extends React.HTMLAttributes { + text?: string; + variant?: TagVariant; + isSelect?: boolean; +}