daleui 0.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (58) hide show
  1. package/.github/CODEOWNERS +1 -0
  2. package/.github/FUNDING.yml +1 -0
  3. package/.github/workflows/automation.yml +13 -0
  4. package/.github/workflows/chromatic.yml +19 -0
  5. package/.github/workflows/deployment.yml +32 -0
  6. package/.github/workflows/integration.yml +15 -0
  7. package/.github/workflows/storybook-tests.yml +17 -0
  8. package/.storybook/main.ts +18 -0
  9. package/.storybook/preview.ts +29 -0
  10. package/.storybook/test-runner.ts +33 -0
  11. package/LICENSE +21 -0
  12. package/README.md +10 -0
  13. package/bun.lock +9736 -0
  14. package/bun.lockb +0 -0
  15. package/chromatic.config.json +5 -0
  16. package/eslint.config.js +28 -0
  17. package/index.html +13 -0
  18. package/package.json +63 -0
  19. package/panda.config.ts +61 -0
  20. package/postcss.config.cjs +5 -0
  21. package/public/logo.svg +9 -0
  22. package/src/App.tsx +67 -0
  23. package/src/assets/Discord.svg +1 -0
  24. package/src/assets/GitHub.svg +1 -0
  25. package/src/assets/LinkedIn.svg +1 -0
  26. package/src/assets/Medium.svg +1 -0
  27. package/src/assets/YouTube.svg +1 -0
  28. package/src/components/Button/Button.stories.tsx +115 -0
  29. package/src/components/Button/Button.test.tsx +108 -0
  30. package/src/components/Button/Button.tsx +245 -0
  31. package/src/components/Button/index.tsx +1 -0
  32. package/src/components/Heading/Heading.stories.tsx +72 -0
  33. package/src/components/Heading/Heading.test.tsx +55 -0
  34. package/src/components/Heading/Heading.tsx +73 -0
  35. package/src/components/Heading/index.tsx +1 -0
  36. package/src/components/Icon/Icon.stories.tsx +106 -0
  37. package/src/components/Icon/Icon.test.tsx +44 -0
  38. package/src/components/Icon/Icon.tsx +116 -0
  39. package/src/components/Icon/index.tsx +1 -0
  40. package/src/components/Text/Text.stories.tsx +65 -0
  41. package/src/components/Text/Text.test.tsx +54 -0
  42. package/src/components/Text/Text.tsx +93 -0
  43. package/src/components/Text/index.tsx +1 -0
  44. package/src/index.css +2 -0
  45. package/src/main.tsx +10 -0
  46. package/src/setupTests.tsx +5 -0
  47. package/src/styles/globalCss.ts +43 -0
  48. package/src/tokens/colors.mdx +100 -0
  49. package/src/tokens/colors.ts +288 -0
  50. package/src/tokens/iconography.mdx +15 -0
  51. package/src/tokens/iconography.tsx +54 -0
  52. package/src/tokens/typography.mdx +38 -0
  53. package/src/tokens/typography.ts +132 -0
  54. package/src/vite-env.d.ts +2 -0
  55. package/tsconfig.app.json +25 -0
  56. package/tsconfig.json +7 -0
  57. package/tsconfig.node.json +22 -0
  58. package/vite.config.ts +16 -0
