@dorsk/tsumikit 0.9.4 → 0.9.6
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.
- package/dist/components/atoms/Card.svelte +13 -0
- package/dist/components/atoms/Card.svelte.d.ts +1 -0
- package/dist/components/molecules/Metric.svelte +5 -0
- package/dist/components/molecules/Metric.svelte.d.ts +1 -0
- package/dist/components/molecules/SegmentedControl.svelte +32 -0
- package/dist/components/molecules/SegmentedControl.svelte.d.ts +1 -0
- package/package.json +1 -1
|
@@ -19,6 +19,7 @@
|
|
|
19
19
|
tap = false,
|
|
20
20
|
as = 'div',
|
|
21
21
|
padding = 'md',
|
|
22
|
+
surface = 'base',
|
|
22
23
|
stacked = false,
|
|
23
24
|
stackTone = 'neutral',
|
|
24
25
|
stackY = 8,
|
|
@@ -31,6 +32,7 @@
|
|
|
31
32
|
tap?: boolean;
|
|
32
33
|
as?: 'div' | 'button' | 'a' | 'li' | 'section' | 'form';
|
|
33
34
|
padding?: 'none' | 'sm' | 'md' | 'lg';
|
|
35
|
+
surface?: 'base' | 'raised' | 'sunken';
|
|
34
36
|
stacked?: boolean;
|
|
35
37
|
stackTone?: Tone;
|
|
36
38
|
stackY?: number;
|
|
@@ -53,6 +55,8 @@
|
|
|
53
55
|
class:pad-none={padding === 'none'}
|
|
54
56
|
class:pad-sm={padding === 'sm'}
|
|
55
57
|
class:pad-lg={padding === 'lg'}
|
|
58
|
+
class:surface-raised={surface === 'raised'}
|
|
59
|
+
class:surface-sunken={surface === 'sunken'}
|
|
56
60
|
class:card-tap={tap}
|
|
57
61
|
class:card-stacked={stacked}
|
|
58
62
|
class:stack-ok={stacked && stackTone === 'ok'}
|
|
@@ -72,6 +76,15 @@
|
|
|
72
76
|
border-radius: var(--r-lg);
|
|
73
77
|
padding: var(--sp-4);
|
|
74
78
|
}
|
|
79
|
+
/* Theme-aware surface shade, selected by prop so it adapts across themes
|
|
80
|
+
instead of being overridden with app-level :global hacks. `base` is the
|
|
81
|
+
default (.card already paints --bg-elevated). */
|
|
82
|
+
.surface-raised {
|
|
83
|
+
background: var(--surface);
|
|
84
|
+
}
|
|
85
|
+
.surface-sunken {
|
|
86
|
+
background: var(--bg-elevated-2);
|
|
87
|
+
}
|
|
75
88
|
.pad-none {
|
|
76
89
|
padding: 0;
|
|
77
90
|
}
|
|
@@ -22,6 +22,9 @@
|
|
|
22
22
|
tone = 'neutral',
|
|
23
23
|
// Tint the value itself with the tone (not just the chip).
|
|
24
24
|
tintValue = false,
|
|
25
|
+
// Theme-aware surface shade, forwarded to the composed Card so tiles can
|
|
26
|
+
// opt into the same shade as sibling panels (no app-level :global override).
|
|
27
|
+
surface = 'base',
|
|
25
28
|
class: klass = '',
|
|
26
29
|
// Raw SVG markup for a custom icon — passed through to `Icon` so any glyph
|
|
27
30
|
// outside the registry can fill the chip.
|
|
@@ -35,6 +38,7 @@
|
|
|
35
38
|
icon?: IconName;
|
|
36
39
|
tone?: Tone;
|
|
37
40
|
tintValue?: boolean;
|
|
41
|
+
surface?: 'base' | 'raised' | 'sunken';
|
|
38
42
|
class?: string;
|
|
39
43
|
iconChildren?: Snippet;
|
|
40
44
|
[key: string]: unknown;
|
|
@@ -44,6 +48,7 @@
|
|
|
44
48
|
<Card
|
|
45
49
|
data-tsu="Metric"
|
|
46
50
|
class="metric metric-{tone} {tintValue ? 'metric-tint' : ''} {klass}"
|
|
51
|
+
{surface}
|
|
47
52
|
{...rest}
|
|
48
53
|
>
|
|
49
54
|
<div class="metric-head">
|
|
@@ -31,6 +31,9 @@
|
|
|
31
31
|
variant = 'pill',
|
|
32
32
|
size = 'md',
|
|
33
33
|
label = 'Options',
|
|
34
|
+
// `mobile` hides segment labels below the mobile breakpoint, collapsing
|
|
35
|
+
// labelled segments to centered icon-only squares (aria-label preserved).
|
|
36
|
+
collapseLabels = 'never',
|
|
34
37
|
class: klass = '',
|
|
35
38
|
// Custom rendering per option (overrides the built-in label/count/icon).
|
|
36
39
|
option: optionSnippet
|
|
@@ -40,6 +43,7 @@
|
|
|
40
43
|
variant?: 'pill' | 'icon';
|
|
41
44
|
size?: 'sm' | 'md';
|
|
42
45
|
label?: string;
|
|
46
|
+
collapseLabels?: 'never' | 'mobile';
|
|
43
47
|
class?: string;
|
|
44
48
|
option?: Snippet<[SegmentOption, boolean]>;
|
|
45
49
|
} = $props();
|
|
@@ -94,6 +98,7 @@
|
|
|
94
98
|
aria-label={label}
|
|
95
99
|
tabindex="-1"
|
|
96
100
|
class="seg seg-{variant} seg-{size} {klass}"
|
|
101
|
+
class:seg-collapse-mobile={collapseLabels === 'mobile'}
|
|
97
102
|
data-tsu="SegmentedControl"
|
|
98
103
|
{onkeydown}
|
|
99
104
|
>
|
|
@@ -107,6 +112,7 @@
|
|
|
107
112
|
aria-label={variant === 'icon' && !o.label ? o.value : o.label}
|
|
108
113
|
tabindex={selected ? 0 : -1}
|
|
109
114
|
class="seg-item"
|
|
115
|
+
class:has-label={!!o.label}
|
|
110
116
|
class:selected
|
|
111
117
|
disabled={o.disabled}
|
|
112
118
|
onclick={() => select(o.value)}
|
|
@@ -169,6 +175,32 @@
|
|
|
169
175
|
padding: 0.25rem;
|
|
170
176
|
font-size: var(--fs-sm);
|
|
171
177
|
}
|
|
178
|
+
/* A labelled icon segment renders <icon><label>, so it must keep the normal
|
|
179
|
+
icon/label gap and the roomier pill padding — only true icon-only segments
|
|
180
|
+
collapse to the square gap:0 layout above. */
|
|
181
|
+
.seg-icon .seg-item.has-label {
|
|
182
|
+
gap: var(--sp-2);
|
|
183
|
+
padding: 0.3rem var(--sp-3);
|
|
184
|
+
}
|
|
185
|
+
.seg-icon.seg-sm .seg-item.has-label {
|
|
186
|
+
padding: 0.2rem var(--sp-2);
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
/* collapseLabels='mobile': below the breakpoint, drop the label text and
|
|
190
|
+
tighten labelled segments back to a square icon button. The aria-label on
|
|
191
|
+
the button preserves the accessible name. */
|
|
192
|
+
@media (max-width: 47.999rem) {
|
|
193
|
+
.seg-collapse-mobile .seg-item.has-label .seg-label {
|
|
194
|
+
display: none;
|
|
195
|
+
}
|
|
196
|
+
.seg-collapse-mobile .seg-item.has-label {
|
|
197
|
+
gap: 0;
|
|
198
|
+
padding: 0.35rem;
|
|
199
|
+
}
|
|
200
|
+
.seg-collapse-mobile.seg-sm .seg-item.has-label {
|
|
201
|
+
padding: 0.25rem;
|
|
202
|
+
}
|
|
203
|
+
}
|
|
172
204
|
|
|
173
205
|
.seg-item:hover:not(:disabled):not(.selected) {
|
|
174
206
|
color: var(--text);
|
package/package.json
CHANGED