Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ yarn-error.log*
# Misc
.DS_Store
*.pem
.mcp.json

# Storybook build output
packages/timo-design-system/storybook-static/
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import { CreateButton } from "./CreateButton";

import type { Meta, StoryObj } from "@storybook/react";

const meta = {
title: "Components/CreateButton",

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

디자인 시스템에 따라 컴포넌트를 구현하다 보니, 같은 버튼 종류의 컴포넌트 같은 경우 Components/Button/CreateButton 이런 식으로 폴더 구조를 한 번 더 가져가는 게 좋을 것 같은 생각이 들었어요!

컴포넌트가 더 많아질 거로 생각돼서, 미리 구조화하면 시각적으로 구분하기도 더 좋을 것 같아요! 스토리북 폴더 구조뿐만 아니라 실제 파일 구조도 한 번 더 구조화해 주시면 감사하겠습니다!

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

그렇네요! 구조화도 신경써야겠네요!!! 👍🏻🫡

component: CreateButton,
parameters: {
layout: "centered",
},
argTypes: {
label: {
control: "text",
description: "버튼에 표시될 텍스트",
table: {
type: { summary: "string" },
},
},
disabled: {
control: "boolean",
description: "버튼 비활성화 여부",
table: {
type: { summary: "boolean" },
defaultValue: { summary: "false" },
},
},
},
} satisfies Meta<typeof CreateButton>;

export default meta;
type Story = StoryObj<typeof meta>;

export const Default: Story = {
args: { label: "생성하기" },
};

export const Disabled: Story = {
args: { label: "생성하기", disabled: true },
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import { cn } from "@lib";

export interface CreateButtonProps {
label: string;
disabled?: boolean;
onClick?: () => void;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

onClick을 꼭 안 넣어도 되게(안 넣어도 에러 안 나게) 해두신 이유가 궁금합니당!

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

질문 감사합니다! 저도 몰라서 찾아봤어요.. 🫰🏻
onClick이 모든 버튼에서 필요한 건 아니라고 해요.
type="submit" 버튼처럼 form의 onSubmit으로 동작할 때도 있고,
부모 요소가 클릭처리하는 경우도 있고,
또 disabled 상태에서는 브라우저가 클릭 이벤트를 발생시키지 않아서 onClick을 전달하더라도 실행되지 않아요.
그래서 선택 prop으로 뒀습니다!

}

export const CreateButton = ({
label,
disabled = false,
onClick,
}: CreateButtonProps) => {
return (
<button
type="button"
onClick={onClick}
disabled={disabled}
className={cn(
"typo-headline-b-14 inline-flex items-center justify-center rounded px-3 py-1.5",
disabled
? "bg-timo-gray-500 text-timo-gray-700 cursor-not-allowed"
: "bg-timo-blue-300 cursor-pointer text-white",
)}
Comment thread
ehye1 marked this conversation as resolved.
>
{label}
</button>
);
};
13 changes: 7 additions & 6 deletions packages/timo-design-system/src/components/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
export { Checkbox } from "./checkbox/Checkbox";
export { Color } from "./color/Color";
export { Typography } from "./typography/Typography";
export { Tag } from "./tag/Tag";
export { PriorityIcon } from "./priority-icon/PriorityIcon";
export { TodayBadge } from "./badge/today-badge/TodayBadge";
export { Checkbox } from "@components/checkbox/Checkbox";
export { Color } from "@components/color/Color";
export { Typography } from "@components/typography/Typography";
export { Tag } from "@components/tag/Tag";
export { PriorityIcon } from "@components/priority-icon/PriorityIcon";
export { CreateButton } from "@components/button/create-button/CreateButton";
export { TodayBadge } from "@components/badge/today-badge/TodayBadge";
Loading