Repository navigation
[FEAT] Tag, PriorityIcon 컴포넌트 추가 및 Storybook 커스터마이징 #49
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 6 commits
113ad6a
29312b3
a690406
fc5c852
659b550
f666709
7a5c6b8
bb9f4fb
7fc87d0
c03e4c5
543e408
3d6ef63
bbc9db2
b51ed96
c36628d
ff79f01
0e0fe8c
8e60a24
d8b48f4
593863b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. js말고 css로 텍스트를 추가하는 방식이 깔끔한 것 같아요. 이런 방식으로 사용할 수도 있군용! |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| <style> | ||
| .sidebar-header img { | ||
| height: 50px; | ||
| width: auto; | ||
| } | ||
|
|
||
| .sidebar-header a { | ||
| display: flex; | ||
| align-items: center; | ||
| } | ||
|
|
||
| .sidebar-header a::after { | ||
| content: "TIMO DESIGN SYSTEM"; | ||
| font-size: 13px; | ||
| font-weight: 700; | ||
| color: #1f1f1f; | ||
| margin-left: 10px; | ||
| letter-spacing: 0.04em; | ||
| white-space: nowrap; | ||
| } | ||
| </style> |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| import { addons } from "@storybook/manager-api"; | ||
|
|
||
| import { timoTheme } from "./theme"; | ||
|
|
||
| addons.setConfig({ | ||
| theme: timoTheme, | ||
| }); |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,42 @@ | ||
| import { create } from "@storybook/theming"; | ||
|
|
||
| export const timoTheme = create({ | ||
| base: "light", | ||
|
|
||
| brandImage: "/timo-logo/timo-logo.png", | ||
| brandTitle: "TIMO DESIGN SYSTEM", | ||
| brandUrl: "https://timo.kr", | ||
| brandTarget: "_blank", | ||
|
|
||
| // 배경 | ||
| colorPrimary: "#74A0F8", | ||
| colorSecondary: "#8CB0F9", | ||
|
|
||
| // UI | ||
| appBg: "#f5f5f5", | ||
| appContentBg: "#ffffff", | ||
| appPreviewBg: "#ffffff", | ||
| appBorderColor: "#e5e5e5", | ||
| appBorderRadius: 10, | ||
|
|
||
| // 텍스트 | ||
| textColor: "#1f1f1f", | ||
| textMutedColor: "#757575", | ||
| textInverseColor: "#ffffff", | ||
|
|
||
| // 툴바 | ||
| barTextColor: "#525252", | ||
| barHoverColor: "#8CB0F9", | ||
| barSelectedColor: "#74a0f8", | ||
| barBg: "#ffffff", | ||
|
|
||
| // 인풋 | ||
| inputBg: "#ffffff", | ||
| inputBorder: "#e5e5e5", | ||
| inputTextColor: "#1f1f1f", | ||
| inputBorderRadius: 6, | ||
|
|
||
| // 버튼 | ||
| buttonBg: "#f5f5f5", | ||
| buttonBorder: "#e5e5e5", | ||
| }); |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| declare module "*.css"; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,2 +1,4 @@ | ||
| export { Color } from "./color/Color"; | ||
| export { Typography } from "./typography/Typography"; | ||
| export { Tag } from "./tag/Tag"; | ||
| export { PriorityIcon } from "./priority-icon/PriorityIcon"; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,40 @@ | ||
| import { PriorityIcon } from "./PriorityIcon"; | ||
|
|
||
| import type { Meta, StoryObj } from "@storybook/react"; | ||
|
|
||
| const meta = { | ||
| title: "Components/PriorityIcon", | ||
| component: PriorityIcon, | ||
| parameters: { | ||
| layout: "centered", | ||
| }, | ||
| argTypes: { | ||
| priority: { | ||
| control: "select", | ||
| options: ["매우중요", "중요", "보통", "낮음", "Disable"], | ||
| }, | ||
| }, | ||
| } satisfies Meta<typeof PriorityIcon>; | ||
|
|
||
| export default meta; | ||
| type Story = StoryObj<typeof meta>; | ||
|
|
||
| export const 매우중요: Story = { | ||
| args: { priority: "매우중요" }, | ||
| }; | ||
|
|
||
| export const 중요: Story = { | ||
| args: { priority: "중요" }, | ||
| }; | ||
|
|
||
| export const 보통: Story = { | ||
| args: { priority: "보통" }, | ||
| }; | ||
|
|
||
| export const 낮음: Story = { | ||
| args: { priority: "낮음" }, | ||
| }; | ||
|
|
||
| export const Disable: Story = { | ||
| args: { priority: "Disable" }, | ||
| }; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| import { cn } from "../../lib"; | ||
|
|
||
| export type Priority = "매우중요" | "중요" | "보통" | "낮음" | "Disable"; | ||
|
|
||
| const PRIORITY_COLOR: Record<Priority, string> = { | ||
| 매우중요: "bg-timo-red", | ||
| 중요: "bg-timo-orange", | ||
| 보통: "bg-timo-gray-600", | ||
| 낮음: "bg-timo-black", | ||
| Disable: "bg-timo-gray-500", | ||
| }; | ||
|
|
||
| export interface PriorityIconProps { | ||
| priority: Priority; | ||
| } | ||
|
|
||
| export const PriorityIcon = ({ priority = "매우중요" }: PriorityIconProps) => { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. priority가 PriorityIconProps에서 required인데 기본값이 설정되어 있어요. 저는 optional로 맞추거나 기본값을 제거하는 게 좋을 것 같다고 생각이 들어요.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. props로 우선순위를 명확히 지정해서 전달한 뒤 쓰이는 경우가 많을 컴포넌트라고 생각되어 optional을 제거했었는데, 기본값도 함께 제거하는 걸 까먹었었네요! 제거해두겠습니돠
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 태그 디자인은 이미 변경 사항 반영해 두었어요~~!! |
||
| return ( | ||
| <div | ||
| className={cn("size-4.5 shrink-0 rounded-full", PRIORITY_COLOR[priority])} | ||
| /> | ||
| ); | ||
| }; | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,52 @@ | ||
| import { Tag } from "./Tag"; | ||
|
|
||
| import type { Meta, StoryObj } from "@storybook/react"; | ||
|
|
||
| const meta = { | ||
| title: "Components/Tag", | ||
| component: Tag, | ||
| parameters: { | ||
| layout: "centered", | ||
| }, | ||
| argTypes: { | ||
| variant: { | ||
| control: "select", | ||
| options: ["과제", "운동", "일상", "업무", "기타"], | ||
| }, | ||
| }, | ||
| } satisfies Meta<typeof Tag>; | ||
|
|
||
| export default meta; | ||
| type Story = StoryObj<typeof meta>; | ||
|
|
||
| export const 과제: Story = { | ||
| args: { variant: "과제" }, | ||
| }; | ||
|
|
||
| export const 운동: Story = { | ||
| args: { variant: "운동" }, | ||
| }; | ||
|
|
||
| export const 일상: Story = { | ||
| args: { variant: "일상" }, | ||
| }; | ||
|
|
||
| export const 업무: Story = { | ||
| args: { variant: "업무" }, | ||
| }; | ||
|
|
||
| export const 기타: Story = { | ||
| args: { variant: "기타" }, | ||
| }; | ||
|
|
||
| export const AllVariants: Story = { | ||
| render: () => ( | ||
| <div className="flex flex-col gap-2"> | ||
| {(["과제", "운동", "일상", "업무", "기타"] as const).map((variant) => ( | ||
| <div key={variant} className="flex items-center gap-2"> | ||
| <Tag variant={variant} /> | ||
| </div> | ||
| ))} | ||
| </div> | ||
| ), | ||
| }; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,43 @@ | ||
| import { cn } from "../../lib"; | ||
|
|
||
| export type TagVariant = "과제" | "운동" | "일상" | "업무" | "기타"; | ||
|
|
||
| const TAG_BG: Record<TagVariant, string> = { | ||
| 과제: "bg-timo-yellow-300", | ||
| 운동: "bg-timo-green", | ||
| 일상: "bg-timo-blue-75", | ||
| 업무: "bg-timo-gray-900", | ||
| 기타: "bg-timo-gray-500", | ||
| }; | ||
|
|
||
| const TAG_TEXT_COLOR: Record<TagVariant, string> = { | ||
| 과제: "text-timo-black", | ||
| 운동: "text-white", | ||
| 일상: "text-white", | ||
| 업무: "text-white", | ||
| 기타: "text-timo-gray-800", | ||
| }; | ||
|
|
||
| export interface TagProps { | ||
| variant?: TagVariant; | ||
| } | ||
|
|
||
| export const Tag = ({ variant = "과제" }: TagProps) => { | ||
| return ( | ||
| <div | ||
| className={cn( | ||
| "flex h-4 w-7.5 items-center justify-center rounded-[4px]", | ||
| TAG_BG[variant], | ||
| )} | ||
| > | ||
| <span | ||
| className={cn( | ||
| "typo-caption-r-10 whitespace-nowrap", | ||
| TAG_TEXT_COLOR[variant], | ||
| )} | ||
| > | ||
| {variant} | ||
| </span> | ||
| </div> | ||
|
kimminna marked this conversation as resolved.
Resolved
|
||
| ); | ||
| }; | ||
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Uh oh!
There was an error while loading. Please reload this page.