@x33025/sveltely 0.1.16 → 0.1.17
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.
|
@@ -16,10 +16,31 @@
|
|
|
16
16
|
const extractedStyleProps = $derived.by(() => extractStyleProps(restProps));
|
|
17
17
|
const styleProps = $derived(extractedStyleProps.styleProps);
|
|
18
18
|
const props = $derived(extractedStyleProps.restProps);
|
|
19
|
-
|
|
19
|
+
|
|
20
|
+
const rootStyle = $derived.by(() => {
|
|
21
|
+
const { background, borderColor, color, ...surfaceProps } = styleProps;
|
|
22
|
+
const declarations = [surfaceStyle(surfaceProps, 'link')];
|
|
23
|
+
if (background !== undefined) {
|
|
24
|
+
declarations.push(`--link-background: ${background};`);
|
|
25
|
+
}
|
|
26
|
+
if (borderColor !== undefined) {
|
|
27
|
+
declarations.push(`--link-border-color: ${borderColor};`);
|
|
28
|
+
}
|
|
29
|
+
if (color !== undefined) {
|
|
30
|
+
declarations.push(`--link-color: ${color};`);
|
|
31
|
+
}
|
|
32
|
+
return declarations.filter(Boolean).join(' ');
|
|
33
|
+
});
|
|
34
|
+
const iconOnly = $derived(!children && !label);
|
|
20
35
|
</script>
|
|
21
36
|
|
|
22
|
-
<a
|
|
37
|
+
<a
|
|
38
|
+
class="link inline-flex items-center justify-center {iconOnly
|
|
39
|
+
? 'link-icon-only'
|
|
40
|
+
: ''} {className}"
|
|
41
|
+
style={rootStyle}
|
|
42
|
+
{...props}
|
|
43
|
+
>
|
|
23
44
|
{#if children}
|
|
24
45
|
{@render children()}
|
|
25
46
|
{:else if label}
|
|
@@ -30,32 +51,44 @@
|
|
|
30
51
|
<style>
|
|
31
52
|
.link {
|
|
32
53
|
--link-font-size: var(--sveltely-font-size);
|
|
54
|
+
--link-scale: calc(var(--link-font-size) / 1rem);
|
|
33
55
|
--link-icon-size: calc(var(--link-font-size) * 1.143);
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
color: var(--link-color, var(--sveltely-active-color));
|
|
56
|
+
border: 1px solid var(--link-border-color, var(--sveltely-border-color));
|
|
57
|
+
border-radius: var(--link-border-radius, var(--sveltely-border-radius));
|
|
58
|
+
background: var(--link-background, var(--sveltely-background-color));
|
|
59
|
+
color: var(--link-color, var(--sveltely-primary-color));
|
|
60
|
+
gap: var(--link-gap, var(--sveltely-gap));
|
|
40
61
|
font-size: var(--link-font-size);
|
|
41
62
|
line-height: 1.25;
|
|
63
|
+
padding: var(--link-padding-y, calc(var(--sveltely-padding-y) * 0.67 * var(--link-scale)))
|
|
64
|
+
var(--link-padding-x, calc(var(--sveltely-padding-x) * var(--link-scale)));
|
|
42
65
|
text-decoration: none;
|
|
43
|
-
text-underline-offset: 0.18em;
|
|
44
66
|
transition:
|
|
45
67
|
color 150ms,
|
|
46
|
-
|
|
47
|
-
|
|
68
|
+
border-color 150ms,
|
|
69
|
+
background-color 150ms;
|
|
48
70
|
}
|
|
49
71
|
|
|
50
72
|
.link:hover {
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
73
|
+
background: var(
|
|
74
|
+
--link-hover-background,
|
|
75
|
+
color-mix(
|
|
76
|
+
in oklab,
|
|
77
|
+
var(--link-background, var(--sveltely-background-color)) 88%,
|
|
78
|
+
var(--link-color, var(--sveltely-primary-color))
|
|
79
|
+
)
|
|
80
|
+
);
|
|
54
81
|
}
|
|
55
82
|
|
|
56
|
-
.link
|
|
57
|
-
|
|
58
|
-
|
|
83
|
+
.link-icon-only {
|
|
84
|
+
padding: var(--link-padding-y, calc(var(--sveltely-padding-y) * 0.67 * var(--link-scale)))
|
|
85
|
+
var(--link-padding-x, calc(var(--sveltely-padding-x) * 0.67 * var(--link-scale)));
|
|
86
|
+
min-width: calc(
|
|
87
|
+
(var(--link-padding-x, calc(var(--sveltely-padding-x) * 0.67 * var(--link-scale))) * 2) + 1rem
|
|
88
|
+
);
|
|
89
|
+
min-height: calc(
|
|
90
|
+
(var(--link-padding-y, calc(var(--sveltely-padding-y) * 0.67 * var(--link-scale))) * 2) + 1rem
|
|
91
|
+
);
|
|
59
92
|
}
|
|
60
93
|
|
|
61
94
|
.link :global(svg) {
|