m3-svelte 5.15.4 → 6.0.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/package/buttons/Button.svelte +137 -131
- package/package/buttons/ConnectedButtons.svelte +1 -1
- package/package/buttons/FAB.svelte +30 -21
- package/package/buttons/SplitButton.svelte +30 -21
- package/package/containers/BottomSheet.svelte +10 -8
- package/package/containers/Card.svelte +15 -13
- package/package/containers/Dialog.svelte +36 -45
- package/package/containers/Dialog.svelte.d.ts +0 -8
- package/package/containers/ListItem.svelte +43 -11
- package/package/containers/Menu.svelte +6 -4
- package/package/containers/MenuItem.svelte +13 -6
- package/package/containers/Snackbar.svelte +49 -45
- package/package/containers/Snackbar.svelte.d.ts +4 -17
- package/package/containers/SnackbarItem.svelte +9 -7
- package/package/containers/StandardSideSheet.svelte +11 -2
- package/package/forms/Checkbox.svelte +12 -12
- package/package/forms/Chip.svelte +31 -19
- package/package/forms/CircularProgress.svelte +3 -3
- package/package/forms/CircularProgressEstimate.svelte +2 -2
- package/package/forms/DateField.svelte +33 -19
- package/package/forms/DateFieldOutlined.svelte +42 -28
- package/package/forms/DatePickerDocked.svelte +5 -3
- package/package/forms/LinearProgress.svelte +5 -5
- package/package/forms/LinearProgressEstimate.svelte +4 -4
- package/package/forms/LoadingIndicator.svelte +4 -4
- package/package/forms/RadioAnim1.svelte +9 -9
- package/package/forms/RadioAnim2.svelte +9 -9
- package/package/forms/RadioAnim3.svelte +9 -9
- package/package/forms/Select.svelte +46 -36
- package/package/forms/SelectOutlined.svelte +47 -37
- package/package/forms/Slider.svelte +40 -33
- package/package/forms/Switch.svelte +30 -29
- package/package/forms/TextField.svelte +44 -27
- package/package/forms/TextFieldMultiline.svelte +44 -27
- package/package/forms/TextFieldOutlined.svelte +44 -30
- package/package/forms/TextFieldOutlinedMultiline.svelte +44 -30
- package/package/forms/WavyLinearProgress.svelte +2 -7
- package/package/forms/WavyLinearProgressEstimate.svelte +2 -7
- package/package/forms/_picker/CalendarPicker.svelte +9 -2
- package/package/forms/_picker/FocusPicker.svelte +9 -7
- package/package/forms/_picker/Header.svelte +12 -5
- package/package/forms/_picker/Item.svelte +15 -8
- package/package/index.d.ts +4 -8
- package/package/index.js +4 -7
- package/package/{utils → misc}/Divider.svelte +1 -1
- package/package/misc/Icon.svelte +0 -4
- package/package/misc/Layer.svelte +1 -1
- package/package/{utils → misc}/badge.js +8 -5
- package/package/misc/recommended-styles.css +12 -10
- package/package/misc/styles.css +183 -250
- package/package/misc/tailwind-styles.css +199 -107
- package/package/misc/utils.js +2 -4
- package/package/nav/NavCMLX.svelte +65 -29
- package/package/nav/NavCMLX.svelte.d.ts +1 -1
- package/package/nav/NavCMLXItem.svelte +359 -188
- package/package/nav/NavCMLXItem.svelte.d.ts +4 -7
- package/package/nav/Tabs.svelte +19 -10
- package/package/nav/TabsLink.svelte +19 -10
- package/package/nav/VariableTabs.svelte +18 -9
- package/package/nav/VariableTabsLink.svelte +18 -9
- package/package.json +16 -13
- package/package/containers/NewSnackbar.svelte +0 -113
- package/package/containers/NewSnackbar.svelte.d.ts +0 -7
- package/package/forms/CircularProgressIndeterminate.svelte +0 -62
- package/package/forms/CircularProgressIndeterminate.svelte.d.ts +0 -5
- package/package/forms/LinearProgressIndeterminate.svelte +0 -55
- package/package/forms/LinearProgressIndeterminate.svelte.d.ts +0 -5
- package/package/forms/SliderTicks.svelte +0 -12
- package/package/forms/SliderTicks.svelte.d.ts +0 -18
- /package/package/{utils → misc}/ChipChooser.svelte +0 -0
- /package/package/{utils → misc}/ChipChooser.svelte.d.ts +0 -0
- /package/package/{utils → misc}/Divider.svelte.d.ts +0 -0
- /package/package/{utils → misc}/badge.d.ts +0 -0
|
@@ -27,8 +27,10 @@
|
|
|
27
27
|
{/if}
|
|
28
28
|
|
|
29
29
|
<style>
|
|
30
|
-
|
|
31
|
-
|
|
30
|
+
@layer tokens {
|
|
31
|
+
:root {
|
|
32
|
+
--m3-card-shape: var(--m3-shape-medium);
|
|
33
|
+
}
|
|
32
34
|
}
|
|
33
35
|
|
|
34
36
|
.m3-container {
|
|
@@ -38,9 +40,9 @@
|
|
|
38
40
|
padding: 1rem; /* protip: use margin: -1rem (adjust as needed) to make images stretch to the end */
|
|
39
41
|
border: none;
|
|
40
42
|
border-radius: var(--m3-card-shape);
|
|
41
|
-
background-color:
|
|
42
|
-
--
|
|
43
|
-
color:
|
|
43
|
+
background-color: var(--m3c-surface);
|
|
44
|
+
--m3v-background: var(--m3c-surface);
|
|
45
|
+
color: var(--m3c-on-surface);
|
|
44
46
|
}
|
|
45
47
|
|
|
46
48
|
button {
|
|
@@ -51,24 +53,24 @@
|
|
|
51
53
|
}
|
|
52
54
|
@media (hover: hover) {
|
|
53
55
|
button:hover {
|
|
54
|
-
box-shadow: var(--m3-
|
|
56
|
+
box-shadow: var(--m3-elevation-1);
|
|
55
57
|
}
|
|
56
58
|
button.type-elevated:hover {
|
|
57
|
-
box-shadow: var(--m3-
|
|
59
|
+
box-shadow: var(--m3-elevation-2);
|
|
58
60
|
}
|
|
59
61
|
}
|
|
60
62
|
|
|
61
63
|
.elevated {
|
|
62
|
-
background-color:
|
|
63
|
-
--
|
|
64
|
-
box-shadow: var(--m3-
|
|
64
|
+
background-color: var(--m3c-surface-container-low);
|
|
65
|
+
--m3v-background: var(--m3c-surface-container-low);
|
|
66
|
+
box-shadow: var(--m3-elevation-1);
|
|
65
67
|
}
|
|
66
68
|
.filled {
|
|
67
|
-
background-color:
|
|
68
|
-
--
|
|
69
|
+
background-color: var(--m3c-surface-container-highest);
|
|
70
|
+
--m3v-background: var(--m3c-surface-container-highest);
|
|
69
71
|
}
|
|
70
72
|
.outlined {
|
|
71
|
-
border: solid 1px
|
|
73
|
+
border: solid 1px var(--m3c-outline-variant);
|
|
72
74
|
}
|
|
73
75
|
|
|
74
76
|
@media print, (forced-colors: active) {
|
|
@@ -18,14 +18,6 @@
|
|
|
18
18
|
buttons: Snippet;
|
|
19
19
|
children: Snippet;
|
|
20
20
|
open: boolean;
|
|
21
|
-
/** @deprecated use closedby instead */
|
|
22
|
-
closeOnEsc?: boolean;
|
|
23
|
-
/** @deprecated use closedby instead */
|
|
24
|
-
closeOnClick?: boolean;
|
|
25
|
-
/** @deprecated listen to `open` state changes instead of onEsc */
|
|
26
|
-
onEsc?: () => void;
|
|
27
|
-
/** @deprecated listen to `open` state changes instead of onClick */
|
|
28
|
-
onClick?: () => void;
|
|
29
21
|
} & HTMLDialogAttributes = $props();
|
|
30
22
|
|
|
31
23
|
let dialog: HTMLDialogElement | undefined = $state();
|
|
@@ -41,33 +33,16 @@
|
|
|
41
33
|
ontoggle={(e) => {
|
|
42
34
|
open = e.newState == "open";
|
|
43
35
|
}}
|
|
44
|
-
oncancel={(e) => {
|
|
45
|
-
if (e.target != e.currentTarget) return;
|
|
46
|
-
if (extra.closeOnEsc && extra.onEsc) {
|
|
47
|
-
extra.onEsc();
|
|
48
|
-
}
|
|
49
|
-
}}
|
|
50
|
-
onclick={(e) => {
|
|
51
|
-
if (e.target != e.currentTarget) return;
|
|
52
|
-
if (extra.closeOnClick && extra.onClick) {
|
|
53
|
-
extra.onClick();
|
|
54
|
-
}
|
|
55
|
-
}}
|
|
56
36
|
bind:this={dialog}
|
|
57
|
-
|
|
58
|
-
(extra.closeOnClick == false && extra.closeOnEsc == false
|
|
59
|
-
? "none"
|
|
60
|
-
: extra.closeOnClick == false
|
|
61
|
-
? "closerequest"
|
|
62
|
-
: "any")}
|
|
37
|
+
{closedby}
|
|
63
38
|
role="alertdialog"
|
|
64
39
|
{...extra}
|
|
65
40
|
>
|
|
66
41
|
{#if icon}
|
|
67
42
|
<Icon {icon} size={24} />
|
|
68
43
|
{/if}
|
|
69
|
-
<p class="headline
|
|
70
|
-
<div class="content
|
|
44
|
+
<p class="headline" class:center={icon}>{headline}</p>
|
|
45
|
+
<div class="content">
|
|
71
46
|
{@render children()}
|
|
72
47
|
</div>
|
|
73
48
|
<form method="dialog" class="buttons">
|
|
@@ -76,14 +51,16 @@
|
|
|
76
51
|
</dialog>
|
|
77
52
|
|
|
78
53
|
<style>
|
|
79
|
-
|
|
80
|
-
|
|
54
|
+
@layer tokens {
|
|
55
|
+
:root {
|
|
56
|
+
--m3-dialog-shape: var(--m3-shape-extra-large);
|
|
57
|
+
}
|
|
81
58
|
}
|
|
82
59
|
dialog {
|
|
83
60
|
display: flex;
|
|
84
61
|
flex-direction: column;
|
|
85
|
-
background-color:
|
|
86
|
-
--
|
|
62
|
+
background-color: var(--m3c-surface-container-high);
|
|
63
|
+
--m3v-background: var(--m3c-surface-container-high);
|
|
87
64
|
border: none;
|
|
88
65
|
border-radius: var(--m3-dialog-shape);
|
|
89
66
|
min-width: 17.5rem;
|
|
@@ -91,7 +68,7 @@
|
|
|
91
68
|
padding: 1.5rem;
|
|
92
69
|
overflow: auto;
|
|
93
70
|
> :global(svg) {
|
|
94
|
-
color:
|
|
71
|
+
color: var(--m3c-secondary);
|
|
95
72
|
|
|
96
73
|
flex-shrink: 0;
|
|
97
74
|
align-self: center;
|
|
@@ -99,7 +76,14 @@
|
|
|
99
76
|
}
|
|
100
77
|
}
|
|
101
78
|
.headline {
|
|
102
|
-
|
|
79
|
+
|
|
80
|
+
font-family: var(--m3-font);
|
|
81
|
+
font-size: 1.5rem;
|
|
82
|
+
line-height: 1.333;
|
|
83
|
+
letter-spacing: 0;
|
|
84
|
+
font-weight: 400;
|
|
85
|
+
|
|
86
|
+
color: var(--m3c-on-surface);
|
|
103
87
|
margin-top: 0;
|
|
104
88
|
margin-bottom: 1rem;
|
|
105
89
|
}
|
|
@@ -107,7 +91,14 @@
|
|
|
107
91
|
text-align: center;
|
|
108
92
|
}
|
|
109
93
|
.content {
|
|
110
|
-
|
|
94
|
+
|
|
95
|
+
font-family: var(--m3-font);
|
|
96
|
+
font-size: 0.875rem;
|
|
97
|
+
line-height: 1.429;
|
|
98
|
+
letter-spacing: 0.016rem;
|
|
99
|
+
font-weight: 400;
|
|
100
|
+
|
|
101
|
+
color: var(--m3c-on-surface-variant);
|
|
111
102
|
margin-bottom: 1.5rem;
|
|
112
103
|
}
|
|
113
104
|
.buttons {
|
|
@@ -123,31 +114,31 @@
|
|
|
123
114
|
visibility: hidden;
|
|
124
115
|
pointer-events: none;
|
|
125
116
|
transition:
|
|
126
|
-
opacity var(--m3-
|
|
127
|
-
visibility var(--m3-
|
|
117
|
+
opacity var(--m3-easing-fast),
|
|
118
|
+
visibility var(--m3-easing-fast);
|
|
128
119
|
}
|
|
129
120
|
dialog[open] {
|
|
130
121
|
opacity: 1;
|
|
131
122
|
visibility: visible;
|
|
132
123
|
pointer-events: auto;
|
|
133
124
|
animation:
|
|
134
|
-
dialogIn var(--m3-
|
|
135
|
-
opacity var(--m3-
|
|
125
|
+
dialogIn var(--m3-timing-function-emphasized-decel) 500ms,
|
|
126
|
+
opacity var(--m3-timing-function-emphasized-decel) 100ms backwards;
|
|
136
127
|
}
|
|
137
128
|
dialog[open] .headline {
|
|
138
|
-
animation: opacity var(--m3-
|
|
129
|
+
animation: opacity var(--m3-easing-fast);
|
|
139
130
|
}
|
|
140
131
|
dialog[open] .content {
|
|
141
|
-
animation: opacity var(--m3-
|
|
132
|
+
animation: opacity var(--m3-easing-fast) 50ms backwards;
|
|
142
133
|
}
|
|
143
134
|
dialog[open] .buttons {
|
|
144
135
|
animation:
|
|
145
|
-
buttonsIn var(--m3-
|
|
146
|
-
opacity var(--m3-
|
|
136
|
+
buttonsIn var(--m3-timing-function-emphasized-decel) 500ms,
|
|
137
|
+
opacity var(--m3-easing-fast) 100ms backwards;
|
|
147
138
|
}
|
|
148
139
|
dialog::backdrop {
|
|
149
|
-
background-color:
|
|
150
|
-
animation: opacity var(--m3-
|
|
140
|
+
background-color: oklab(from var(--m3c-scrim) l a b / 0.3);
|
|
141
|
+
animation: opacity var(--m3-timing-function-emphasized-decel) 500ms;
|
|
151
142
|
}
|
|
152
143
|
@keyframes dialogIn {
|
|
153
144
|
0% {
|
|
@@ -7,14 +7,6 @@ type $$ComponentProps = {
|
|
|
7
7
|
buttons: Snippet;
|
|
8
8
|
children: Snippet;
|
|
9
9
|
open: boolean;
|
|
10
|
-
/** @deprecated use closedby instead */
|
|
11
|
-
closeOnEsc?: boolean;
|
|
12
|
-
/** @deprecated use closedby instead */
|
|
13
|
-
closeOnClick?: boolean;
|
|
14
|
-
/** @deprecated listen to `open` state changes instead of onEsc */
|
|
15
|
-
onEsc?: () => void;
|
|
16
|
-
/** @deprecated listen to `open` state changes instead of onClick */
|
|
17
|
-
onClick?: () => void;
|
|
18
10
|
} & HTMLDialogAttributes;
|
|
19
11
|
declare const Dialog: import("svelte").Component<$$ComponentProps, {}, "open">;
|
|
20
12
|
type Dialog = ReturnType<typeof Dialog>;
|
|
@@ -37,15 +37,15 @@
|
|
|
37
37
|
<div class="body">
|
|
38
38
|
{#if overline}
|
|
39
39
|
<!-- Renamed to not conflict with Tailwind -->
|
|
40
|
-
<p class="overline-
|
|
40
|
+
<p class="overline-">{overline}</p>
|
|
41
41
|
{/if}
|
|
42
|
-
<p class="headline
|
|
42
|
+
<p class="headline">{headline}</p>
|
|
43
43
|
{#if supporting}
|
|
44
|
-
<p class="supporting
|
|
44
|
+
<p class="supporting">{supporting}</p>
|
|
45
45
|
{/if}
|
|
46
46
|
</div>
|
|
47
47
|
{#if trailing}
|
|
48
|
-
<div class="trailing
|
|
48
|
+
<div class="trailing">
|
|
49
49
|
{@render trailing()}
|
|
50
50
|
</div>
|
|
51
51
|
{/if}
|
|
@@ -93,13 +93,13 @@
|
|
|
93
93
|
cursor: pointer;
|
|
94
94
|
}
|
|
95
95
|
.lines-1 {
|
|
96
|
-
height: calc(3.5rem + var(--
|
|
96
|
+
height: calc(3.5rem + (var(--m3v-density) * 0.25rem));
|
|
97
97
|
}
|
|
98
98
|
.lines-2 {
|
|
99
|
-
height: calc(4.5rem + var(--
|
|
99
|
+
height: calc(4.5rem + (var(--m3v-density) * 0.25rem));
|
|
100
100
|
}
|
|
101
101
|
.lines-3 {
|
|
102
|
-
height: calc(5.5rem + var(--
|
|
102
|
+
height: calc(5.5rem + (var(--m3v-density) * 0.25rem));
|
|
103
103
|
padding-top: 0.75rem;
|
|
104
104
|
padding-bottom: 0.75rem;
|
|
105
105
|
align-items: flex-start;
|
|
@@ -110,7 +110,16 @@
|
|
|
110
110
|
.leading,
|
|
111
111
|
.trailing {
|
|
112
112
|
display: contents;
|
|
113
|
-
color:
|
|
113
|
+
color: var(--m3c-on-surface-variant);
|
|
114
|
+
}
|
|
115
|
+
.trailing {
|
|
116
|
+
|
|
117
|
+
font-family: var(--m3-font);
|
|
118
|
+
font-size: 0.688rem;
|
|
119
|
+
line-height: 1.455;
|
|
120
|
+
letter-spacing: 0.031rem;
|
|
121
|
+
font-weight: 500;
|
|
122
|
+
|
|
114
123
|
}
|
|
115
124
|
.leading > :global(svg),
|
|
116
125
|
.trailing > :global(svg) {
|
|
@@ -122,11 +131,34 @@
|
|
|
122
131
|
p {
|
|
123
132
|
margin: 0;
|
|
124
133
|
}
|
|
125
|
-
.supporting
|
|
134
|
+
.supporting {
|
|
135
|
+
|
|
136
|
+
font-family: var(--m3-font);
|
|
137
|
+
font-size: 0.875rem;
|
|
138
|
+
line-height: 1.429;
|
|
139
|
+
letter-spacing: 0.016rem;
|
|
140
|
+
font-weight: 400;
|
|
141
|
+
|
|
142
|
+
color: var(--m3c-on-surface-variant);
|
|
143
|
+
}
|
|
126
144
|
.overline- {
|
|
127
|
-
|
|
145
|
+
|
|
146
|
+
font-family: var(--m3-font);
|
|
147
|
+
font-size: 0.688rem;
|
|
148
|
+
line-height: 1.455;
|
|
149
|
+
letter-spacing: 0.031rem;
|
|
150
|
+
font-weight: 500;
|
|
151
|
+
|
|
152
|
+
color: var(--m3c-on-surface-variant);
|
|
128
153
|
}
|
|
129
154
|
.headline {
|
|
130
|
-
|
|
155
|
+
|
|
156
|
+
font-family: var(--m3-font);
|
|
157
|
+
font-size: 1rem;
|
|
158
|
+
line-height: 1.5;
|
|
159
|
+
letter-spacing: 0;
|
|
160
|
+
font-weight: 400;
|
|
161
|
+
|
|
162
|
+
color: var(--m3c-on-surface);
|
|
131
163
|
}
|
|
132
164
|
</style>
|
|
@@ -9,8 +9,10 @@
|
|
|
9
9
|
</div>
|
|
10
10
|
|
|
11
11
|
<style>
|
|
12
|
-
|
|
13
|
-
|
|
12
|
+
@layer tokens {
|
|
13
|
+
:root {
|
|
14
|
+
--m3-menu-shape: var(--m3-shape-extra-small);
|
|
15
|
+
}
|
|
14
16
|
}
|
|
15
17
|
.m3-container {
|
|
16
18
|
display: flex;
|
|
@@ -20,8 +22,8 @@
|
|
|
20
22
|
border-radius: var(--m3-menu-shape);
|
|
21
23
|
min-width: 7rem;
|
|
22
24
|
max-width: 17.5rem;
|
|
23
|
-
background-color:
|
|
25
|
+
background-color: var(--m3c-surface-container);
|
|
24
26
|
z-index: 2;
|
|
25
|
-
box-shadow: var(--m3-
|
|
27
|
+
box-shadow: var(--m3-elevation-2);
|
|
26
28
|
}
|
|
27
29
|
</style>
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
} = $props();
|
|
18
18
|
</script>
|
|
19
19
|
|
|
20
|
-
<button type="button" class="item focus-inset
|
|
20
|
+
<button type="button" class="item focus-inset" {disabled} {onclick}>
|
|
21
21
|
<Layer />
|
|
22
22
|
{#if icon == "space"}
|
|
23
23
|
<span class="icon"></span>
|
|
@@ -31,9 +31,16 @@
|
|
|
31
31
|
|
|
32
32
|
<style>
|
|
33
33
|
.item {
|
|
34
|
+
|
|
35
|
+
font-family: var(--m3-font);
|
|
36
|
+
font-size: 0.875rem;
|
|
37
|
+
line-height: 1.429;
|
|
38
|
+
letter-spacing: 0.006rem;
|
|
39
|
+
font-weight: 500;
|
|
40
|
+
|
|
34
41
|
display: flex;
|
|
35
42
|
align-items: center;
|
|
36
|
-
height: calc(3rem + var(--
|
|
43
|
+
height: calc(3rem + (var(--m3v-density) * 0.25rem));
|
|
37
44
|
padding: 0 0.75rem;
|
|
38
45
|
gap: 0.75rem;
|
|
39
46
|
white-space: nowrap;
|
|
@@ -41,7 +48,7 @@
|
|
|
41
48
|
border: none;
|
|
42
49
|
position: relative;
|
|
43
50
|
background-color: transparent;
|
|
44
|
-
color:
|
|
51
|
+
color: var(--m3c-on-surface);
|
|
45
52
|
|
|
46
53
|
cursor: pointer;
|
|
47
54
|
}
|
|
@@ -52,14 +59,14 @@
|
|
|
52
59
|
.icon > :global(svg) {
|
|
53
60
|
width: 1.5rem;
|
|
54
61
|
height: 1.5rem;
|
|
55
|
-
color:
|
|
62
|
+
color: var(--m3c-on-surface-variant);
|
|
56
63
|
}
|
|
57
64
|
|
|
58
65
|
.item:disabled {
|
|
59
|
-
color:
|
|
66
|
+
color: oklab(from var(--m3c-on-surface) l a b / 0.38);
|
|
60
67
|
cursor: auto;
|
|
61
68
|
}
|
|
62
69
|
.item:disabled > .icon > :global(svg) {
|
|
63
|
-
color:
|
|
70
|
+
color: oklab(from var(--m3c-on-surface) l a b / 0.38);
|
|
64
71
|
}
|
|
65
72
|
</style>
|
|
@@ -1,80 +1,70 @@
|
|
|
1
|
-
<!--
|
|
2
|
-
@component
|
|
3
|
-
@deprecated use NewSnackbar instead
|
|
4
|
-
-->
|
|
5
1
|
<script module lang="ts">
|
|
6
|
-
export
|
|
7
|
-
message: string
|
|
8
|
-
actions?: Record<string, () => void
|
|
9
|
-
closable?: boolean
|
|
2
|
+
export const snackbar = (
|
|
3
|
+
message: string,
|
|
4
|
+
actions?: Record<string, () => void>,
|
|
5
|
+
closable?: boolean,
|
|
10
6
|
/*
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
7
|
+
undefined/unset -> 4s timeout
|
|
8
|
+
2000 -> 2s timeout
|
|
9
|
+
-1 -> no timeout
|
|
14
10
|
*/
|
|
15
|
-
timeout?: number
|
|
11
|
+
timeout?: number,
|
|
12
|
+
) => {
|
|
13
|
+
_show(message, actions, closable, timeout);
|
|
16
14
|
};
|
|
15
|
+
let _show: typeof snackbar;
|
|
17
16
|
</script>
|
|
18
17
|
|
|
19
18
|
<script lang="ts">
|
|
20
|
-
import { onDestroy
|
|
19
|
+
import { onDestroy } from "svelte";
|
|
21
20
|
import { fade } from "svelte/transition";
|
|
22
21
|
import iconX from "@ktibow/iconset-material-symbols/close";
|
|
23
22
|
import Icon from "../misc/Icon.svelte";
|
|
24
23
|
import SnackbarItem from "./SnackbarItem.svelte";
|
|
25
24
|
import Layer from "../misc/Layer.svelte";
|
|
26
|
-
import type { DivAttrs } from "../misc/typing-utils";
|
|
27
25
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
}: {
|
|
35
|
-
config?: SnackbarConfig;
|
|
36
|
-
closeButtonTitle?: string;
|
|
37
|
-
} & DivAttrs = $props();
|
|
38
|
-
export const show = ({ message, actions = {}, closable = false, timeout = 4000 }: SnackbarIn) => {
|
|
39
|
-
snackbar = { message, actions, closable, timeout };
|
|
26
|
+
let { closeTitle = "Close" }: { closeTitle?: string } = $props();
|
|
27
|
+
let shown:
|
|
28
|
+
| { message: string; actions: Record<string, () => void>; closable: boolean }
|
|
29
|
+
| undefined = $state();
|
|
30
|
+
let timeoutId: number;
|
|
31
|
+
_show = (message, actions = {}, closable = false, timeout = 4000) => {
|
|
40
32
|
clearTimeout(timeoutId);
|
|
41
|
-
|
|
33
|
+
shown = { message, actions, closable };
|
|
34
|
+
if (timeout && timeout > 0)
|
|
42
35
|
timeoutId = setTimeout(() => {
|
|
43
|
-
|
|
36
|
+
shown = undefined;
|
|
44
37
|
}, timeout);
|
|
45
38
|
};
|
|
46
|
-
|
|
47
|
-
let snackbar: Required<SnackbarIn> | undefined = $state();
|
|
48
|
-
let timeoutId: number;
|
|
49
39
|
onDestroy(() => {
|
|
50
40
|
clearTimeout(timeoutId);
|
|
51
41
|
});
|
|
52
42
|
</script>
|
|
53
43
|
|
|
54
|
-
{#if
|
|
55
|
-
<div class="holder" out:fade={{ duration: 200 }}
|
|
56
|
-
{#key
|
|
57
|
-
<SnackbarItem
|
|
58
|
-
<p
|
|
59
|
-
{#each Object.entries(
|
|
44
|
+
{#if shown}
|
|
45
|
+
<div class="holder" out:fade={{ duration: 200 }}>
|
|
46
|
+
{#key shown}
|
|
47
|
+
<SnackbarItem>
|
|
48
|
+
<p>{shown.message}</p>
|
|
49
|
+
{#each Object.entries(shown.actions) as [key, action]}
|
|
60
50
|
<button
|
|
61
51
|
type="button"
|
|
62
|
-
class="action
|
|
52
|
+
class="action"
|
|
63
53
|
onclick={() => {
|
|
64
|
-
|
|
54
|
+
shown = undefined;
|
|
65
55
|
action();
|
|
66
56
|
}}
|
|
67
57
|
>
|
|
68
58
|
{key}
|
|
69
59
|
</button>
|
|
70
60
|
{/each}
|
|
71
|
-
{#if
|
|
61
|
+
{#if shown.closable}
|
|
72
62
|
<button
|
|
73
63
|
type="button"
|
|
74
64
|
class="close"
|
|
75
|
-
title={
|
|
65
|
+
title={closeTitle}
|
|
76
66
|
onclick={() => {
|
|
77
|
-
|
|
67
|
+
shown = undefined;
|
|
78
68
|
}}
|
|
79
69
|
>
|
|
80
70
|
<Layer />
|
|
@@ -90,12 +80,19 @@
|
|
|
90
80
|
.holder {
|
|
91
81
|
position: fixed;
|
|
92
82
|
padding-bottom: 1rem;
|
|
93
|
-
bottom: var(--
|
|
83
|
+
bottom: var(--m3v-bottom-offset);
|
|
94
84
|
left: 50%;
|
|
95
85
|
transform: translate(-50%, 0);
|
|
96
86
|
z-index: 3;
|
|
97
87
|
}
|
|
98
88
|
p {
|
|
89
|
+
|
|
90
|
+
font-family: var(--m3-font);
|
|
91
|
+
font-size: 0.875rem;
|
|
92
|
+
line-height: 1.429;
|
|
93
|
+
letter-spacing: 0.016rem;
|
|
94
|
+
font-weight: 400;
|
|
95
|
+
|
|
99
96
|
margin-right: auto;
|
|
100
97
|
}
|
|
101
98
|
button {
|
|
@@ -107,6 +104,7 @@
|
|
|
107
104
|
border: none;
|
|
108
105
|
|
|
109
106
|
background-color: transparent;
|
|
107
|
+
color: unset;
|
|
110
108
|
cursor: pointer;
|
|
111
109
|
position: relative;
|
|
112
110
|
}
|
|
@@ -116,11 +114,17 @@
|
|
|
116
114
|
}
|
|
117
115
|
|
|
118
116
|
.action {
|
|
119
|
-
|
|
117
|
+
|
|
118
|
+
font-family: var(--m3-font);
|
|
119
|
+
font-size: 0.875rem;
|
|
120
|
+
line-height: 1.429;
|
|
121
|
+
letter-spacing: 0.006rem;
|
|
122
|
+
font-weight: 500;
|
|
123
|
+
|
|
124
|
+
color: var(--m3c-inverse-primary);
|
|
120
125
|
padding: 0 0.5rem;
|
|
121
126
|
}
|
|
122
127
|
.close {
|
|
123
|
-
color: var(--m3-scheme-inverse-on-surface);
|
|
124
128
|
padding: 0 0.75rem;
|
|
125
129
|
margin-right: -1rem;
|
|
126
130
|
}
|
|
@@ -1,20 +1,7 @@
|
|
|
1
|
-
export
|
|
2
|
-
message: string;
|
|
3
|
-
actions?: Record<string, () => void>;
|
|
4
|
-
closable?: boolean;
|
|
5
|
-
timeout?: number | null;
|
|
6
|
-
};
|
|
7
|
-
import { type ComponentProps } from "svelte";
|
|
8
|
-
import SnackbarItem from "./SnackbarItem.svelte";
|
|
9
|
-
import type { DivAttrs } from "../misc/typing-utils";
|
|
10
|
-
type SnackbarConfig = Omit<ComponentProps<typeof SnackbarItem>, "children">;
|
|
1
|
+
export declare const snackbar: (message: string, actions?: Record<string, () => void>, closable?: boolean, timeout?: number) => void;
|
|
11
2
|
type $$ComponentProps = {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
}
|
|
15
|
-
/** @deprecated use NewSnackbar instead */
|
|
16
|
-
declare const Snackbar: import("svelte").Component<$$ComponentProps, {
|
|
17
|
-
show: ({ message, actions, closable, timeout }: SnackbarIn) => void;
|
|
18
|
-
}, "">;
|
|
3
|
+
closeTitle?: string;
|
|
4
|
+
};
|
|
5
|
+
declare const Snackbar: import("svelte").Component<$$ComponentProps, {}, "">;
|
|
19
6
|
type Snackbar = ReturnType<typeof Snackbar>;
|
|
20
7
|
export default Snackbar;
|
|
@@ -10,8 +10,10 @@
|
|
|
10
10
|
</div>
|
|
11
11
|
|
|
12
12
|
<style>
|
|
13
|
-
|
|
14
|
-
|
|
13
|
+
@layer tokens {
|
|
14
|
+
:root {
|
|
15
|
+
--m3-snackbar-shape: var(--m3-shape-extra-small);
|
|
16
|
+
}
|
|
15
17
|
}
|
|
16
18
|
.m3-container {
|
|
17
19
|
display: flex;
|
|
@@ -21,12 +23,12 @@
|
|
|
21
23
|
max-width: 60rem;
|
|
22
24
|
min-height: 3rem;
|
|
23
25
|
border-radius: var(--m3-snackbar-shape);
|
|
24
|
-
box-shadow: var(--m3-
|
|
25
|
-
background-color:
|
|
26
|
-
color:
|
|
26
|
+
box-shadow: var(--m3-elevation-3);
|
|
27
|
+
background-color: var(--m3c-inverse-surface);
|
|
28
|
+
color: var(--m3c-inverse-on-surface);
|
|
27
29
|
animation:
|
|
28
|
-
snackbarIn var(--m3-
|
|
29
|
-
opacity var(--m3-
|
|
30
|
+
snackbarIn var(--m3-timing-function-emphasized-decel) 500ms,
|
|
31
|
+
opacity var(--m3-timing-function-emphasized-decel) 100ms;
|
|
30
32
|
}
|
|
31
33
|
/*@TODO: Fix animation with different shaping or something*/
|
|
32
34
|
@keyframes snackbarIn {
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
|
|
18
18
|
<div class="m3-container">
|
|
19
19
|
<div class="header">
|
|
20
|
-
<span
|
|
20
|
+
<span>{headline}</span>
|
|
21
21
|
<Button variant="text" iconType="full" onclick={close}>
|
|
22
22
|
<Icon icon={iconX} />
|
|
23
23
|
</Button>
|
|
@@ -36,8 +36,17 @@
|
|
|
36
36
|
justify-content: space-between;
|
|
37
37
|
|
|
38
38
|
padding: 1.5rem;
|
|
39
|
+
}
|
|
40
|
+
.header > span {
|
|
41
|
+
|
|
42
|
+
font-family: var(--m3-font);
|
|
43
|
+
font-size: 1.375rem;
|
|
44
|
+
line-height: 1.273;
|
|
45
|
+
letter-spacing: 0;
|
|
46
|
+
font-weight: 400;
|
|
47
|
+
|
|
39
48
|
}
|
|
40
49
|
.header > :global(button.m3-container) {
|
|
41
|
-
color:
|
|
50
|
+
color: var(--m3c-on-surface-variant);
|
|
42
51
|
}
|
|
43
52
|
</style>
|