Skip to content

Commit 91747cc

Browse files
authored
Merge pull request #288 from DaleStudy/203-apply-link-component-to-website
Link 컴포넌트를 웹사이트에 적용
2 parents 6fc2022 + 7fe3478 commit 91747cc

File tree

3 files changed

+42
-14
lines changed

3 files changed

+42
-14
lines changed

src/App.tsx

Lines changed: 33 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import logo from "/logo.svg";
22
import { css } from "../styled-system/css";
33
import { Button } from "./components/Button/Button";
44
import { Heading } from "./components/Heading/Heading";
5+
import { Link } from "./components/Link/Link";
56
import { Text } from "./components/Text/Text";
67

78
function App() {
@@ -13,42 +14,63 @@ function App() {
1314
})}
1415
>
1516
<header>
16-
<a
17-
href="/"
17+
<Link
18+
href={"/"}
1819
className={css({
1920
display: "flex",
2021
gap: "4",
2122
})}
2223
>
2324
<img src={logo} className="logo" alt="logo" />
2425
달레 UI
25-
</a>
26+
</Link>
2627
</header>
2728
<main>
2829
<Heading level={1}>Welcome Dale UI!</Heading>
2930
<section>
3031
<Heading level={2}>유용한 링크</Heading>
3132
<ul>
3233
<li>
33-
<a href="https://main--675790d317ba346348aa3490.chromatic.com/">
34+
<Link
35+
href={"https://main--675790d317ba346348aa3490.chromatic.com/"}
36+
underline={false}
37+
>
3438
스토리북
35-
</a>
39+
</Link>
3640
</li>
3741
<li>
38-
<a href="https://github.com/DaleStudy/daleui">깃허브</a>
42+
<Link
43+
href={"https://github.com/DaleStudy/daleui"}
44+
underline={false}
45+
>
46+
깃허브
47+
</Link>
3948
</li>
4049
<li>
41-
<a href="https://github.com/DaleStudy/daleui/wiki">위키</a>
50+
<Link
51+
href={"https://github.com/DaleStudy/daleui/wiki"}
52+
underline={false}
53+
>
54+
위키
55+
</Link>
4256
</li>
4357
<li>
44-
<a href="https://github.com/DaleStudy/daleui/discussions">
58+
<Link
59+
href={"https://github.com/DaleStudy/daleui/discussions"}
60+
underline={false}
61+
>
4562
게시판
46-
</a>
63+
</Link>
4764
</li>
4865
<li>
49-
<a href="https://discord.com/channels/775115965964222492/1280152682044063837">
66+
<Link
67+
href={
68+
"https://discord.com/channels/775115965964222492/1280152682044063837"
69+
}
70+
underline={false}
71+
>
5072
채팅방
51-
</a>
73+
</Link>
5274
</li>
5375
</ul>
5476
</section>

src/components/Link/Link.tsx

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
1-
import { type AnchorHTMLAttributes, type PropsWithChildren } from "react";
1+
import { type AnchorHTMLAttributes } from "react";
22
import type { Tone } from "../../tokens/colors";
33
import { css, cva } from "../../../styled-system/css";
44
import type { FontSize, FontWeight } from "../../tokens/typography";
55

66
interface LinkProps extends AnchorHTMLAttributes<HTMLAnchorElement> {
7+
/** 링크 URL (필수) */
8+
href: string;
9+
/** 링크 내용 (필수) */
10+
children: React.ReactNode;
711
/** 색조 */
812
tone?: Tone;
913
/** 크기 */
@@ -25,6 +29,7 @@ interface LinkProps extends AnchorHTMLAttributes<HTMLAnchorElement> {
2529
*/
2630
export function Link({
2731
children,
32+
href,
2833
tone = "neutral",
2934
size,
3035
weight,
@@ -33,7 +38,7 @@ export function Link({
3338
target,
3439
rel,
3540
...props
36-
}: PropsWithChildren<LinkProps>) {
41+
}: LinkProps) {
3742
return (
3843
<a
3944
className={css(
@@ -43,6 +48,7 @@ export function Link({
4348
fontWeight: weight,
4449
}),
4550
)}
51+
href={href}
4652
target={target}
4753
rel={target === "_blank" ? "noopener noreferrer" : rel}
4854
{...props}

src/examples/Homepage/Homepage.stories.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ export const Default: StoryObj = {
4949
aria-label="주요 메뉴"
5050
>
5151
{MENU_ITEMS.map((item) => (
52-
<Link key={item} underline={false}>
52+
<Link key={item} underline={false} href={"#"}>
5353
{item}
5454
</Link>
5555
))}

0 commit comments

Comments
 (0)