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

Color Tokens #28

Merged
merged 3 commits into from
Jan 6, 2025
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
3 changes: 2 additions & 1 deletion .storybook/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ const config: StorybookConfig = {
"@storybook/addon-essentials",
"@chromatic-com/storybook",
"@storybook/addon-interactions",
"@storybook/addon-a11y"
"@storybook/addon-a11y",
"@storybook/addon-themes",
],
framework: {
name: "@storybook/react-vite",
Expand Down
13 changes: 11 additions & 2 deletions .storybook/preview.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import "../src/index.css";

import type { Preview } from "@storybook/react";
import { withThemeByClassName } from "@storybook/addon-themes";
import type { Preview, ReactRenderer } from "@storybook/react";

const preview: Preview = {
parameters: {
Expand All @@ -14,6 +14,15 @@ const preview: Preview = {
toc: true,
},
},
decorators: [
withThemeByClassName<ReactRenderer>({
themes: {
light: "",
dark: "dark",
},
defaultTheme: "light",
}),
],
Comment on lines +17 to +25
Copy link
Contributor Author

Choose a reason for hiding this comment

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

이 설정을 통해 툴바에 라이트/다크 모드 전환 버튼이 생깁니다.

Shot 2024-12-30 at 21 17 09

tags: ["autodocs"],
};

Expand Down
Binary file modified bun.lockb
Binary file not shown.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
"@storybook/addon-essentials": "^8.4.7",
"@storybook/addon-interactions": "^8.4.7",
"@storybook/addon-links": "^8.4.7",
"@storybook/addon-themes": "^8.4.7",
"@storybook/blocks": "^8.4.7",
"@storybook/react": "^8.4.7",
"@storybook/react-vite": "^8.4.7",
Expand Down
5 changes: 5 additions & 0 deletions panda.config.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { defineConfig } from "@pandacss/dev";
import { globalCss } from "./src/styles/globalCss";
import { colors, semanticColors } from "./src/tokens/colors";
import {
textStyles,
fonts,
Expand Down Expand Up @@ -30,12 +31,16 @@ export default defineConfig({
extend: {
textStyles,
tokens: {
colors,
fonts,
fontWeights,
fontSizes,
letterSpacings,
lineHeights,
},
semanticTokens: {
colors: semanticColors,
},
},
},

Expand Down
3 changes: 2 additions & 1 deletion src/styles/globalCss.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ import { defineGlobalStyles } from "@pandacss/dev";

export const globalCss = defineGlobalStyles({
":root": {
"--global-font-body": "var (--fonts-sans)",
"--global-font-body": "var(--fonts-sans)",
Copy link
Contributor Author

Choose a reason for hiding this comment

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

제가 이전 PR에서 요기에 오타를 내서 현재 웹사이트에 기본 폰트가 적용이 안 되고 있습니다 😆

backgroundColor: "var(--colors-base)",
},
h1: {
fontSize: "var(--font-sizes-4xl)", // 2.25rem
Expand Down
100 changes: 100 additions & 0 deletions src/tokens/colors.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
import { Meta, ColorPalette, ColorItem } from "@storybook/blocks";
import { colors, semanticColors } from "./colors.ts";

# Colors

달레 UI의 근간이 되는 색상 팔레트입니다.

<ColorPalette>
<ColorItem
title="초록"
subtitle="colors.teal"
colors={Object.fromEntries(
Object.entries(colors.teal).map(([name, { value }]) => [name, value])
)}
/>
<ColorItem
title="초록 (dark)"
subtitle="colors.tealDark"
colors={Object.fromEntries(
Object.entries(colors.tealDark).map(([name, { value }]) => [name, value])
)}
/>
<ColorItem
title="보라"
subtitle="colors.violet"
colors={Object.fromEntries(
Object.entries(colors.violet).map(([name, { value }]) => [name, value])
)}
/>
<ColorItem
title="보라 (dark)"
subtitle="colors.violetDark"
colors={Object.fromEntries(
Object.entries(colors.violetDark).map(([name, { value }]) => [
name,
value,
])
)}
/>
<ColorItem
title="빨강"
subtitle="colors.red"
colors={Object.fromEntries(
Object.entries(colors.red).map(([name, { value }]) => [name, value])
)}
/>
<ColorItem
title="빨강 (dark)"
subtitle="colors.redDark"
colors={Object.fromEntries(
Object.entries(colors.redDark).map(([name, { value }]) => [name, value])
)}
/>
<ColorItem
title="노랑"
subtitle="colors.yellow"
colors={Object.fromEntries(
Object.entries(colors.yellow).map(([name, { value }]) => [name, value])
)}
/>
<ColorItem
title="노랑 (dark)"
subtitle="colors.yellowDark"
colors={Object.fromEntries(
Object.entries(colors.yellowDark).map(([name, { value }]) => [
name,
value,
])
)}
/>
<ColorItem
title="회색"
subtitle="colors.gray"
colors={Object.fromEntries(
Object.entries(colors.gray).map(([name, { value }]) => [name, value])
)}
/>
<ColorItem
title="회색 (dark)"
subtitle="colors.grayDark"
colors={Object.fromEntries(
Object.entries(colors.grayDark).map(([name, { value }]) => [name, value])
)}
/>
</ColorPalette>

용도에 따라서 각 색상은 12가지 스케일로 분리됩니다.

- Scale 1: 페이지 배경
- Scale 2: 예비
- Scale 3: 컴포넌트 배경
- Scale 4: 컴포넌트 배경 (hover)
- Scale 5: 컴포넌트 배경 (active)
- Scale 6: 예비
- Scale 7: 경계
- Scale 8: 경계 (hover)
- Scale 9: 솔리드 배경
- Scale 10: 솔리드 배경 (hover)
- Scale 11: 글자 (low contrast)
- Scale 12: 글자 (high contrast)
Comment on lines +87 to +100
Copy link
Contributor Author

Choose a reason for hiding this comment

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

이 가이드만 준수하여 색상을 사용하면 명암비로 인한 웹 접근성 문제는 피할 수 있을 거라고 생각합니다.

Loading
Loading