bref-ui 2.0.1 → 2.1.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/button/button.svelte +67 -47
- package/dist/button/types.d.ts +1 -0
- package/dist/checkbox/checkbox.svelte +40 -35
- package/dist/combobox/combobox.svelte +2 -3
- package/dist/combobox/input.svelte +1 -1
- package/dist/combobox/list.svelte +5 -5
- package/dist/combobox/option.svelte +29 -9
- package/dist/dialog/dialog.svelte +15 -12
- package/dist/dialog/footer.svelte +2 -2
- package/dist/dialog/header.svelte +4 -4
- package/dist/icon/icon.svelte +6 -4
- package/dist/pill/content.svelte +11 -4
- package/dist/pill/content.svelte.d.ts +1 -1
- package/dist/pill/on-delete.svelte +42 -13
- package/dist/pill/pill.svelte +74 -94
- package/dist/pill/registry.json +1 -1
- package/dist/pill/types.d.ts +1 -0
- package/dist/pill-choice-group/pill-choice-group.svelte +19 -0
- package/dist/pill-choice-group/types.d.ts +1 -0
- package/dist/pill-group/pill-group.svelte +2 -0
- package/dist/pill-group/types.d.ts +1 -0
- package/dist/popover/popover.svelte +31 -6
- package/dist/popover/types.d.ts +1 -1
- package/dist/progress/progress.svelte +42 -55
- package/dist/select/empty.svelte +2 -3
- package/dist/select/list.svelte +2 -1
- package/dist/select/option.svelte +20 -6
- package/dist/select/select.svelte +7 -4
- package/dist/select/trigger.svelte +30 -7
- package/dist/spinner/spinner.svelte +8 -21
- package/dist/surface/surface.svelte +6 -1
- package/dist/surface/types.d.ts +2 -0
- package/dist/switch/switch.svelte +48 -51
- package/dist/text-area/registry.json +1 -1
- package/dist/text-area/text-area.svelte +33 -73
- package/dist/text-area/types.d.ts +1 -0
- package/dist/text-input/registry.json +1 -1
- package/dist/text-input/text-input.svelte +33 -73
- package/dist/text-input/types.d.ts +1 -0
- package/dist/theme/cli-theme.svelte +2 -0
- package/dist/theme/glass.svelte +60 -0
- package/dist/theme/glass.svelte.d.ts +26 -0
- package/dist/theme/registry.json +1 -0
- package/dist/theme/styles.svelte +6 -0
- package/dist/theme/surface.d.ts +1 -1
- package/dist/theme/surface.js +3 -2
- package/dist/theme/surfaces.svelte +23 -45
- package/dist/theme/theme.svelte +2 -0
- package/dist/tree-view/tree-node/chevron-button.svelte +9 -9
- package/dist/tree-view/tree-node/content.svelte +15 -12
- package/dist/tree-view/tree-node/delete-button.svelte +6 -5
- package/dist/tree-view/tree-node/tree-node.svelte +23 -24
- package/dist/tree-view/tree-view-section.svelte +9 -9
- package/dist/tree-view/tree-view.svelte +17 -9
- package/dist/tree-view/types.d.ts +2 -1
- package/package.json +1 -1
- package/readme.md +3 -1
- package/src/lib/button/button.svelte +67 -47
- package/src/lib/button/types.ts +1 -0
- package/src/lib/checkbox/checkbox.svelte +40 -35
- package/src/lib/combobox/combobox.svelte +2 -3
- package/src/lib/combobox/input.svelte +1 -1
- package/src/lib/combobox/list.svelte +5 -5
- package/src/lib/combobox/option.svelte +29 -9
- package/src/lib/dialog/dialog.svelte +15 -12
- package/src/lib/dialog/footer.svelte +2 -2
- package/src/lib/dialog/header.svelte +4 -4
- package/src/lib/icon/icon.svelte +6 -4
- package/src/lib/pill/content.svelte +11 -4
- package/src/lib/pill/on-delete.svelte +42 -13
- package/src/lib/pill/pill.svelte +74 -94
- package/src/lib/pill/registry.json +1 -1
- package/src/lib/pill/types.ts +1 -0
- package/src/lib/pill-choice-group/pill-choice-group.svelte +19 -0
- package/src/lib/pill-choice-group/types.ts +1 -0
- package/src/lib/pill-group/pill-group.svelte +2 -0
- package/src/lib/pill-group/types.ts +1 -0
- package/src/lib/popover/popover.svelte +31 -6
- package/src/lib/popover/types.ts +16 -1
- package/src/lib/progress/progress.svelte +42 -55
- package/src/lib/select/empty.svelte +2 -3
- package/src/lib/select/list.svelte +2 -1
- package/src/lib/select/option.svelte +20 -6
- package/src/lib/select/select.svelte +7 -4
- package/src/lib/select/trigger.svelte +30 -7
- package/src/lib/spinner/spinner.svelte +8 -21
- package/src/lib/surface/surface.svelte +6 -1
- package/src/lib/surface/types.ts +2 -0
- package/src/lib/switch/switch.svelte +48 -51
- package/src/lib/text-area/registry.json +1 -1
- package/src/lib/text-area/text-area.svelte +33 -73
- package/src/lib/text-area/types.ts +1 -0
- package/src/lib/text-input/registry.json +1 -1
- package/src/lib/text-input/text-input.svelte +33 -73
- package/src/lib/text-input/types.ts +1 -0
- package/src/lib/theme/cli-theme.svelte +2 -0
- package/src/lib/theme/glass.svelte +60 -0
- package/src/lib/theme/registry.json +1 -0
- package/src/lib/theme/styles.svelte +6 -0
- package/src/lib/theme/surface.ts +4 -2
- package/src/lib/theme/surfaces.svelte +23 -45
- package/src/lib/theme/theme.svelte +2 -0
- package/src/lib/tree-view/tree-node/chevron-button.svelte +9 -9
- package/src/lib/tree-view/tree-node/content.svelte +15 -12
- package/src/lib/tree-view/tree-node/delete-button.svelte +6 -5
- package/src/lib/tree-view/tree-node/tree-node.svelte +23 -24
- package/src/lib/tree-view/tree-view-section.svelte +9 -9
- package/src/lib/tree-view/tree-view.svelte +17 -9
- package/src/lib/tree-view/types.ts +2 -1
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
import { fly } from 'svelte/transition';
|
|
5
5
|
import { prefersReducedMotion } from 'svelte/motion';
|
|
6
6
|
import { MediaQuery } from 'svelte/reactivity';
|
|
7
|
+
import { surface } from '../theme/surface.js';
|
|
7
8
|
import Header from './header.svelte';
|
|
8
9
|
import Footer from './footer.svelte';
|
|
9
10
|
import type { DialogProps } from './types.js';
|
|
@@ -71,6 +72,7 @@
|
|
|
71
72
|
{#if open}
|
|
72
73
|
<div
|
|
73
74
|
data-surface
|
|
75
|
+
class={surface({ color: 'background', glass: true, shadow: 'large' })}
|
|
74
76
|
use:showModal
|
|
75
77
|
transition:fly|global={{
|
|
76
78
|
y: prefersReducedMotion.current ? 0 : 16,
|
|
@@ -104,11 +106,7 @@
|
|
|
104
106
|
display: flex;
|
|
105
107
|
flex-direction: column;
|
|
106
108
|
max-height: calc(100dvh - 2rem);
|
|
107
|
-
border:
|
|
108
|
-
border-radius: 0.75rem;
|
|
109
|
-
background: var(--color-background, white);
|
|
110
|
-
color: var(--color-foreground, black);
|
|
111
|
-
box-shadow: 0 1.5rem 4rem color-mix(in srgb, var(--color-foreground, black) 20%, transparent);
|
|
109
|
+
border-radius: 1rem;
|
|
112
110
|
}
|
|
113
111
|
dialog[open] {
|
|
114
112
|
display: flex;
|
|
@@ -127,26 +125,30 @@
|
|
|
127
125
|
--internal-width: 72rem;
|
|
128
126
|
}
|
|
129
127
|
dialog::backdrop {
|
|
130
|
-
background: color-mix(in srgb, var(--color-
|
|
131
|
-
|
|
128
|
+
background: color-mix(in srgb, var(--color-background, white) 48%, transparent);
|
|
129
|
+
-webkit-backdrop-filter: blur(0);
|
|
132
130
|
backdrop-filter: blur(0);
|
|
131
|
+
opacity: 0;
|
|
133
132
|
transition:
|
|
134
133
|
opacity 300ms ease,
|
|
134
|
+
-webkit-backdrop-filter 300ms ease,
|
|
135
135
|
backdrop-filter 300ms ease;
|
|
136
136
|
}
|
|
137
137
|
dialog[data-visible='true']::backdrop {
|
|
138
|
-
|
|
138
|
+
-webkit-backdrop-filter: blur(0.25rem);
|
|
139
139
|
backdrop-filter: blur(0.25rem);
|
|
140
|
+
opacity: 1;
|
|
140
141
|
}
|
|
141
142
|
@starting-style {
|
|
142
143
|
dialog[data-visible='true']::backdrop {
|
|
143
|
-
|
|
144
|
+
-webkit-backdrop-filter: blur(0);
|
|
144
145
|
backdrop-filter: blur(0);
|
|
146
|
+
opacity: 0;
|
|
145
147
|
}
|
|
146
148
|
}
|
|
147
149
|
[data-content] {
|
|
148
150
|
min-height: 0;
|
|
149
|
-
padding: 1.5rem;
|
|
151
|
+
padding: 1.25rem 1.75rem 1.5rem;
|
|
150
152
|
overflow: auto;
|
|
151
153
|
}
|
|
152
154
|
dialog[data-size='full-screen'] {
|
|
@@ -172,11 +174,12 @@
|
|
|
172
174
|
}
|
|
173
175
|
@media (forced-colors: active) {
|
|
174
176
|
[data-surface] {
|
|
175
|
-
border
|
|
176
|
-
box-shadow: none;
|
|
177
|
+
border: 1px solid CanvasText;
|
|
177
178
|
}
|
|
178
179
|
dialog::backdrop {
|
|
179
180
|
background: Canvas;
|
|
181
|
+
-webkit-backdrop-filter: none;
|
|
182
|
+
backdrop-filter: none;
|
|
180
183
|
}
|
|
181
184
|
}
|
|
182
185
|
</style>
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
display: flex;
|
|
30
30
|
align-items: flex-start;
|
|
31
31
|
gap: 1rem;
|
|
32
|
-
padding: 1.
|
|
32
|
+
padding: 1.75rem 1.75rem 0;
|
|
33
33
|
}
|
|
34
34
|
header > div {
|
|
35
35
|
flex: 1;
|
|
@@ -44,9 +44,9 @@
|
|
|
44
44
|
h2 {
|
|
45
45
|
margin: 0;
|
|
46
46
|
font: inherit;
|
|
47
|
-
font-size: 1.
|
|
48
|
-
font-weight:
|
|
49
|
-
line-height: 1.
|
|
47
|
+
font-size: 1.5rem;
|
|
48
|
+
font-weight: 400;
|
|
49
|
+
line-height: 1.3;
|
|
50
50
|
}
|
|
51
51
|
p {
|
|
52
52
|
margin: 0.5rem 0 0;
|
package/src/lib/icon/icon.svelte
CHANGED
|
@@ -29,6 +29,8 @@
|
|
|
29
29
|
height: 1em;
|
|
30
30
|
align-items: center;
|
|
31
31
|
justify-content: center;
|
|
32
|
+
flex-shrink: 0;
|
|
33
|
+
vertical-align: middle;
|
|
32
34
|
font-family: 'Material Symbols Outlined';
|
|
33
35
|
font-style: normal;
|
|
34
36
|
font-weight: 100;
|
|
@@ -51,11 +53,11 @@
|
|
|
51
53
|
}
|
|
52
54
|
|
|
53
55
|
.x-small {
|
|
54
|
-
font-size:
|
|
56
|
+
font-size: 1rem;
|
|
55
57
|
}
|
|
56
58
|
|
|
57
59
|
.small {
|
|
58
|
-
font-size:
|
|
60
|
+
font-size: 1.25rem;
|
|
59
61
|
}
|
|
60
62
|
|
|
61
63
|
.medium {
|
|
@@ -63,11 +65,11 @@
|
|
|
63
65
|
}
|
|
64
66
|
|
|
65
67
|
.large {
|
|
66
|
-
font-size:
|
|
68
|
+
font-size: 2rem;
|
|
67
69
|
}
|
|
68
70
|
|
|
69
71
|
.x-large {
|
|
70
|
-
font-size: 5rem;
|
|
72
|
+
font-size: 2.5rem;
|
|
71
73
|
}
|
|
72
74
|
|
|
73
75
|
.primary {
|
|
@@ -3,21 +3,28 @@
|
|
|
3
3
|
import Icon from '../icon/icon.svelte';
|
|
4
4
|
import type { PillProps } from './types.js';
|
|
5
5
|
|
|
6
|
-
let { label, icon
|
|
6
|
+
let { label, icon }: Pick<PillProps, 'label' | 'icon'> = $props();
|
|
7
7
|
</script>
|
|
8
8
|
|
|
9
9
|
{#if icon}
|
|
10
10
|
{#key icon.name}
|
|
11
|
-
<
|
|
12
|
-
<Icon {...icon} label={undefined} {
|
|
13
|
-
</
|
|
11
|
+
<i data-icon in:fly>
|
|
12
|
+
<Icon {...icon} label={undefined} size={undefined} color={undefined} />
|
|
13
|
+
</i>
|
|
14
14
|
{/key}
|
|
15
15
|
{/if}
|
|
16
16
|
<span>{label}</span>
|
|
17
17
|
|
|
18
18
|
<style>
|
|
19
19
|
[data-icon] {
|
|
20
|
+
all: unset;
|
|
20
21
|
display: inline-flex;
|
|
21
22
|
align-items: center;
|
|
23
|
+
flex-shrink: 0;
|
|
24
|
+
font-size: var(--pill-icon-size, 1.125rem);
|
|
25
|
+
}
|
|
26
|
+
span {
|
|
27
|
+
flex: 1;
|
|
28
|
+
text-justify: left;
|
|
22
29
|
}
|
|
23
30
|
</style>
|
|
@@ -1,26 +1,55 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
|
-
import
|
|
2
|
+
import Icon from '../icon/icon.svelte';
|
|
3
3
|
import type { PillProps } from './types.js';
|
|
4
4
|
|
|
5
5
|
let { label, onDelete }: Required<Pick<PillProps, 'label' | 'onDelete'>> = $props();
|
|
6
6
|
</script>
|
|
7
7
|
|
|
8
|
-
<
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
</span>
|
|
8
|
+
<button
|
|
9
|
+
type="button"
|
|
10
|
+
aria-label={`Remove ${label}`}
|
|
11
|
+
onclick={(event) => {
|
|
12
|
+
event.stopPropagation();
|
|
13
|
+
onDelete();
|
|
14
|
+
}}
|
|
15
|
+
>
|
|
16
|
+
<Icon name="close" />
|
|
17
|
+
</button>
|
|
19
18
|
|
|
20
19
|
<style>
|
|
21
|
-
|
|
20
|
+
button {
|
|
21
|
+
box-sizing: border-box;
|
|
22
22
|
position: relative;
|
|
23
23
|
z-index: 1;
|
|
24
24
|
display: inline-flex;
|
|
25
|
+
align-items: center;
|
|
26
|
+
justify-content: center;
|
|
27
|
+
flex-shrink: 0;
|
|
28
|
+
width: var(--pill-delete-size, 1.5rem);
|
|
29
|
+
height: var(--pill-delete-size, 1.5rem);
|
|
30
|
+
padding: 0;
|
|
31
|
+
border: 0;
|
|
32
|
+
border-radius: 50%;
|
|
33
|
+
background: transparent;
|
|
34
|
+
color: inherit;
|
|
35
|
+
font: inherit;
|
|
36
|
+
font-size: var(--pill-icon-size, 1.125rem);
|
|
37
|
+
cursor: pointer;
|
|
38
|
+
}
|
|
39
|
+
button:hover {
|
|
40
|
+
background: color-mix(in srgb, currentColor 8%, transparent);
|
|
41
|
+
}
|
|
42
|
+
button:active {
|
|
43
|
+
background: color-mix(in srgb, currentColor 16%, transparent);
|
|
44
|
+
}
|
|
45
|
+
button:focus-visible {
|
|
46
|
+
outline: 2px solid currentColor;
|
|
47
|
+
outline-offset: -2px;
|
|
48
|
+
}
|
|
49
|
+
@media (pointer: coarse) {
|
|
50
|
+
button {
|
|
51
|
+
min-width: 44px;
|
|
52
|
+
min-height: 44px;
|
|
53
|
+
}
|
|
25
54
|
}
|
|
26
55
|
</style>
|
package/src/lib/pill/pill.svelte
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
2
|
/* eslint-disable max-lines -- Component recipe and animation remain colocated. */
|
|
3
3
|
import type { PillProps } from './types.js';
|
|
4
|
+
import { surface } from '../theme/surface.js';
|
|
4
5
|
import Content from './content.svelte';
|
|
5
6
|
import OnDelete from './on-delete.svelte';
|
|
6
7
|
|
|
@@ -15,32 +16,46 @@
|
|
|
15
16
|
size = 'medium',
|
|
16
17
|
variant = 'neutral',
|
|
17
18
|
wide = false,
|
|
19
|
+
class: className,
|
|
20
|
+
glass,
|
|
18
21
|
...attributes
|
|
19
22
|
}: PillProps = $props();
|
|
23
|
+
|
|
24
|
+
const nativeAttributes = $derived({
|
|
25
|
+
...attributes,
|
|
26
|
+
onclick: onClick,
|
|
27
|
+
role: onClick ? 'button' : attributes.role,
|
|
28
|
+
tabindex: onClick ? (attributes.tabindex ?? 0) : attributes.tabindex,
|
|
29
|
+
'aria-label': attributes['aria-labelledby']
|
|
30
|
+
? undefined
|
|
31
|
+
: (attributes['aria-label'] ?? (onClick ? label : undefined)),
|
|
32
|
+
onkeydown: onClick
|
|
33
|
+
? (event: KeyboardEvent & { currentTarget: EventTarget & HTMLDivElement }) => {
|
|
34
|
+
attributes.onkeydown?.(event);
|
|
35
|
+
if (
|
|
36
|
+
!event.defaultPrevented &&
|
|
37
|
+
event.target === event.currentTarget &&
|
|
38
|
+
(event.key === 'Enter' || event.key === ' ')
|
|
39
|
+
) {
|
|
40
|
+
event.preventDefault();
|
|
41
|
+
if (!event.repeat) event.currentTarget.click();
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
: attributes.onkeydown
|
|
45
|
+
});
|
|
20
46
|
</script>
|
|
21
47
|
|
|
22
|
-
<!-- svelte-ignore a11y_no_noninteractive_tabindex (The button role and tab stop are enabled together.) -->
|
|
23
48
|
<div
|
|
24
|
-
{...
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
if (
|
|
35
|
-
!event.defaultPrevented &&
|
|
36
|
-
event.target === event.currentTarget &&
|
|
37
|
-
(event.key === 'Enter' || event.key === ' ')
|
|
38
|
-
) {
|
|
39
|
-
event.preventDefault();
|
|
40
|
-
if (!event.repeat) event.currentTarget.click();
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
: attributes.onkeydown}
|
|
49
|
+
{...nativeAttributes}
|
|
50
|
+
class={[
|
|
51
|
+
surface({
|
|
52
|
+
color,
|
|
53
|
+
variant,
|
|
54
|
+
glass,
|
|
55
|
+
hover: onClick || onDelete ? 'small' : undefined
|
|
56
|
+
}),
|
|
57
|
+
className
|
|
58
|
+
]}
|
|
44
59
|
data-swoosh={swoosh || undefined}
|
|
45
60
|
data-clickable={onClick ? '' : undefined}
|
|
46
61
|
data-icon={icon ? '' : undefined}
|
|
@@ -48,85 +63,69 @@
|
|
|
48
63
|
data-color={color}
|
|
49
64
|
data-size={size}
|
|
50
65
|
data-variant={variant}
|
|
51
|
-
style:--pill-color={`var(--color-${color}, var(--color-foreground))`}
|
|
52
66
|
data-wide={wide}
|
|
53
67
|
>
|
|
54
|
-
<Content {label} {icon}
|
|
68
|
+
<Content {label} {icon} />
|
|
55
69
|
{@render children?.()}
|
|
70
|
+
<!-- todo: the on delete should always be at right msot of the pill, content has to "fill the parent" -->
|
|
56
71
|
{#if onDelete}<OnDelete {label} {onDelete} />{/if}
|
|
57
72
|
</div>
|
|
58
73
|
|
|
59
74
|
<style>
|
|
60
75
|
div {
|
|
61
|
-
--pill-
|
|
62
|
-
--pill-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
);
|
|
67
|
-
--pill-border: color-mix(in srgb, var(--pill-color) 20%, transparent);
|
|
68
|
-
--pill-highlight: color-mix(in srgb, var(--color-foreground, black) 16%, transparent);
|
|
69
|
-
--pill-content: var(--pill-color);
|
|
70
|
-
--pill-padding: 1.125rem;
|
|
71
|
-
--pill-height: 3rem;
|
|
76
|
+
--pill-glint: color-mix(in srgb, var(--color-foreground, black) 8%, transparent);
|
|
77
|
+
--pill-padding: 0.75rem;
|
|
78
|
+
--pill-height: 2rem;
|
|
79
|
+
--pill-icon-size: 1.125rem;
|
|
80
|
+
--pill-delete-size: 1.5rem;
|
|
72
81
|
box-sizing: border-box;
|
|
73
82
|
display: inline-flex;
|
|
74
83
|
position: relative;
|
|
75
84
|
isolation: isolate;
|
|
76
85
|
align-items: center;
|
|
77
|
-
gap: 0.
|
|
78
|
-
justify-content:
|
|
86
|
+
gap: 0.375rem;
|
|
87
|
+
justify-content: flex-start;
|
|
79
88
|
min-width: 0;
|
|
89
|
+
width: fit-content;
|
|
80
90
|
max-width: 100%;
|
|
81
91
|
min-height: var(--pill-height);
|
|
82
|
-
padding: 0.
|
|
83
|
-
border: 1px solid var(--pill-border);
|
|
92
|
+
padding: 0.125rem var(--pill-padding);
|
|
84
93
|
border-radius: 999px;
|
|
85
|
-
background: var(--pill-background);
|
|
86
|
-
box-shadow:
|
|
87
|
-
inset 0 1px 0 var(--pill-highlight),
|
|
88
|
-
0 2px 6px color-mix(in srgb, var(--color-foreground, black) 8%, transparent);
|
|
89
|
-
-webkit-backdrop-filter: blur(0.5rem) saturate(120%);
|
|
90
|
-
backdrop-filter: blur(0.5rem) saturate(120%);
|
|
91
|
-
transition: all 150ms;
|
|
92
|
-
color: var(--pill-content);
|
|
93
94
|
font: inherit;
|
|
94
95
|
line-height: 1.25;
|
|
95
|
-
text-align:
|
|
96
|
+
text-align: left;
|
|
96
97
|
white-space: normal;
|
|
97
98
|
overflow-wrap: anywhere;
|
|
98
99
|
overflow: hidden;
|
|
99
100
|
user-select: none;
|
|
100
101
|
}
|
|
101
102
|
div[data-size='x-small'] {
|
|
102
|
-
--pill-height: 1.
|
|
103
|
+
--pill-height: 1.5rem;
|
|
103
104
|
--pill-padding: 0.5rem;
|
|
104
|
-
|
|
105
|
+
--pill-icon-size: 0.875rem;
|
|
106
|
+
font-size: 0.8125rem;
|
|
105
107
|
}
|
|
106
108
|
div[data-size='small'] {
|
|
107
|
-
--pill-height:
|
|
108
|
-
--pill-padding: 0.
|
|
109
|
+
--pill-height: 1.75rem;
|
|
110
|
+
--pill-padding: 0.625rem;
|
|
111
|
+
--pill-icon-size: 1rem;
|
|
112
|
+
font-size: 0.875rem;
|
|
109
113
|
}
|
|
110
114
|
div[data-size='large'] {
|
|
111
|
-
--pill-height:
|
|
112
|
-
--pill-padding:
|
|
113
|
-
|
|
115
|
+
--pill-height: 2.25rem;
|
|
116
|
+
--pill-padding: 0.875rem;
|
|
117
|
+
--pill-icon-size: 1.25rem;
|
|
118
|
+
--pill-delete-size: 1.75rem;
|
|
114
119
|
}
|
|
115
120
|
div[data-size='x-large'] {
|
|
116
|
-
--pill-height: 5rem;
|
|
117
|
-
--pill-padding:
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
--pill-tint: 16%;
|
|
122
|
-
--pill-border: color-mix(in srgb, var(--pill-color) 30%, transparent);
|
|
123
|
-
--pill-content: color-mix(in srgb, var(--pill-color) 80%, var(--color-foreground, black));
|
|
121
|
+
--pill-height: 2.5rem;
|
|
122
|
+
--pill-padding: 1rem;
|
|
123
|
+
--pill-icon-size: 1.375rem;
|
|
124
|
+
--pill-delete-size: 2rem;
|
|
125
|
+
font-size: 1.125rem;
|
|
124
126
|
}
|
|
125
127
|
div[data-variant='filled'] {
|
|
126
|
-
--pill-
|
|
127
|
-
--pill-border: color-mix(in srgb, var(--pill-color) 68%, var(--color-foreground, black));
|
|
128
|
-
--pill-highlight: color-mix(in srgb, var(--color-foreground, black) 28%, transparent);
|
|
129
|
-
--pill-content: color-mix(in srgb, var(--color-background, white) 90%, var(--pill-color));
|
|
128
|
+
--pill-glint: color-mix(in srgb, var(--surface-color) 28%, transparent);
|
|
130
129
|
}
|
|
131
130
|
div[data-icon] {
|
|
132
131
|
padding-left: calc(var(--pill-padding) * 0.6);
|
|
@@ -134,12 +133,8 @@
|
|
|
134
133
|
div[data-removable] {
|
|
135
134
|
padding-right: calc(var(--pill-padding) / 2);
|
|
136
135
|
}
|
|
137
|
-
div[data-
|
|
138
|
-
|
|
139
|
-
}
|
|
140
|
-
div[data-clickable]:focus-visible {
|
|
141
|
-
outline: 2px solid var(--color-primary, currentColor);
|
|
142
|
-
outline-offset: 3px;
|
|
136
|
+
div[data-wide='true'] {
|
|
137
|
+
width: 100%;
|
|
143
138
|
}
|
|
144
139
|
div[data-swoosh]::before {
|
|
145
140
|
position: absolute;
|
|
@@ -148,21 +143,13 @@
|
|
|
148
143
|
inset-inline-start: -45%;
|
|
149
144
|
width: 40%;
|
|
150
145
|
content: '';
|
|
151
|
-
background: linear-gradient(
|
|
152
|
-
90deg,
|
|
153
|
-
transparent,
|
|
154
|
-
color-mix(in srgb, var(--pill-color) 28%, transparent),
|
|
155
|
-
transparent
|
|
156
|
-
);
|
|
146
|
+
background: linear-gradient(90deg, transparent, var(--pill-glint), transparent);
|
|
157
147
|
filter: blur(0.3rem);
|
|
158
148
|
opacity: 0;
|
|
159
149
|
pointer-events: none;
|
|
160
150
|
transform: skewX(-18deg);
|
|
161
151
|
animation: pill-swoosh 2s ease-in-out infinite;
|
|
162
152
|
}
|
|
163
|
-
div[data-wide='true'] {
|
|
164
|
-
width: 100%;
|
|
165
|
-
}
|
|
166
153
|
@keyframes pill-swoosh {
|
|
167
154
|
0%,
|
|
168
155
|
20% {
|
|
@@ -179,22 +166,15 @@
|
|
|
179
166
|
transform: translateX(400%) skewX(-18deg);
|
|
180
167
|
}
|
|
181
168
|
}
|
|
182
|
-
@media (
|
|
183
|
-
div {
|
|
184
|
-
|
|
169
|
+
@media (pointer: coarse) {
|
|
170
|
+
div[data-clickable] {
|
|
171
|
+
min-width: 44px;
|
|
172
|
+
min-height: 44px;
|
|
185
173
|
}
|
|
174
|
+
}
|
|
175
|
+
@media (prefers-reduced-motion: reduce) {
|
|
186
176
|
div[data-swoosh]::before {
|
|
187
177
|
animation: none;
|
|
188
178
|
}
|
|
189
179
|
}
|
|
190
|
-
@media (forced-colors: active) {
|
|
191
|
-
div {
|
|
192
|
-
border-color: CanvasText;
|
|
193
|
-
color: CanvasText;
|
|
194
|
-
background: Canvas;
|
|
195
|
-
box-shadow: none;
|
|
196
|
-
-webkit-backdrop-filter: none;
|
|
197
|
-
backdrop-filter: none;
|
|
198
|
-
}
|
|
199
|
-
}
|
|
200
180
|
</style>
|
package/src/lib/pill/types.ts
CHANGED
|
@@ -12,6 +12,7 @@
|
|
|
12
12
|
size = 'medium',
|
|
13
13
|
variant = 'neutral',
|
|
14
14
|
color = 'foreground',
|
|
15
|
+
glass,
|
|
15
16
|
animateSelected = false,
|
|
16
17
|
...attributes
|
|
17
18
|
}: PillChoiceGroupProps = $props();
|
|
@@ -80,6 +81,7 @@
|
|
|
80
81
|
label={item.label}
|
|
81
82
|
icon={item.icon}
|
|
82
83
|
{color}
|
|
84
|
+
{glass}
|
|
83
85
|
swoosh={selected && animateSelected}
|
|
84
86
|
variant={selected ? selectedVariant : variant}
|
|
85
87
|
{size}
|
|
@@ -110,6 +112,15 @@
|
|
|
110
112
|
clip-path: inset(50%);
|
|
111
113
|
overflow: hidden;
|
|
112
114
|
}
|
|
115
|
+
div:has(input:checked) {
|
|
116
|
+
--pill-choice-emphasis: 18%;
|
|
117
|
+
}
|
|
118
|
+
div:not([data-disabled]):is(:hover, :has(input:focus-visible)) {
|
|
119
|
+
--pill-choice-hover: 2%;
|
|
120
|
+
}
|
|
121
|
+
div:not([data-disabled]):active {
|
|
122
|
+
--pill-choice-hover: 4%;
|
|
123
|
+
}
|
|
113
124
|
div:has(input:focus-visible) {
|
|
114
125
|
outline: 2px solid var(--color-primary, currentColor);
|
|
115
126
|
outline-offset: 3px;
|
|
@@ -122,6 +133,14 @@
|
|
|
122
133
|
opacity: 0.45;
|
|
123
134
|
cursor: not-allowed;
|
|
124
135
|
}
|
|
136
|
+
@media (pointer: coarse) {
|
|
137
|
+
div {
|
|
138
|
+
display: inline-grid;
|
|
139
|
+
min-width: 44px;
|
|
140
|
+
min-height: 44px;
|
|
141
|
+
align-items: stretch;
|
|
142
|
+
}
|
|
143
|
+
}
|
|
125
144
|
@media (forced-colors: active) {
|
|
126
145
|
div:has(input:checked) {
|
|
127
146
|
outline: 2px solid Highlight;
|
|
@@ -9,6 +9,7 @@
|
|
|
9
9
|
color = 'foreground',
|
|
10
10
|
size = 'medium',
|
|
11
11
|
variant = 'neutral',
|
|
12
|
+
glass,
|
|
12
13
|
...attributes
|
|
13
14
|
}: PillGroupProps = $props();
|
|
14
15
|
</script>
|
|
@@ -21,6 +22,7 @@
|
|
|
21
22
|
{color}
|
|
22
23
|
{size}
|
|
23
24
|
{variant}
|
|
25
|
+
{glass}
|
|
24
26
|
onDelete={onDelete ? () => onDelete?.(item.id) : undefined}
|
|
25
27
|
/>
|
|
26
28
|
{/snippet}
|
|
@@ -8,6 +8,7 @@ export type PillGroupProps = Omit<HTMLAttributes<HTMLUListElement>, 'children' |
|
|
|
8
8
|
color?: PillProps['color'];
|
|
9
9
|
size?: PillProps['size'];
|
|
10
10
|
variant?: PillProps['variant'];
|
|
11
|
+
glass?: PillProps['glass'];
|
|
11
12
|
};
|
|
12
13
|
export type PillGroupContainerProps = Omit<HTMLAttributes<HTMLUListElement>, 'children'> &
|
|
13
14
|
Pick<PillGroupProps, 'items' | 'size'> & {
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
|
-
import {
|
|
2
|
+
import { cubicOut } from 'svelte/easing';
|
|
3
3
|
import { prefersReducedMotion } from 'svelte/motion';
|
|
4
|
+
import type { TransitionConfig } from 'svelte/transition';
|
|
4
5
|
import Surface from '../surface/surface.svelte';
|
|
5
6
|
import type { PopoverProps } from './types.js';
|
|
7
|
+
import type { SurfaceProps } from '../surface/types.ts';
|
|
6
8
|
|
|
7
9
|
let {
|
|
8
10
|
trigger,
|
|
@@ -15,11 +17,27 @@
|
|
|
15
17
|
let anchor: HTMLDivElement;
|
|
16
18
|
let returnFocus: HTMLElement | null = null;
|
|
17
19
|
|
|
20
|
+
const flyGlass: (node: Element) => TransitionConfig = () => ({
|
|
21
|
+
duration: prefersReducedMotion.current ? 0 : 250,
|
|
22
|
+
easing: cubicOut,
|
|
23
|
+
css: (t: number, u: number) =>
|
|
24
|
+
`--surface-motion-offset: ${u * 10}px; --surface-motion-opacity: ${t}`
|
|
25
|
+
});
|
|
26
|
+
|
|
18
27
|
const showPopover = (node: HTMLDivElement) => {
|
|
19
28
|
if (node.matches(':popover-open')) return;
|
|
20
29
|
returnFocus = document.activeElement instanceof HTMLElement ? document.activeElement : null;
|
|
21
30
|
node.showPopover({ source: anchor.firstElementChild as HTMLElement });
|
|
22
31
|
};
|
|
32
|
+
|
|
33
|
+
const surfacePropsWithDefaults: SurfaceProps = $derived({
|
|
34
|
+
variant: 'soft',
|
|
35
|
+
spacing: 'medium',
|
|
36
|
+
radius: 'small',
|
|
37
|
+
shadow: 'medium',
|
|
38
|
+
...surfaceProps,
|
|
39
|
+
glass: true
|
|
40
|
+
});
|
|
23
41
|
</script>
|
|
24
42
|
|
|
25
43
|
<div data-trigger bind:this={anchor}>
|
|
@@ -30,7 +48,8 @@
|
|
|
30
48
|
use:showPopover
|
|
31
49
|
{id}
|
|
32
50
|
popover="auto"
|
|
33
|
-
|
|
51
|
+
data-width={surfaceProps.width}
|
|
52
|
+
transition:flyGlass
|
|
34
53
|
onintrostart={(event) => showPopover(event.currentTarget)}
|
|
35
54
|
onoutrostart={(event) => {
|
|
36
55
|
if (!event.currentTarget.matches(':popover-open')) return;
|
|
@@ -42,7 +61,7 @@
|
|
|
42
61
|
open = false;
|
|
43
62
|
}}
|
|
44
63
|
>
|
|
45
|
-
<Surface {...
|
|
64
|
+
<Surface {...surfacePropsWithDefaults} data-surface-motion>
|
|
46
65
|
<div data-content>{@render children()}</div>
|
|
47
66
|
</Surface>
|
|
48
67
|
</div>
|
|
@@ -59,17 +78,23 @@
|
|
|
59
78
|
inset: auto;
|
|
60
79
|
position-area: block-end;
|
|
61
80
|
position-try-fallbacks: flip-block;
|
|
62
|
-
width:
|
|
81
|
+
width: fit-content;
|
|
82
|
+
min-width: min(anchor-size(width), calc(100vw - 1rem));
|
|
63
83
|
max-width: calc(100vw - 1rem);
|
|
64
84
|
max-height: min(24rem, calc(100% - 0.75rem));
|
|
65
85
|
margin: 0.375rem 0;
|
|
66
86
|
padding: 0;
|
|
67
87
|
overflow: visible;
|
|
68
|
-
overflow-wrap:
|
|
88
|
+
overflow-wrap: break-word;
|
|
69
89
|
border: 0;
|
|
70
90
|
background: transparent;
|
|
71
91
|
color: var(--color-foreground, black);
|
|
72
|
-
transition:
|
|
92
|
+
transition:
|
|
93
|
+
display var(--internal-duration) allow-discrete,
|
|
94
|
+
overlay var(--internal-duration) allow-discrete;
|
|
95
|
+
}
|
|
96
|
+
div[popover][data-width='fill'] {
|
|
97
|
+
width: anchor-size(width);
|
|
73
98
|
}
|
|
74
99
|
div:popover-open {
|
|
75
100
|
display: flex;
|