Skip to content

Commit 03180d6

Browse files
committed
feat(#2956): update link to v2
1 parent 0c90dcc commit 03180d6

File tree

1 file changed

+74
-10
lines changed

1 file changed

+74
-10
lines changed

libs/web-components/src/components/link/Link.svelte

Lines changed: 74 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@
1515
1616
export let leadingicon: GoAIconType | null = null;
1717
export let trailingicon: GoAIconType | null = null;
18-
export let color: "interactive" | "light" = "interactive";
18+
export let color: "interactive" | "dark" | "light" = "interactive";
19+
export let size: "xsmall" | "small" | "medium" | "large" = "medium";
1920
2021
export let action: string = "";
2122
export let actionArg: string = "";
@@ -40,49 +41,112 @@
4041
e.preventDefault();
4142
dispatch(e.target as Element, action, actionArg || actionArgs, { bubbles: true });
4243
}
44+
45+
function getIconSize(linkSize: string): string {
46+
const sizeMap: Record<string, string> = {
47+
xsmall: "2xsmall", // 12px
48+
small: "xsmall", // 16px
49+
medium: "small", // 18px
50+
large: "medium" // 20px
51+
};
52+
return sizeMap[linkSize] || "small";
53+
}
4354
</script>
4455

4556
<div
4657
class="link"
4758
class:interactive={color === "interactive"}
59+
class:dark={color === "dark"}
4860
class:light={color === "light"}
61+
class:xsmall={size === "xsmall"}
62+
class:small={size === "small"}
63+
class:medium={size === "medium"}
64+
class:large={size === "large"}
4965
bind:this={_rootEl}
5066
style={styles(calculateMargin(mt, mr, mb, ml))}
5167
data-testid={testid}
5268
>
53-
{#if leadingicon}<goa-icon data-testid="leading-icon" type={leadingicon} />{/if}
69+
{#if leadingicon}<goa-icon data-testid="leading-icon" type={leadingicon} size={getIconSize(size)} />{/if}
5470
<slot />
55-
{#if trailingicon}<goa-icon data-testid="trailing-icon" type={trailingicon} />{/if}
71+
{#if trailingicon}<goa-icon data-testid="trailing-icon" type={trailingicon} size={getIconSize(size)} />{/if}
5672
</div>
5773

5874
<style>
5975
:global(::slotted(a)) {
60-
color: var(--goa-color-interactive-default);
76+
color: var(--goa-link-color-interactive-default, var(--goa-color-interactive-default));
6177
}
6278
79+
/* Base link styles */
6380
.link {
6481
display: inline-flex;
6582
align-items: center;
6683
padding: 0;
6784
border: none;
6885
background: none;
6986
cursor: pointer;
70-
font: var(--goa-typography-body-m);
7187
text-decoration: underline;
72-
gap: 8px;
88+
/* V1: Default gap fallback (4px) */
89+
gap: var(--goa-link-gap, 0.25rem);
90+
/* V2: Size-specific gaps override below */
91+
}
92+
93+
/* Size variants - Typography and Gap */
94+
.link.xsmall {
95+
font: var(--goa-link-typography-xsmall);
96+
gap: var(--goa-link-gap-xsmall, 0.125rem);
97+
}
98+
99+
.link.small {
100+
font: var(--goa-link-typography-small);
101+
gap: var(--goa-link-gap-small, 0.1875rem);
73102
}
74103
104+
.link.medium {
105+
font: var(--goa-link-typography-medium);
106+
gap: var(--goa-link-gap-medium, 0.25rem);
107+
}
108+
109+
.link.large {
110+
font: var(--goa-link-typography-large);
111+
gap: var(--goa-link-gap-large, 0.3125rem);
112+
}
113+
114+
/* Color variant: Interactive (Blue) */
75115
.link.interactive {
76-
color: var(--goa-color-interactive-default);
116+
color: var(--goa-link-color-interactive-default, var(--goa-color-interactive-default));
77117
}
118+
78119
.link.interactive:hover {
79-
color: var(--goa-color-interactive-hover);
120+
color: var(--goa-link-color-interactive-hover, var(--goa-color-interactive-hover));
80121
}
81122
123+
.link.interactive :global(::slotted(a:visited)) {
124+
color: var(--goa-link-color-interactive-visited, var(--goa-color-interactive-visited));
125+
}
126+
127+
/* Color variant: Dark (Black) */
128+
.link.dark {
129+
color: var(--goa-link-color-dark-default, var(--goa-color-greyscale-black));
130+
}
131+
132+
.link.dark:hover {
133+
color: var(--goa-link-color-dark-hover, var(--goa-color-greyscale-700));
134+
}
135+
136+
.link.dark :global(::slotted(a:visited)) {
137+
color: var(--goa-link-color-dark-visited, var(--goa-color-interactive-visited));
138+
}
139+
140+
/* Color variant: Light (White) */
82141
.link.light {
83-
color: var(--goa-color-text-light);
142+
color: var(--goa-link-color-light-default, var(--goa-color-text-light));
84143
}
144+
85145
.link.light:hover {
86-
color: var(--goa-color-text-light);
146+
color: var(--goa-link-color-light-hover, var(--goa-color-greyscale-100));
147+
}
148+
149+
.link.light :global(::slotted(a:visited)) {
150+
color: var(--goa-link-color-light-visited, var(--goa-color-greyscale-300));
87151
}
88152
</style>

0 commit comments

Comments
 (0)