@@ -0,0 +1,245 @@
1
+ import React, { type HTMLAttributes } from "react";
2
+ import { css, cva } from "../../../styled-system/css";
3
+ import type { Tone } from "../../tokens/colors";
4
+
5
+ type ButtonVariant = "solid" | "outline";
6
+ type ButtonSize = "sm" | "md" | "lg";
7
+
8
+ export interface ButtonProps
9
+ extends Omit<HTMLAttributes<HTMLElement>, "style"> {
10
+ /** 텍스트 */
11
+ children: React.ReactNode;
12
+ /** 타입 */
13
+ type?: "button" | "submit";
14
+ /** 클릭 시 실행함수 */
15
+ onClick?: () => void;
16
+ /** 종류 */
17
+ variant: ButtonVariant;
18
+ /** 색조 */
19
+ tone?: Tone;
20
+ /** 버튼의 크기 */
21
+ size?: ButtonSize;
22
+ /** 버튼 비활성화 여부 */
23
+ disabled?: boolean;
24
+ }
25
+
26
+ /**
27
+ * - `variant` 속성으로 버튼의 스타일 종류를 지정할 수 있습니다.
28
+ * - `tone` 속성으로 버튼의 색상 강조를 지정할 수 있습니다.
29
+ * - `size` 속성으로 버튼의 크기를 지정할 수 있습니다.
30
+ * - `type` 속성으로 버튼의 타입을 지정할 수 있습니다.
31
+ * - `disabled` 속성을 사용하여 버튼을 비활성화할 수 있습니다.
32
+ */
33
+ export const Button = ({
34
+ children,
35
+ type = "button",
36
+ onClick,
37
+ variant = "solid",
38
+ tone = "neutral",
39
+ size = "md",
40
+ disabled,
41
+ ...rest
42
+ }: ButtonProps) => {
43
+ return (
44
+ <button
45
+ className={css(styles.raw({ tone, variant, size }), baseStyles)}
46
+ type={type}
47
+ onClick={onClick}
48
+ disabled={disabled}
49
+ {...rest}
50
+ >
51
+ {children}
52
+ </button>
53
+ );
54
+ };
55
+
56
+ const baseStyles = {
57
+ appearance: "none",
58
+ margin: "0",
59
+ fontWeight: 500,
60
+ textAlign: "center",
61
+ textDecoration: "none",
62
+ display: "flex",
63
+ alignItems: "center",
64
+ justifyContent: "center",
65
+ width: ["auto", "100%"],
66
+ borderRadius: "10px",
67
+ cursor: "pointer",
68
+ transition: "0.2s",
69
+ lineHeight: "1",
70
+ outline: "0",
71
+ "&:disabled": {
72
+ opacity: 0.5,
73
+ cursor: "not-allowed",
74
+ },
75
+ };
76
+
77
+ const styles = cva({
78
+ base: {
79
+ padding: "0.7rem 3rem",
80
+ },
81
+ variants: {
82
+ size: {
83
+ sm: {
84
+ padding: "0.5rem 1.5rem",
85
+ fontSize: "sm",
86
+ },
87
+ md: {
88
+ padding: "0.7rem 2rem",
89
+ fontSize: "md",
90
+ },
91
+ lg: {
92
+ padding: "1rem 2.5rem",
93
+ fontSize: "lg",
94
+ },
95
+ },
96
+ variant: {
97
+ solid: {},
98
+ outline: {},
99
+ },
100
+ tone: {
101
+ neutral: {},
102
+ accent: {},
103
+ danger: {},
104
+ warning: {},
105
+ },
106
+ },
107
+ compoundVariants: [
108
+ {
109
+ variant: "solid",
110
+ tone: "neutral",
111
+ css: {
112
+ background: "bg",
113
+ color: "text",
114
+ "&:active, &:hover": {
115
+ background: "bg.hover",
116
+ },
117
+ "&:focus": {
118
+ outlineColor: "border.neutral",
119
+ outline: "3px solid",
120
+ outlineOffset: "2px",
121
+ },
122
+ },
123
+ },
124
+ {
125
+ variant: "solid",
126
+ tone: "accent",
127
+ css: {
128
+ background: "bg.accent",
129
+ color: "text.accent",
130
+ "&:active, &:hover": {
131
+ background: "bg.hover.accent",
132
+ },
133
+ "&:focus": {
134
+ outlineColor: "border.accent",
135
+ outline: "3px solid",
136
+ outlineOffset: "2px",
137
+ },
138
+ },
139
+ },
140
+ {
141
+ variant: "solid",
142
+ tone: "danger",
143
+ css: {
144
+ background: "bg.danger",
145
+ color: "text.danger",
146
+ "&:active, &:hover": {
147
+ background: "bg.hover.danger",
148
+ },
149
+ "&:focus": {
150
+ outlineColor: "border.danger",
151
+ outline: "3px solid",
152
+ outlineOffset: "2px",
153
+ },
154
+ },
155
+ },
156
+ {
157
+ variant: "solid",
158
+ tone: "warning",
159
+ css: {
160
+ background: "bg.warning",
161
+ color: "text.warning",
162
+ "&:active, &:hover": {
163
+ background: "bg.hover.warning",
164
+ },
165
+ "&:focus": {
166
+ outlineColor: "border.warning",
167
+ outline: "3px solid",
168
+ outlineOffset: "2px",
169
+ },
170
+ },
171
+ },
172
+ {
173
+ variant: "outline",
174
+ tone: "neutral",
175
+ css: {
176
+ border: "3px solid",
177
+ borderColor: "border",
178
+ color: "text",
179
+ "&:active, &:hover": {
180
+ background: "bg.hover",
181
+ color: "text.muted",
182
+ },
183
+ "&:focus": {
184
+ outlineColor: "border.neutral",
185
+ outline: "3px solid",
186
+ outlineOffset: "2px",
187
+ },
188
+ },
189
+ },
190
+ {
191
+ variant: "outline",
192
+ tone: "accent",
193
+ css: {
194
+ border: "3px solid",
195
+ borderColor: "border.accent",
196
+ color: "text.accent",
197
+ "&:active, &:hover": {
198
+ background: "bg.hover.accent",
199
+ color: "text.muted.accent",
200
+ },
201
+ "&:focus": {
202
+ outlineColor: "border.accent",
203
+ outline: "3px solid",
204
+ outlineOffset: "2px",
205
+ },
206
+ },
207
+ },
208
+ {
209
+ variant: "outline",
210
+ tone: "danger",
211
+ css: {
212
+ border: "3px solid",
213
+ borderColor: "border.danger",
214
+ color: "text.danger",
215
+ "&:active, &:hover": {
216
+ background: "bg.hover.danger",
217
+ color: "text.muted.danger",
218
+ },
219
+ "&:focus": {
220
+ outlineColor: "border.danger",
221
+ outline: "3px solid",
222
+ outlineOffset: "2px",
223
+ },
224
+ },
225
+ },
226
+ {
227
+ variant: "outline",
228
+ tone: "warning",
229
+ css: {
230
+ border: "3px solid",
231
+ borderColor: "border.warning",
232
+ color: "text.warning",
233
+ "&:active, &:hover": {
234
+ background: "bg.hover.warning",
235
+ color: "text.muted.warning",
236
+ },
237
+ "&:focus": {
238
+ outlineColor: "border.warning",
239
+ outline: "3px solid",
240
+ outlineOffset: "2px",
241
+ },
242
+ },
243
+ },
244
+ ],
245
+ });
@@ -0,0 +1 @@
1
+ export { Button } from "./Button";
@@ -0,0 +1,72 @@
1
+ import type { Meta, StoryObj } from "@storybook/react";
2
+ import { vstack } from "../../../styled-system/patterns";
3
+ import { Heading } from "./Heading";
4
+
5
+ export default {
6
+ component: Heading,
7
+ parameters: {
8
+ layout: "centered",
9
+ },
10
+ args: {
11
+ children: "제목",
12
+ level: 1,
13
+ },
14
+ } satisfies Meta<typeof Heading>;
15
+
16
+ export const Basic: StoryObj<typeof Heading> = {};
17
+
18
+ export const Levels: StoryObj<typeof Heading> = {
19
+ render: (args) => {
20
+ return (
21
+ <div className={vstack({ gap: "6" })}>
22
+ <Heading {...args} level={1}>
23
+ 1 단계
24
+ </Heading>
25
+ <Heading {...args} level={2}>
26
+ 2 단계
27
+ </Heading>
28
+ <Heading {...args} level={3}>
29
+ 3 단계
30
+ </Heading>
31
+ <Heading {...args} level={4}>
32
+ 4 단계
33
+ </Heading>
34
+ <Heading {...args} level={5}>
35
+ 5 단계
36
+ </Heading>
37
+ <Heading {...args} level={6}>
38
+ 6 단계
39
+ </Heading>
40
+ </div>
41
+ );
42
+ },
43
+ argTypes: {
44
+ children: {
45
+ control: false,
46
+ },
47
+ level: {
48
+ control: false,
49
+ },
50
+ },
51
+ };
52
+
53
+ export const Contrasts: StoryObj<typeof Heading> = {
54
+ render: (args) => {
55
+ return (
56
+ <div className={vstack({ gap: "6" })}>
57
+ <Heading {...args} muted>
58
+ 낮은 명암비
59
+ </Heading>
60
+ <Heading {...args}>높은 명암비</Heading>
61
+ </div>
62
+ );
63
+ },
64
+ argTypes: {
65
+ children: {
66
+ control: false,
67
+ },
68
+ muted: {
69
+ control: false,
70
+ },
71
+ },
72
+ };
@@ -0,0 +1,55 @@
1
+ import { faker } from "@faker-js/faker";
2
+ import { composeStories } from "@storybook/react";
3
+ import { render, screen } from "@testing-library/react";
4
+ import { expect, test } from "vitest";
5
+ import { fontSizes, fontWeights } from "../../tokens/typography";
6
+ import * as stories from "./Heading.stories";
7
+
8
+ const { Basic, Contrasts } = composeStories(stories);
9
+
10
+ test("renders the heading with the correct text content", () => {
11
+ render(<Basic>제목</Basic>);
12
+
13
+ expect(screen.getByRole("heading")).toHaveTextContent("제목");
14
+ });
15
+
16
+ test.each([1, 2, 3, 4, 5, 6] as const)(
17
+ "renders the correct HTML heading element for level %i",
18
+ (level) => {
19
+ render(<Basic level={level} />);
20
+
21
+ expect(screen.getByRole("heading", { level })).toBeInTheDocument();
22
+ }
23
+ );
24
+
25
+ test("applies the correct font weight class based on the weight prop", () => {
26
+ const weight = faker.helpers.arrayElement(
27
+ Object.keys(fontWeights)
28
+ ) as keyof typeof fontWeights;
29
+
30
+ render(<Basic weight={weight} />);
31
+
32
+ expect(screen.getByRole("heading")).toHaveClass(`fw_${weight}`);
33
+ });
34
+
35
+ test("applies the correct font size class based on the size prop", () => {
36
+ const size = faker.helpers.arrayElement(
37
+ Object.keys(fontSizes)
38
+ ) as keyof typeof fontSizes;
39
+
40
+ render(<Basic size={size} />);
41
+
42
+ expect(screen.getByRole("heading")).toHaveClass(`fs_${size}`);
43
+ });
44
+
45
+ test("applies the correct color for low and high contrast", () => {
46
+ render(<Contrasts />);
47
+
48
+ expect(screen.getByRole("heading", { name: "낮은 명암비" })).toHaveClass(
49
+ "c_text.muted"
50
+ );
51
+
52
+ expect(screen.getByRole("heading", { name: "높은 명암비" })).toHaveClass(
53
+ "c_text"
54
+ );
55
+ });
@@ -0,0 +1,73 @@
1
+ import type { ReactNode, HTMLAttributes } from "react";
2
+ import { css, cva } from "../../../styled-system/css";
3
+ import type { FontSize, FontWeight } from "../../tokens/typography";
4
+
5
+ type Level = 1 | 2 | 3 | 4 | 5 | 6;
6
+
7
+ export interface HeadingProps extends HTMLAttributes<HTMLHeadingElement> {
8
+ /** 텍스트 */
9
+ children: ReactNode;
10
+ /** 단계 */
11
+ level: Level;
12
+ /** 크기 */
13
+ size?: FontSize;
14
+ /** 굵기 */
15
+ weight?: FontWeight;
16
+ /** 명암비 낮출지 */
17
+ muted?: boolean;
18
+ }
19
+
20
+ /**
21
+ * - `level` 속성을 통해서 `<h1>`, `<h2>`, `<h3>`, `<h4>`, `<h5>`, `<h6>` 요소 중 하나를 선택할 수 있습니다.
22
+ * - `level` 속성은 단계 별 기본 텍스트 스타일을 제공합니다.
23
+ * - `size` 속성과 `weight` 속성을 통해서 기본 스타일을 변경할 수 있습니다.
24
+ * - `muted` 속성을 주시면 글자색이 옅어집니다. 명암비가 낮아지므로 접근성 측면에서 주의해서 사용하세요.
25
+ */
26
+ export const Heading = ({
27
+ children,
28
+ level,
29
+ size,
30
+ weight,
31
+ muted = false,
32
+ ...rest
33
+ }: HeadingProps) => {
34
+ if (!level) {
35
+ throw new Error(
36
+ "The level prop is required and you can cause accessibility issues."
37
+ );
38
+ }
39
+
40
+ const Tag = `h${level}` as const;
41
+
42
+ return (
43
+ <Tag
44
+ className={css(
45
+ styles.raw({ level, muted }),
46
+ css.raw({
47
+ fontSize: size,
48
+ fontWeight: weight,
49
+ })
50
+ )}
51
+ {...rest}
52
+ >
53
+ {children}
54
+ </Tag>
55
+ );
56
+ };
57
+
58
+ const styles = cva({
59
+ variants: {
60
+ level: {
61
+ 1: { textStyle: "4xl" },
62
+ 2: { textStyle: "3xl" },
63
+ 3: { textStyle: "2xl" },
64
+ 4: { textStyle: "xl" },
65
+ 5: { textStyle: "lg" },
66
+ 6: { textStyle: "md" },
67
+ },
68
+ muted: {
69
+ true: { color: "text.muted" },
70
+ false: { color: "text" },
71
+ },
72
+ },
73
+ });
@@ -0,0 +1 @@
1
+ export { Heading } from "./Heading";
@@ -0,0 +1,106 @@
1
+ import type { Meta, StoryObj } from "@storybook/react";
2
+ import { vstack } from "../../../styled-system/patterns";
3
+ import { Heading } from "../Heading/Heading";
4
+ import { Text } from "../Text/Text";
5
+ import { Icon } from "./Icon";
6
+
7
+ export default {
8
+ component: Icon,
9
+ parameters: {
10
+ layout: "centered",
11
+ },
12
+ args: {
13
+ name: "user",
14
+ },
15
+ } satisfies Meta<typeof Icon>;
16
+
17
+ export const Basic: StoryObj<typeof Icon> = {
18
+ args: {
19
+ tone: "accent",
20
+ muted: true,
21
+ size: "xl",
22
+ },
23
+ };
24
+
25
+ export const Sizes: StoryObj<typeof Icon> = {
26
+ render: (args) => {
27
+ return (
28
+ <div className={vstack({ gap: "6" })}>
29
+ <Icon {...args} size="xs" />
30
+ <Icon {...args} size="sm" />
31
+ <Icon {...args} size="md" />
32
+ <Icon {...args} size="lg" />
33
+ <Icon {...args} size="xl" />
34
+ </div>
35
+ );
36
+ },
37
+ argTypes: {
38
+ size: {
39
+ control: false,
40
+ },
41
+ },
42
+ args: {
43
+ tone: "accent",
44
+ muted: true,
45
+ },
46
+ };
47
+
48
+ export const Tones: StoryObj<typeof Icon> = {
49
+ render: (args) => {
50
+ return (
51
+ <div className={vstack({ gap: "6" })}>
52
+ <Icon {...args} tone="neutral" />
53
+ <Icon {...args} tone="accent" />
54
+ <Icon {...args} tone="danger" />
55
+ <Icon {...args} tone="warning" />
56
+ </div>
57
+ );
58
+ },
59
+ argTypes: {
60
+ tone: {
61
+ control: false,
62
+ },
63
+ },
64
+ args: {
65
+ muted: true,
66
+ },
67
+ };
68
+
69
+ export const Contrasts: StoryObj<typeof Icon> = {
70
+ render: (args) => {
71
+ return (
72
+ <div className={vstack({ gap: "6" })}>
73
+ <Text {...args} muted>
74
+ 낮은 <Icon name="moon" /> 명암비
75
+ </Text>
76
+ <Text {...args}>
77
+ 높은 <Icon name="sun" /> 명암비
78
+ </Text>
79
+ </div>
80
+ );
81
+ },
82
+ argTypes: {
83
+ name: {
84
+ control: false,
85
+ },
86
+ muted: {
87
+ control: false,
88
+ },
89
+ },
90
+ };
91
+
92
+ export const WithHeading: StoryObj<typeof Icon> = {
93
+ render: (args) => {
94
+ return (
95
+ <Heading level={2}>
96
+ <Icon {...args} name="user" />
97
+ 프로필
98
+ </Heading>
99
+ );
100
+ },
101
+ argTypes: {
102
+ name: {
103
+ control: false,
104
+ },
105
+ },
106
+ };
@@ -0,0 +1,44 @@
1
+ import { composeStories } from "@storybook/react";
2
+ import { render } from "@testing-library/react";
3
+ import { expect, test } from "vitest";
4
+ import * as stories from "./Icon.stories";
5
+
6
+ const { Basic } = composeStories(stories);
7
+
8
+ test("renders an svg element", () => {
9
+ const { container } = render(<Basic />);
10
+
11
+ expect(container.querySelector("svg")).toBeInTheDocument();
12
+ });
13
+
14
+ test.each([
15
+ ["xs", "w_1em h_1em"],
16
+ ["sm", "w_1.25em h_1.25em"],
17
+ ["md", "w_1.5em h_1.5em"],
18
+ ["lg", "w_1.875em h_1.875em"],
19
+ ["xl", "w_2.25em h_2.25em"],
20
+ ] as const)('applies the correct class for size="%s"', (size, className) => {
21
+ const { container } = render(<Basic size={size} />);
22
+
23
+ expect(container.querySelector("svg")).toHaveClass(className);
24
+ });
25
+
26
+ test.each([
27
+ ["neutral", "c_text"],
28
+ ["accent", "c_text.accent"],
29
+ ["danger", "c_text.danger"],
30
+ ["warning", "c_text.warning"],
31
+ ] as const)('applies the correct class for tone="%s"', (tone, className) => {
32
+ const { container } = render(<Basic tone={tone} muted={false} />);
33
+
34
+ expect(container.querySelector("svg")).toHaveClass(className);
35
+ });
36
+
37
+ test.each([
38
+ [false, "c_text"],
39
+ [true, "c_text.muted"],
40
+ ] as const)("applies the correct class for muted={%s}", (muted, className) => {
41
+ const { container } = render(<Basic tone="neutral" muted={muted} />);
42
+
43
+ expect(container.querySelector("svg")).toHaveClass(className);
44
+ });