-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
feat(Tag): Tag 컴포넌트 개발
- Loading branch information
Showing
10 changed files
with
246 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,36 +7,41 @@ | |
} | ||
|
||
body { | ||
background-color: rgb(0, 0, 0); | ||
background-color: #1e1e1e; | ||
} | ||
|
||
@font-face { | ||
font-family: "SUIT"; | ||
src: url("https://cdn.jsdelivr.net/gh/projectnoonnu/[email protected]/SUIT-Light.woff2") format("woff2"); | ||
src: url("https://cdn.jsdelivr.net/gh/projectnoonnu/[email protected]/SUIT-Light.woff2") | ||
format("woff2"); | ||
font-weight: 300; | ||
font-style: normal; | ||
} | ||
@font-face { | ||
font-family: "SUIT"; | ||
src: url("https://cdn.jsdelivr.net/gh/projectnoonnu/[email protected]/SUIT-Regular.woff2") format("woff2"); | ||
src: url("https://cdn.jsdelivr.net/gh/projectnoonnu/[email protected]/SUIT-Regular.woff2") | ||
format("woff2"); | ||
font-weight: 400; | ||
font-style: normal; | ||
} | ||
@font-face { | ||
font-family: "SUIT"; | ||
src: url("https://cdn.jsdelivr.net/gh/projectnoonnu/[email protected]/SUIT-Medium.woff2") format("woff2"); | ||
src: url("https://cdn.jsdelivr.net/gh/projectnoonnu/[email protected]/SUIT-Medium.woff2") | ||
format("woff2"); | ||
font-weight: 500; | ||
font-style: normal; | ||
} | ||
@font-face { | ||
font-family: "SUIT"; | ||
src: url("https://cdn.jsdelivr.net/gh/projectnoonnu/[email protected]/SUIT-SemiBold.woff2") format("woff2"); | ||
src: url("https://cdn.jsdelivr.net/gh/projectnoonnu/[email protected]/SUIT-SemiBold.woff2") | ||
format("woff2"); | ||
font-weight: 600; | ||
font-style: normal; | ||
} | ||
@font-face { | ||
font-family: "SUIT"; | ||
src: url("https://cdn.jsdelivr.net/gh/projectnoonnu/[email protected]/SUIT-Bold.woff2") format("woff2"); | ||
src: url("https://cdn.jsdelivr.net/gh/projectnoonnu/[email protected]/SUIT-Bold.woff2") | ||
format("woff2"); | ||
font-weight: 700; | ||
font-style: normal; | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import { Meta, StoryObj } from "@storybook/react"; | ||
|
||
import { type HTMLAttributes } from "react"; | ||
import { Tag } from "@sopt-makers/ui"; | ||
|
||
interface TagOwnProps extends HTMLAttributes<HTMLSpanElement> { | ||
children?: string; | ||
size?: "sm" | "md" | "lg"; | ||
shape?: "rect" | "pill"; | ||
variant?: "default" | "primary" | "secondary"; | ||
type?: "solid" | "line"; | ||
} | ||
|
||
type TagStoryProps = TagOwnProps & { children: string }; | ||
|
||
export default { | ||
title: "Components/Tag", | ||
component: Tag, | ||
tags: ["autodocs"], | ||
} as Meta<TagStoryProps>; | ||
|
||
// 기본 태그 스토리 | ||
export const Default: StoryObj<TagStoryProps> = { | ||
args: { | ||
children: "Default Tag", | ||
size: "sm", | ||
shape: "rect", | ||
variant: "default", | ||
type: "solid", | ||
}, | ||
}; | ||
|
||
// 커스텀 버튼 스토리 | ||
export const Another: StoryObj<TagStoryProps> = { | ||
args: { | ||
children: "Another Tag", | ||
size: "md", | ||
shape: "pill", | ||
variant: "primary", | ||
type: "line", | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import * as S from "./style.css"; | ||
import createTagStyle from "./utils"; | ||
|
||
interface TagProps { | ||
children?: React.ReactNode; | ||
size?: "sm" | "md" | "lg"; | ||
shape?: "rect" | "pill"; | ||
variant?: "default" | "primary" | "secondary"; | ||
type?: "solid" | "line"; | ||
} | ||
|
||
function Tag({ | ||
children, | ||
size = "sm", | ||
shape = "rect", | ||
variant = "default", | ||
type = "solid", | ||
}: TagProps) { | ||
const style = createTagStyle(type, variant, shape, size); | ||
return ( | ||
<div className={`${S.root} ${style}`}> | ||
{children} | ||
</div> | ||
); | ||
} | ||
|
||
export default Tag; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import theme from "../theme.css"; | ||
import type { | ||
TagBgColorTheme, | ||
TagShapeTheme, | ||
TagSizeTheme, | ||
TagVariantTheme, | ||
} from "./types"; | ||
|
||
export const bgColors: Record<TagBgColorTheme, string> = { | ||
"default-solid": theme.colors.gray700, | ||
"primary-solid": theme.colors.orangeAlpha200, | ||
"secondary-solid": theme.colors.blueAlpha200, | ||
"default-line": "unset", | ||
"primary-line": "unset", | ||
"secondary-line": "unset", | ||
}; | ||
|
||
export const borders: Record<TagBgColorTheme, string> = { | ||
"default-solid": "none", | ||
"primary-solid": "none", | ||
"secondary-solid": "none", | ||
"default-line": `0 0 0 1px ${theme.colors.gray300} inset`, | ||
"primary-line": `0 0 0 1px ${theme.colors.orange700} inset`, | ||
"secondary-line": `0 0 0 1px ${theme.colors.blue700} inset`, | ||
}; | ||
|
||
export const textColors: Record<TagVariantTheme, string> = { | ||
default: theme.colors.gray10, | ||
primary: theme.colors.secondary, | ||
secondary: theme.colors.success, | ||
}; | ||
|
||
export const borderRadiuses: Record<TagShapeTheme, string> = { | ||
rect: "4px", | ||
pill: "100px", | ||
}; | ||
|
||
export const paddings: Record<TagSizeTheme, string> = { | ||
sm: "3px 6px", | ||
md: "3px 7px", | ||
lg: "3px 8px", | ||
}; | ||
|
||
export const fonts = { | ||
sm: theme.fontsObject.LABEL_5_11_SB, | ||
md: theme.fontsObject.LABEL_3_14_SB, | ||
lg: theme.fontsObject.LABEL_2_16_SB, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export { default } from "./Tag"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import { createSprinkles, defineProperties } from "@vanilla-extract/sprinkles"; | ||
import { style } from "@vanilla-extract/css"; | ||
import { | ||
bgColors, | ||
borderRadiuses, | ||
borders, | ||
fonts, | ||
paddings, | ||
textColors, | ||
} from "./constants"; | ||
|
||
export const root = style({ | ||
display: "flex", | ||
justifyContent: "center", | ||
alignItems: "center", | ||
width: "fit-content", | ||
height: "fit-content", | ||
}); | ||
|
||
const sprinkleProperties = defineProperties({ | ||
properties: { | ||
backgroundColor: bgColors, | ||
boxShadow: borders, | ||
color: textColors, | ||
borderRadius: borderRadiuses, | ||
padding: paddings, | ||
fontStyle: fonts, | ||
}, | ||
}); | ||
|
||
export const sprinkles = createSprinkles(sprinkleProperties); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
export type TagSizeTheme = "sm" | "md" | "lg"; | ||
|
||
export type TagShapeTheme = "rect" | "pill"; | ||
|
||
export type TagVariantTheme = "default" | "primary" | "secondary"; | ||
|
||
export type TagTypeTheme = "solid" | "line"; | ||
|
||
export type TagBgColorTheme = `${TagVariantTheme}-${TagTypeTheme}`; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import type { | ||
TagShapeTheme, | ||
TagSizeTheme, | ||
TagTypeTheme, | ||
TagVariantTheme, | ||
} from "./types"; | ||
import { sprinkles } from "./style.css"; | ||
|
||
function createTagStyle( | ||
typeTheme: TagTypeTheme, | ||
variantTheme: TagVariantTheme, | ||
shapeTheme: TagShapeTheme, | ||
sizeTheme: TagSizeTheme | ||
) { | ||
return sprinkles({ | ||
backgroundColor: `${variantTheme}-${typeTheme}`, | ||
boxShadow: `${variantTheme}-${typeTheme}`, | ||
color: variantTheme, | ||
borderRadius: shapeTheme, | ||
padding: sizeTheme, | ||
fontStyle: sizeTheme, | ||
}); | ||
} | ||
export default createTagStyle; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters