Skip to content
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

typography 디자인 토큰 스토리 작성 #23

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
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
69 changes: 69 additions & 0 deletions src/design-token/typography.stories.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
import { Meta, StoryObj } from "@storybook/react";

import typography from "./typography";

const meta: Meta<typeof Text> = {
Copy link
Member Author

Choose a reason for hiding this comment

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

typography는 컴포넌트가 아니라서 docs가 없어도 괜찮을 거 같은데 어떻게 생각하시나요!

Copy link
Member

Choose a reason for hiding this comment

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

저는 개인적으로 통일성때문에 있었으면 좋겠어요...😊
className에 적용해서 사용하면 된다는 간단한 설명 있으면 좋지 않을까요?

Copy link
Member Author

Choose a reason for hiding this comment

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

좋습니다!! 반영했습니다 7bf8eba

title: "Design Tokens/Typography",
Copy link
Member Author

Choose a reason for hiding this comment

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

- Components
  - Button
- Design Tokens
  - Typography

디자인 토큰 / 컴포넌트 그룹으로 나누면 좋을 거 같아서 우선 디자인 토큰만 폴더로 나눠봤습니다. 괜찮나요?

Copy link
Member

Choose a reason for hiding this comment

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

아우 너무 좋아요 ㅎㅎ

tags: ["autodocs"],
component: Text,
argTypes: {
className: {
control: {
type: "radio",
// radio label을 mm-semantic-typography-h1에서 h1로 변경
labels: Object.fromEntries(
Object.entries(typography.$semantic).map(([key, value]) => [
value,
key,
]),
),
},
Comment on lines +13 to +20
Copy link
Member Author

Choose a reason for hiding this comment

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

labels이 없으면 아래처럼 options 값으로 보이는데 "mm-sementic-typography" 는 없어도 괜찮을 거 같아서 변경해봤습니다! (다시 보니 라벨 없을 때도 괜찮은 거 같네요🤔)

라벨 없을 때 라벨 있을 때
image image

Copy link
Member

Choose a reason for hiding this comment

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

ㅎㅎ 둘 다 좋아요! 보편적으로는 오른쪽이 보기 편한 것 같아요! 굿굿👍🏻

options: Object.values(typography.$semantic),
},
},
excludeStories: /Text/,
};

export default meta;

type Story = StoryObj<typeof Text>;

export const Variants: Story = {
args: {
className: typography.$semantic.body1Bold,
children: "Git challenge 디자인 시스템",
},
};

export const Overview: Story = {
parameters: {
controls: { exclude: ["className", "children"] },
},
// render: () => {} 처럼 매개변수가 없으면, controls 필터링 기능이 동작하지 않는 문제가 있음
// https://github.com/storybookjs/storybook/issues/23343#issuecomment-1627351756
// eslint-disable-next-line @typescript-eslint/no-unused-vars
render: (_) => (
<div style={{ display: "flex", flexDirection: "column", gap: "6px" }}>
{Object.entries(typography.$semantic).map(([key, value]) => (
<Text className={value} key={key}>
{key}
</Text>
))}
</div>
),
};

type TypographySementicKey = keyof typeof typography.$semantic;

export interface TextProps<Key extends TypographySementicKey> {
/** className에 typography 토큰을 설정해 적용할 수 있습니다. */
className: (typeof typography.$semantic)[Key];
children: string;
}

export function Text<Key extends TypographySementicKey>({
Comment on lines +58 to +64
Copy link
Member Author

Choose a reason for hiding this comment

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

TextProps, Text는 스토리에서만 사용되는데 외부로 export 하는 이유는 스토리북 autodocs 때문입니다. autodocs 기능은 내부적으로 react-docgen-typescript를 사용하는데 props랑 컴포넌트를 named export 해야 적용된다네요!

className,
children,
}: TextProps<Key>) {
return <div className={className}>{children}</div>;
}
2 changes: 1 addition & 1 deletion src/design-token/typography.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ const $semantic = {
caption2Regular: "mm-semantic-typography-caption2-regular",
caption2Bold: "mm-semantic-typography-caption2-bold",
code: "mm-semantic-typography-code",
};
} as const;

const typography = { $semantic };
export default typography;
Loading