Skip to content

Commit 3ceec5f

Browse files
committed
apply heading component to app
1 parent af623fe commit 3ceec5f

File tree

8 files changed

+19
-11679
lines changed

8 files changed

+19
-11679
lines changed

bun.lockb

371 Bytes
Binary file not shown.

package-lock.json

Lines changed: 0 additions & 11661 deletions
This file was deleted.

src/App.tsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import logo from "/logo.svg";
22
import { css } from "../styled-system/css";
33
import { Button } from "./components/Button";
4+
import { Heading } from "./components/Heading";
45

56
function App() {
67
return (
@@ -23,9 +24,9 @@ function App() {
2324
</a>
2425
</header>
2526
<main>
26-
<h1>Welcome Dale UI!</h1>
27+
<Heading level={1}>Welcome Dale UI!</Heading>
2728
<section>
28-
<h2>유용한 링크</h2>
29+
<Heading level={2}>유용한 링크</Heading>
2930
<ul>
3031
<li>
3132
<a href="https://main--675790d317ba346348aa3490.chromatic.com/">
@@ -51,7 +52,7 @@ function App() {
5152
</ul>
5253
</section>
5354
<section>
54-
<h2>섹션 2</h2>
55+
<Heading level={2}>섹션 2</Heading>
5556
<Button>클릭</Button>
5657
</section>
5758
</main>

src/components/Heading/Heading.stories.tsx

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -56,20 +56,18 @@ export const Contrasts: StoryObj<typeof meta> = {
5656
render: (args) => {
5757
return (
5858
<div className={vstack({ gap: "6" })}>
59-
<Heading {...args} contrast="low">
59+
<Heading {...args} muted>
6060
낮은 명암비
6161
</Heading>
62-
<Heading {...args} contrast="high">
63-
높은 명암비
64-
</Heading>
62+
<Heading {...args}>높은 명암비</Heading>
6563
</div>
6664
);
6765
},
6866
argTypes: {
6967
children: {
7068
control: false,
7169
},
72-
contrast: {
70+
muted: {
7371
control: false,
7472
},
7573
},

src/components/Heading/Heading.test.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,10 @@ test("applies the correct color for low and high contrast", () => {
4646
render(<Contrasts />);
4747

4848
expect(screen.getByRole("heading", { name: "낮은 명암비" })).toHaveClass(
49-
"c_text"
49+
"c_text.muted"
5050
);
5151

5252
expect(screen.getByRole("heading", { name: "높은 명암비" })).toHaveClass(
53-
"c_text.contrast"
53+
"c_text"
5454
);
5555
});

src/components/Heading/Heading.tsx

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,20 +14,21 @@ export interface HeadingProps extends HTMLAttributes<HTMLHeadingElement> {
1414
/** 굵기 */
1515
weight?: FontWeight;
1616
/** 명암비 */
17-
contrast?: "low" | "high";
17+
muted?: boolean;
1818
}
1919

2020
/**
2121
* - `level` 속성을 통해서 `<h1>`, `<h2>`, `<h3>`, `<h4>`, `<h5>`, `<h6>` 요소 중 하나를 선택할 수 있습니다.
2222
* - `level` 속성은 단계 별 기본 텍스트 스타일을 제공합니다.
2323
* - `size` 속성과 `weight` 속성을 통해서 기본 스타일을 변경할 수 있습니다.
24+
* - `muted` 속성을 주시면 글자색이 옅어집니다. 명암비가 낮아지므로 접근성 측면에서 주의해서 사용하세요.
2425
*/
2526
export const Heading = ({
2627
children,
2728
level,
2829
size,
2930
weight,
30-
contrast = "low",
31+
muted = false,
3132
...rest
3233
}: HeadingProps) => {
3334
if (!level) {
@@ -41,7 +42,7 @@ export const Heading = ({
4142
return (
4243
<Tag
4344
className={css(
44-
styles.raw({ level, contrast }),
45+
styles.raw({ level, muted }),
4546
css.raw({
4647
fontSize: size,
4748
fontWeight: weight,
@@ -64,9 +65,9 @@ const styles = cva({
6465
5: { textStyle: "lg" },
6566
6: { textStyle: "md" },
6667
},
67-
contrast: {
68-
low: { color: "text" },
69-
high: { color: "text.contrast" },
68+
muted: {
69+
true: { color: "text.muted" },
70+
false: { color: "text" },
7071
},
7172
},
7273
});

src/components/Heading/index.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export { Heading } from "./Heading";

src/tokens/colors.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ export const semanticColors: SemanticTokens["colors"] = {
111111
},
112112
},
113113
text: {
114-
DEFAULT: {
114+
muted: {
115115
DEFAULT: {
116116
value: { base: "{colors.gray.11}", _dark: "{colors.grayDark.11}" },
117117
},
@@ -125,7 +125,7 @@ export const semanticColors: SemanticTokens["colors"] = {
125125
value: { base: "{colors.yellow.11}", _dark: "{colors.yellowDark.11}" },
126126
},
127127
},
128-
contrast: {
128+
DEFAULT: {
129129
DEFAULT: {
130130
value: { base: "{colors.gray.12}", _dark: "{colors.grayDark.12}" },
131131
},

0 commit comments

Comments
 (0)