@dorsk/tsumikit 0.29.0 → 0.30.0
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/Button.svelte +40 -1
- package/dist/components/atoms/Button.svelte.d.ts +3 -1
- package/dist/components/molecules/FileButton.svelte +10 -0
- package/dist/components/molecules/FileButton.svelte.d.ts +3 -0
- package/dist/components/molecules/IconButton.svelte +9 -0
- package/dist/components/molecules/IconButton.svelte.d.ts +2 -0
- package/dist/components/molecules/Toggle.svelte +22 -0
- package/dist/components/molecules/Toggle.svelte.d.ts +3 -0
- package/package.json +1 -1
|
@@ -3,17 +3,24 @@
|
|
|
3
3
|
import type { HTMLButtonAttributes } from 'svelte/elements';
|
|
4
4
|
|
|
5
5
|
type ButtonProps = HTMLButtonAttributes & {
|
|
6
|
-
|
|
6
|
+
// `link`: no box at all — an inline text action coloured like a link
|
|
7
|
+
// (or like `tone` when set), underlined on hover/focus.
|
|
8
|
+
variant?: 'default' | 'primary' | 'ghost' | 'danger' | 'link';
|
|
7
9
|
// Semantic state tint layered on top of the variant: tints text/border and
|
|
8
10
|
// adds a subtle fill on hover. For stateful controls — an "on"/active toggle
|
|
9
11
|
// (`accent`), positive actions (`success`), or cost/severity states.
|
|
10
12
|
tone?: 'none' | 'accent' | 'success' | 'info' | 'warn' | 'danger';
|
|
11
13
|
size?: 'sm' | 'md' | 'lg';
|
|
12
14
|
control?: boolean;
|
|
15
|
+
// Fully rounded ends (`--r-pill`) on any size/variant.
|
|
16
|
+
pill?: boolean;
|
|
13
17
|
block?: boolean;
|
|
14
18
|
// Fill the available width of a flex/Cluster row (flex: 1). `block` stretches
|
|
15
19
|
// to 100% (grid/stack); `grow` shares a flex row with siblings.
|
|
16
20
|
grow?: boolean;
|
|
21
|
+
// `shrink={false}` pins the button to its intrinsic width in a flex row
|
|
22
|
+
// (flex: none, top-aligned) so a growing sibling can't squash it.
|
|
23
|
+
shrink?: boolean;
|
|
17
24
|
// Render as a link (`<a href>`) while keeping button chrome — for navigations
|
|
18
25
|
// and open-in-new-tab actions that shouldn't be a bare <a>. Setting `href`
|
|
19
26
|
// implies `as="a"`.
|
|
@@ -56,8 +63,10 @@
|
|
|
56
63
|
tone = 'none',
|
|
57
64
|
size = 'md',
|
|
58
65
|
control = false,
|
|
66
|
+
pill = false,
|
|
59
67
|
block = false,
|
|
60
68
|
grow = false,
|
|
69
|
+
shrink = true,
|
|
61
70
|
as = 'button',
|
|
62
71
|
href,
|
|
63
72
|
icon = false,
|
|
@@ -113,6 +122,9 @@
|
|
|
113
122
|
class:btn-primary={variant === 'primary'}
|
|
114
123
|
class:btn-ghost={variant === 'ghost'}
|
|
115
124
|
class:btn-danger={variant === 'danger' || (tone === 'danger' && variant === 'default')}
|
|
125
|
+
class:btn-link={variant === 'link'}
|
|
126
|
+
class:btn-pill={pill}
|
|
127
|
+
class:no-shrink={!shrink}
|
|
116
128
|
class:btn-sm={size === 'sm'}
|
|
117
129
|
class:btn-lg={size === 'lg'}
|
|
118
130
|
class:btn-control={control}
|
|
@@ -354,6 +366,33 @@
|
|
|
354
366
|
filter: brightness(1.08);
|
|
355
367
|
}
|
|
356
368
|
|
|
369
|
+
.no-shrink {
|
|
370
|
+
flex: none;
|
|
371
|
+
align-self: flex-start;
|
|
372
|
+
}
|
|
373
|
+
.btn-pill {
|
|
374
|
+
border-radius: var(--r-pill);
|
|
375
|
+
}
|
|
376
|
+
/* Link variant: no box, inherits the surrounding text size. Placed after the
|
|
377
|
+
size rules so their min-height doesn't reapply; a tone wins over --link. */
|
|
378
|
+
.btn-link {
|
|
379
|
+
min-height: auto;
|
|
380
|
+
height: auto;
|
|
381
|
+
padding: 0 var(--sp-1);
|
|
382
|
+
border: none;
|
|
383
|
+
background: none;
|
|
384
|
+
box-shadow: none;
|
|
385
|
+
border-radius: 0;
|
|
386
|
+
font-size: inherit;
|
|
387
|
+
line-height: 1;
|
|
388
|
+
color: var(--btn-tone, var(--link));
|
|
389
|
+
}
|
|
390
|
+
.btn-link:hover:not(:disabled),
|
|
391
|
+
.btn-link:focus-visible {
|
|
392
|
+
background: none;
|
|
393
|
+
border: none;
|
|
394
|
+
text-decoration: underline;
|
|
395
|
+
}
|
|
357
396
|
/* Icon-only buttons (IconButton). Square box = consistent --box-md tap target. */
|
|
358
397
|
.btn-icon {
|
|
359
398
|
min-height: var(--box-md);
|
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
import type { Snippet } from 'svelte';
|
|
2
2
|
import type { HTMLButtonAttributes } from 'svelte/elements';
|
|
3
3
|
type ButtonProps = HTMLButtonAttributes & {
|
|
4
|
-
variant?: 'default' | 'primary' | 'ghost' | 'danger';
|
|
4
|
+
variant?: 'default' | 'primary' | 'ghost' | 'danger' | 'link';
|
|
5
5
|
tone?: 'none' | 'accent' | 'success' | 'info' | 'warn' | 'danger';
|
|
6
6
|
size?: 'sm' | 'md' | 'lg';
|
|
7
7
|
control?: boolean;
|
|
8
|
+
pill?: boolean;
|
|
8
9
|
block?: boolean;
|
|
9
10
|
grow?: boolean;
|
|
11
|
+
shrink?: boolean;
|
|
10
12
|
as?: 'button' | 'a';
|
|
11
13
|
href?: string;
|
|
12
14
|
target?: string;
|
|
@@ -16,6 +16,7 @@
|
|
|
16
16
|
disabled = false,
|
|
17
17
|
variant = 'default',
|
|
18
18
|
size = 'md',
|
|
19
|
+
control = false,
|
|
19
20
|
box,
|
|
20
21
|
hitArea = 'auto',
|
|
21
22
|
class: klass = ''
|
|
@@ -38,6 +39,9 @@
|
|
|
38
39
|
/** Match the Button atom's sizes so a FileButton lines up with buttons in
|
|
39
40
|
* the same row. */
|
|
40
41
|
size?: 'sm' | 'md' | 'lg';
|
|
42
|
+
/** Uniform `--control-height`, like Button's `control`, so it lines up in a
|
|
43
|
+
* composer/toolbar row. */
|
|
44
|
+
control?: boolean;
|
|
41
45
|
/** Shared square box scale (`--box-xs/sm/md/lg`); implies `iconOnly`. */
|
|
42
46
|
box?: 'xs' | 'sm' | 'md' | 'lg';
|
|
43
47
|
/** Icon-only buttons grow a 44px hit slab on coarse pointers; `compact` opts out. */
|
|
@@ -62,6 +66,7 @@
|
|
|
62
66
|
class:ghost={variant === 'ghost'}
|
|
63
67
|
class:sm={size === 'sm'}
|
|
64
68
|
class:lg={size === 'lg'}
|
|
69
|
+
class:control
|
|
65
70
|
class:icon-only={onlyIcon}
|
|
66
71
|
class:box={box !== undefined}
|
|
67
72
|
class:hit-compact={hitArea === 'compact'}
|
|
@@ -125,6 +130,11 @@
|
|
|
125
130
|
padding: var(--sp-3) var(--sp-5);
|
|
126
131
|
font-size: var(--fs-base);
|
|
127
132
|
}
|
|
133
|
+
.file-btn.control {
|
|
134
|
+
height: var(--control-height);
|
|
135
|
+
min-height: var(--control-height);
|
|
136
|
+
padding: 0 var(--sp-3);
|
|
137
|
+
}
|
|
128
138
|
/* icon-only: square it up and drop the label gap. */
|
|
129
139
|
.file-btn.icon-only {
|
|
130
140
|
gap: 0;
|
|
@@ -18,6 +18,9 @@ type $$ComponentProps = {
|
|
|
18
18
|
/** Match the Button atom's sizes so a FileButton lines up with buttons in
|
|
19
19
|
* the same row. */
|
|
20
20
|
size?: 'sm' | 'md' | 'lg';
|
|
21
|
+
/** Uniform `--control-height`, like Button's `control`, so it lines up in a
|
|
22
|
+
* composer/toolbar row. */
|
|
23
|
+
control?: boolean;
|
|
21
24
|
/** Shared square box scale (`--box-xs/sm/md/lg`); implies `iconOnly`. */
|
|
22
25
|
box?: 'xs' | 'sm' | 'md' | 'lg';
|
|
23
26
|
/** Icon-only buttons grow a 44px hit slab on coarse pointers; `compact` opts out. */
|
|
@@ -16,6 +16,11 @@
|
|
|
16
16
|
children?: Snippet;
|
|
17
17
|
label: string;
|
|
18
18
|
variant?: 'default' | 'primary' | 'ghost' | 'danger';
|
|
19
|
+
// Fully rounded (`--r-pill`) box. Forwarded to Button.
|
|
20
|
+
pill?: boolean;
|
|
21
|
+
// `shrink={false}` pins the box to its intrinsic size in a flex row.
|
|
22
|
+
// Forwarded to Button.
|
|
23
|
+
shrink?: boolean;
|
|
19
24
|
// Semantic state tint (forwarded to Button). Pairs well with `chip`.
|
|
20
25
|
tone?: 'none' | 'accent' | 'info' | 'warn' | 'danger';
|
|
21
26
|
// Outlined `--box-lg` square icon-chip (header/toolbar actions).
|
|
@@ -55,6 +60,8 @@
|
|
|
55
60
|
variant = 'ghost',
|
|
56
61
|
tone = 'none',
|
|
57
62
|
chip = false,
|
|
63
|
+
pill = false,
|
|
64
|
+
shrink = true,
|
|
58
65
|
box,
|
|
59
66
|
size = 18,
|
|
60
67
|
glyphSize,
|
|
@@ -82,6 +89,8 @@
|
|
|
82
89
|
{variant}
|
|
83
90
|
{tone}
|
|
84
91
|
{chip}
|
|
92
|
+
{pill}
|
|
93
|
+
{shrink}
|
|
85
94
|
{box}
|
|
86
95
|
{hitArea}
|
|
87
96
|
{disabled}
|
|
@@ -12,6 +12,8 @@ type IconButtonProps = HTMLButtonAttributes & {
|
|
|
12
12
|
children?: Snippet;
|
|
13
13
|
label: string;
|
|
14
14
|
variant?: 'default' | 'primary' | 'ghost' | 'danger';
|
|
15
|
+
pill?: boolean;
|
|
16
|
+
shrink?: boolean;
|
|
15
17
|
tone?: 'none' | 'accent' | 'info' | 'warn' | 'danger';
|
|
16
18
|
chip?: boolean;
|
|
17
19
|
box?: 'xs' | 'sm' | 'md' | 'lg';
|
|
@@ -14,6 +14,9 @@
|
|
|
14
14
|
pressed = false,
|
|
15
15
|
pill = false,
|
|
16
16
|
struck = false,
|
|
17
|
+
size = 'sm',
|
|
18
|
+
grow = false,
|
|
19
|
+
shrink = true,
|
|
17
20
|
type = 'button',
|
|
18
21
|
disabled = false,
|
|
19
22
|
class: klass = '',
|
|
@@ -23,6 +26,11 @@
|
|
|
23
26
|
pressed?: boolean;
|
|
24
27
|
pill?: boolean;
|
|
25
28
|
struck?: boolean;
|
|
29
|
+
size?: 'sm' | 'md';
|
|
30
|
+
// Share a flex row with siblings (flex: 1 1 0).
|
|
31
|
+
grow?: boolean;
|
|
32
|
+
// `shrink={false}` keeps the chip at its intrinsic width (flex: none).
|
|
33
|
+
shrink?: boolean;
|
|
26
34
|
children?: Snippet;
|
|
27
35
|
} = $props();
|
|
28
36
|
</script>
|
|
@@ -35,6 +43,9 @@
|
|
|
35
43
|
class="toggle {klass}"
|
|
36
44
|
class:pill
|
|
37
45
|
class:struck
|
|
46
|
+
class:md={size === 'md'}
|
|
47
|
+
class:grow
|
|
48
|
+
class:no-shrink={!shrink}
|
|
38
49
|
class:on={pressed}
|
|
39
50
|
aria-pressed={pressed}
|
|
40
51
|
>
|
|
@@ -69,6 +80,17 @@
|
|
|
69
80
|
.toggle.pill {
|
|
70
81
|
border-radius: var(--r-pill);
|
|
71
82
|
}
|
|
83
|
+
.toggle.md {
|
|
84
|
+
padding: 0.3rem var(--sp-2);
|
|
85
|
+
font-size: var(--fs-sm);
|
|
86
|
+
}
|
|
87
|
+
.toggle.grow {
|
|
88
|
+
flex: 1 1 0;
|
|
89
|
+
min-width: 0;
|
|
90
|
+
}
|
|
91
|
+
.toggle.no-shrink {
|
|
92
|
+
flex: none;
|
|
93
|
+
}
|
|
72
94
|
.toggle:hover:not(:disabled) {
|
|
73
95
|
border-color: var(--border-strong);
|
|
74
96
|
}
|
|
@@ -4,6 +4,9 @@ type $$ComponentProps = HTMLButtonAttributes & {
|
|
|
4
4
|
pressed?: boolean;
|
|
5
5
|
pill?: boolean;
|
|
6
6
|
struck?: boolean;
|
|
7
|
+
size?: 'sm' | 'md';
|
|
8
|
+
grow?: boolean;
|
|
9
|
+
shrink?: boolean;
|
|
7
10
|
children?: Snippet;
|
|
8
11
|
};
|
|
9
12
|
declare const Toggle: import("svelte").Component<$$ComponentProps, {}, "">;
|
package/package.json
CHANGED