@skeletonlabs/skeleton 0.80.9 → 0.92.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/README.md +1 -1
- package/components/Accordion/AccordionGroup.svelte +1 -2
- package/components/Accordion/AccordionItem.svelte +6 -3
- package/components/Accordion/AccordionItem.svelte.d.ts +1 -0
- package/components/Alert/Alert.svelte +3 -3
- package/components/AppRail/AppRailTile.svelte +8 -6
- package/components/AppShell/AppShell.svelte +3 -3
- package/components/Breadcrumb/Crumb.svelte +3 -1
- package/components/Breadcrumb/Crumb.svelte.d.ts +5 -0
- package/components/ConicGradient/ConicGradient.svelte +2 -2
- package/components/ConicGradient/ConicGradient.svelte.d.ts +5 -0
- package/{tailwind/colors.d.ts → components/ConicGradient/settings.d.ts} +1 -1
- package/{tailwind/colors.js → components/ConicGradient/settings.js} +1 -1
- package/components/FileButton/FileButton.svelte +2 -2
- package/components/FileButton/FileButton.svelte.d.ts +3 -0
- package/components/FileDropzone/FileDropzone.svelte +5 -4
- package/components/FileDropzone/FileDropzone.svelte.d.ts +4 -0
- package/components/GradientHeading/GradientHeading.svelte +1 -1
- package/components/InputChip/InputChip.svelte +107 -0
- package/components/InputChip/InputChip.svelte.d.ts +29 -0
- package/components/ListBox/ListBoxItem.svelte +6 -5
- package/components/ListBox/ListBoxItem.svelte.d.ts +2 -0
- package/components/Paginator/Paginator.svelte +21 -9
- package/components/Paginator/Paginator.svelte.d.ts +5 -1
- package/components/ProgressBar/ProgressBar.svelte +6 -4
- package/components/ProgressBar/ProgressBar.svelte.d.ts +1 -0
- package/components/ProgressRadial/ProgressRadial.svelte +1 -1
- package/components/Radio/RadioGroup.svelte +2 -2
- package/components/Radio/RadioItem.svelte +3 -1
- package/components/Radio/RadioItem.svelte.d.ts +2 -0
- package/components/RangeSlider/RangeSlider.svelte +1 -1
- package/components/SlideToggle/SlideToggle.svelte +9 -6
- package/components/SlideToggle/SlideToggle.svelte.d.ts +4 -1
- package/components/Stepper/Step.svelte +52 -13
- package/components/Stepper/Step.svelte.d.ts +11 -3
- package/components/Stepper/Stepper.svelte +32 -10
- package/components/Stepper/Stepper.svelte.d.ts +8 -3
- package/components/SvgIcon/SvgIcon.svelte +1 -1
- package/components/SvgIcon/icons.js +2 -148
- package/components/Tab/Tab.svelte +16 -4
- package/components/Tab/Tab.svelte.d.ts +5 -0
- package/components/Table/Table.svelte +3 -3
- package/components/TableOfContents/TableOfContents.svelte +132 -0
- package/components/TableOfContents/TableOfContents.svelte.d.ts +32 -0
- package/index.d.ts +2 -0
- package/index.js +2 -0
- package/package.json +37 -29
- package/styles/all.css +0 -3
- package/styles/core.css +3 -0
- package/styles/elements/alerts.css +43 -0
- package/styles/elements/badges.css +12 -6
- package/styles/elements/breadcrumbs.css +27 -0
- package/styles/elements/buttons.css +34 -10
- package/styles/elements/cards.css +23 -4
- package/styles/elements/chips.css +58 -5
- package/styles/elements/lists.css +1 -1
- package/styles/elements/logo-clouds.css +1 -1
- package/styles/elements/menus.css +1 -1
- package/styles/elements/placeholders.css +1 -1
- package/styles/elements/tables.css +1 -1
- package/styles/elements/tooltips.css +1 -1
- package/styles/elements.css +2 -0
- package/styles/forms.css +59 -41
- package/styles/typography.css +6 -6
- package/tailwind/generated/allComponents.cjs +1 -0
- package/tailwind/generated/allComponents.d.cts +5552 -0
- package/tailwind/settings.cjs +20 -0
- package/tailwind/settings.d.cts +6 -0
- package/tailwind/skeleton.cjs +54 -0
- package/tailwind/skeleton.d.cts +5 -0
- package/tailwind/theme/colors.cjs +18 -0
- package/tailwind/theme/colors.d.cts +2 -0
- package/tailwind/tokens/backgrounds.cjs +40 -0
- package/tailwind/tokens/backgrounds.d.cts +2 -0
- package/tailwind/tokens/border-radius.cjs +21 -0
- package/tailwind/tokens/border-radius.d.cts +33 -0
- package/tailwind/tokens/borders.cjs +20 -0
- package/tailwind/tokens/borders.d.cts +6 -0
- package/tailwind/tokens/fills.cjs +20 -0
- package/tailwind/tokens/fills.d.cts +15 -0
- package/tailwind/tokens/rings.cjs +42 -0
- package/tailwind/tokens/rings.d.cts +17 -0
- package/tailwind/tokens/text.cjs +33 -0
- package/tailwind/tokens/text.d.cts +21 -0
- package/themes/theme-crimson.css +88 -64
- package/themes/theme-gold-nouveau.css +108 -115
- package/themes/theme-hamlindigo.css +97 -74
- package/themes/theme-modern.css +107 -64
- package/themes/theme-rocket.css +96 -63
- package/themes/theme-sahara.css +104 -65
- package/themes/theme-seafoam.css +100 -66
- package/themes/theme-seasonal.css +111 -65
- package/themes/theme-skeleton.css +99 -75
- package/themes/theme-vintage.css +102 -63
- package/utilities/CodeBlock/CodeBlock.svelte +6 -1
- package/utilities/CodeBlock/CodeBlock.svelte.d.ts +2 -0
- package/utilities/DataTable/DataTable.js +3 -1
- package/utilities/Drawer/Drawer.svelte +11 -10
- package/utilities/Drawer/Drawer.svelte.d.ts +1 -2
- package/utilities/Drawer/stores.d.ts +1 -1
- package/utilities/LightSwitch/LightSwitch.svelte +42 -14
- package/utilities/LightSwitch/LightSwitch.svelte.d.ts +5 -0
- package/utilities/LightSwitch/stores.d.ts +2 -3
- package/utilities/LocalStorageStore/LocalStorageStore.d.ts +3 -1
- package/utilities/LocalStorageStore/LocalStorageStore.js +9 -4
- package/utilities/Menu/menu.js +11 -7
- package/utilities/Modal/Modal.svelte +25 -12
- package/utilities/Modal/Modal.svelte.d.ts +2 -0
- package/utilities/Modal/types.d.ts +12 -2
- package/utilities/Toast/Toast.svelte +2 -2
- package/utilities/Toast/stores.js +17 -1
- package/utilities/Toast/types.d.ts +5 -0
- package/styles/tokens/backgrounds.css +0 -239
- package/styles/tokens/border-radius.css +0 -41
- package/styles/tokens/borders.css +0 -185
- package/styles/tokens/fills.css +0 -29
- package/styles/tokens/misc.css +0 -22
- package/styles/tokens/rings.css +0 -185
- package/styles/tokens/text.css +0 -216
- package/styles/tokens.css +0 -11
- package/tailwind/theme.cjs +0 -37
- package/tailwind/theme.d.cts +0 -5
package/themes/theme-vintage.css
CHANGED
|
@@ -5,75 +5,99 @@
|
|
|
5
5
|
|
|
6
6
|
:root {
|
|
7
7
|
/* =~= Theme Styles =~= */
|
|
8
|
-
--theme-border-base: 1px;
|
|
9
|
-
--theme-font-family-heading: 'Abril Fatface', cursive;
|
|
10
8
|
--theme-font-family-base: 'Noto Sans', sans-serif;
|
|
9
|
+
--theme-font-family-heading: 'Abril Fatface', cursive;
|
|
11
10
|
--theme-font-color-base: var(--color-primary-900);
|
|
12
11
|
--theme-font-color-dark: var(--color-primary-100);
|
|
13
12
|
--theme-rounded-base: 2px;
|
|
14
13
|
--theme-rounded-container: 4px;
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
--on-
|
|
18
|
-
--on-
|
|
19
|
-
--on-
|
|
20
|
-
--on-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
--
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
--color-primary-
|
|
27
|
-
--color-primary-
|
|
28
|
-
--color-primary-
|
|
29
|
-
--color-primary-
|
|
30
|
-
--color-primary-
|
|
31
|
-
--color-primary-
|
|
32
|
-
--color-primary-
|
|
33
|
-
/*
|
|
34
|
-
--color-
|
|
35
|
-
--color-
|
|
36
|
-
|
|
37
|
-
--color-
|
|
38
|
-
--color-
|
|
39
|
-
--color-
|
|
40
|
-
--color-
|
|
41
|
-
--color-
|
|
42
|
-
--color-
|
|
43
|
-
--color-
|
|
44
|
-
/*
|
|
45
|
-
--color-
|
|
46
|
-
--color-
|
|
47
|
-
|
|
48
|
-
--color-tertiary-
|
|
49
|
-
--color-tertiary-
|
|
14
|
+
--theme-border-base: 1px;
|
|
15
|
+
/* =~= Theme On-X Colors =~= */
|
|
16
|
+
--on-primary: 0 0 0;
|
|
17
|
+
--on-secondary: 0 0 0;
|
|
18
|
+
--on-tertiary: 0 0 0;
|
|
19
|
+
--on-success: 0 0 0;
|
|
20
|
+
--on-warning: 0 0 0;
|
|
21
|
+
--on-error: 0 0 0;
|
|
22
|
+
--on-surface: 255 255 255;
|
|
23
|
+
/* =~= Theme Colors =~= */
|
|
24
|
+
/* primary | #ea861a */
|
|
25
|
+
--color-primary-50: 252 237 221; /* ⬅ #fceddd */
|
|
26
|
+
--color-primary-100: 251 231 209; /* ⬅ #fbe7d1 */
|
|
27
|
+
--color-primary-200: 250 225 198; /* ⬅ #fae1c6 */
|
|
28
|
+
--color-primary-300: 247 207 163; /* ⬅ #f7cfa3 */
|
|
29
|
+
--color-primary-400: 240 170 95; /* ⬅ #f0aa5f */
|
|
30
|
+
--color-primary-500: 234 134 26; /* ⬅ #ea861a */
|
|
31
|
+
--color-primary-600: 211 121 23; /* ⬅ #d37917 */
|
|
32
|
+
--color-primary-700: 176 101 20; /* ⬅ #b06514 */
|
|
33
|
+
--color-primary-800: 140 80 16; /* ⬅ #8c5010 */
|
|
34
|
+
--color-primary-900: 115 66 13; /* ⬅ #73420d */
|
|
35
|
+
/* secondary | #97cea5 */
|
|
36
|
+
--color-secondary-50: 239 248 242; /* ⬅ #eff8f2 */
|
|
37
|
+
--color-secondary-100: 234 245 237; /* ⬅ #eaf5ed */
|
|
38
|
+
--color-secondary-200: 229 243 233; /* ⬅ #e5f3e9 */
|
|
39
|
+
--color-secondary-300: 213 235 219; /* ⬅ #d5ebdb */
|
|
40
|
+
--color-secondary-400: 182 221 192; /* ⬅ #b6ddc0 */
|
|
41
|
+
--color-secondary-500: 151 206 165; /* ⬅ #97cea5 */
|
|
42
|
+
--color-secondary-600: 136 185 149; /* ⬅ #88b995 */
|
|
43
|
+
--color-secondary-700: 113 155 124; /* ⬅ #719b7c */
|
|
44
|
+
--color-secondary-800: 91 124 99; /* ⬅ #5b7c63 */
|
|
45
|
+
--color-secondary-900: 74 101 81; /* ⬅ #4a6551 */
|
|
46
|
+
/* tertiary | #06b6d4 */
|
|
47
|
+
--color-tertiary-50: 218 244 249; /* ⬅ #daf4f9 */
|
|
48
|
+
--color-tertiary-100: 205 240 246; /* ⬅ #cdf0f6 */
|
|
49
|
+
--color-tertiary-200: 193 237 244; /* ⬅ #c1edf4 */
|
|
50
|
+
--color-tertiary-300: 155 226 238; /* ⬅ #9be2ee */
|
|
51
|
+
--color-tertiary-400: 81 204 225; /* ⬅ #51cce1 */
|
|
50
52
|
--color-tertiary-500: 6 182 212; /* ⬅ #06b6d4 */
|
|
51
|
-
--color-tertiary-600:
|
|
52
|
-
--color-tertiary-700:
|
|
53
|
-
--color-tertiary-800:
|
|
54
|
-
--color-tertiary-900:
|
|
55
|
-
/*
|
|
56
|
-
--color-
|
|
57
|
-
--color-
|
|
58
|
-
--color-
|
|
59
|
-
--color-
|
|
60
|
-
--color-
|
|
61
|
-
--color-
|
|
62
|
-
--color-
|
|
63
|
-
--color-
|
|
64
|
-
--color-
|
|
65
|
-
--color-
|
|
66
|
-
/*
|
|
67
|
-
--color-
|
|
68
|
-
--color-
|
|
69
|
-
--color-
|
|
70
|
-
--color-
|
|
71
|
-
--color-
|
|
72
|
-
--color-
|
|
73
|
-
--color-
|
|
74
|
-
--color-
|
|
75
|
-
--color-
|
|
76
|
-
--color-
|
|
53
|
+
--color-tertiary-600: 5 164 191; /* ⬅ #05a4bf */
|
|
54
|
+
--color-tertiary-700: 5 137 159; /* ⬅ #05899f */
|
|
55
|
+
--color-tertiary-800: 4 109 127; /* ⬅ #046d7f */
|
|
56
|
+
--color-tertiary-900: 3 89 104; /* ⬅ #035968 */
|
|
57
|
+
/* success | #84cb5d */
|
|
58
|
+
--color-success-50: 237 247 231; /* ⬅ #edf7e7 */
|
|
59
|
+
--color-success-100: 230 245 223; /* ⬅ #e6f5df */
|
|
60
|
+
--color-success-200: 224 242 215; /* ⬅ #e0f2d7 */
|
|
61
|
+
--color-success-300: 206 234 190; /* ⬅ #ceeabe */
|
|
62
|
+
--color-success-400: 169 219 142; /* ⬅ #a9db8e */
|
|
63
|
+
--color-success-500: 132 203 93; /* ⬅ #84cb5d */
|
|
64
|
+
--color-success-600: 119 183 84; /* ⬅ #77b754 */
|
|
65
|
+
--color-success-700: 99 152 70; /* ⬅ #639846 */
|
|
66
|
+
--color-success-800: 79 122 56; /* ⬅ #4f7a38 */
|
|
67
|
+
--color-success-900: 65 99 46; /* ⬅ #41632e */
|
|
68
|
+
/* warning | #f2ac23 */
|
|
69
|
+
--color-warning-50: 253 243 222; /* ⬅ #fdf3de */
|
|
70
|
+
--color-warning-100: 252 238 211; /* ⬅ #fceed3 */
|
|
71
|
+
--color-warning-200: 252 234 200; /* ⬅ #fceac8 */
|
|
72
|
+
--color-warning-300: 250 222 167; /* ⬅ #fadea7 */
|
|
73
|
+
--color-warning-400: 246 197 101; /* ⬅ #f6c565 */
|
|
74
|
+
--color-warning-500: 242 172 35; /* ⬅ #f2ac23 */
|
|
75
|
+
--color-warning-600: 218 155 32; /* ⬅ #da9b20 */
|
|
76
|
+
--color-warning-700: 182 129 26; /* ⬅ #b6811a */
|
|
77
|
+
--color-warning-800: 145 103 21; /* ⬅ #916715 */
|
|
78
|
+
--color-warning-900: 119 84 17; /* ⬅ #775411 */
|
|
79
|
+
/* error | #d57e78 */
|
|
80
|
+
--color-error-50: 249 236 235; /* ⬅ #f9eceb */
|
|
81
|
+
--color-error-100: 247 229 228; /* ⬅ #f7e5e4 */
|
|
82
|
+
--color-error-200: 245 223 221; /* ⬅ #f5dfdd */
|
|
83
|
+
--color-error-300: 238 203 201; /* ⬅ #eecbc9 */
|
|
84
|
+
--color-error-400: 226 165 161; /* ⬅ #e2a5a1 */
|
|
85
|
+
--color-error-500: 213 126 120; /* ⬅ #d57e78 */
|
|
86
|
+
--color-error-600: 192 113 108; /* ⬅ #c0716c */
|
|
87
|
+
--color-error-700: 160 95 90; /* ⬅ #a05f5a */
|
|
88
|
+
--color-error-800: 128 76 72; /* ⬅ #804c48 */
|
|
89
|
+
--color-error-900: 104 62 59; /* ⬅ #683e3b */
|
|
90
|
+
/* surface | #3f3731 */
|
|
91
|
+
--color-surface-50: 226 225 224; /* ⬅ #e2e1e0 */
|
|
92
|
+
--color-surface-100: 217 215 214; /* ⬅ #d9d7d6 */
|
|
93
|
+
--color-surface-200: 207 205 204; /* ⬅ #cfcdcc */
|
|
94
|
+
--color-surface-300: 178 175 173; /* ⬅ #b2afad */
|
|
95
|
+
--color-surface-400: 121 115 111; /* ⬅ #79736f */
|
|
96
|
+
--color-surface-500: 63 55 49; /* ⬅ #3f3731 */
|
|
97
|
+
--color-surface-600: 57 50 44; /* ⬅ #39322c */
|
|
98
|
+
--color-surface-700: 47 41 37; /* ⬅ #2f2925 */
|
|
99
|
+
--color-surface-800: 38 33 29; /* ⬅ #26211d */
|
|
100
|
+
--color-surface-900: 31 27 24; /* ⬅ #1f1b18 */
|
|
77
101
|
}
|
|
78
102
|
|
|
79
103
|
[data-theme='vintage'] h1,
|
|
@@ -84,3 +108,18 @@
|
|
|
84
108
|
[data-theme='vintage'] h6 {
|
|
85
109
|
letter-spacing: 1px;
|
|
86
110
|
}
|
|
111
|
+
|
|
112
|
+
/* Applied to body with `<body data-theme="vintage">` */
|
|
113
|
+
/* Created with: https://csshero.org/mesher/ */
|
|
114
|
+
[data-theme='vintage'] {
|
|
115
|
+
/* prettier-ignore */
|
|
116
|
+
background-image:
|
|
117
|
+
radial-gradient(at 100% 0%, hsla(135,34%,70%,0.20) 0px, transparent 50%),
|
|
118
|
+
radial-gradient(at 85% 100%, hsla(31,83%,50%,0.20) 0px, transparent 50%);
|
|
119
|
+
}
|
|
120
|
+
.dark [data-theme='vintage'] {
|
|
121
|
+
/* prettier-ignore */
|
|
122
|
+
background-image:
|
|
123
|
+
radial-gradient(at 100% 0%, hsla(135,34%,70%,0.14) 0px, transparent 50%),
|
|
124
|
+
radial-gradient(at 85% 100%, hsla(31,83%,50%,0.14) 0px, transparent 50%);
|
|
125
|
+
}
|
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
<script>import {
|
|
1
|
+
<script>import { createEventDispatcher } from 'svelte';
|
|
2
|
+
// Event Handler
|
|
3
|
+
const dispatch = createEventDispatcher();
|
|
4
|
+
import { storeHighlightJs } from './stores';
|
|
2
5
|
import { clipboard } from '../../actions/Clipboard/clipboard';
|
|
3
6
|
// Props
|
|
4
7
|
/** Sets a language alias for Highlight.js syntax highlighting. */
|
|
@@ -35,6 +38,8 @@ function onCopyClick() {
|
|
|
35
38
|
copyState = true;
|
|
36
39
|
// prettier-ignore
|
|
37
40
|
setTimeout(() => { copyState = false; }, 2000);
|
|
41
|
+
/** @event {{}} copy - Fires when the Copy button is pressed. */
|
|
42
|
+
dispatch('copy', {});
|
|
38
43
|
}
|
|
39
44
|
// Trigger syntax highlighting if highlight.js is available
|
|
40
45
|
$: if ($storeHighlightJs !== undefined) {
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
<script>import { fade, fly } from 'svelte/transition';
|
|
2
|
-
import { onMount } from 'svelte';
|
|
2
|
+
import { createEventDispatcher, onMount } from 'svelte';
|
|
3
|
+
// Event Handler
|
|
4
|
+
const dispatch = createEventDispatcher();
|
|
3
5
|
// Actions
|
|
4
6
|
import { focusTrap } from '../../actions/FocusTrap/focusTrap';
|
|
5
7
|
import { drawerStore } from './stores';
|
|
@@ -100,14 +102,16 @@ function percentage(percent, amount) {
|
|
|
100
102
|
return (amount / 100) * percent;
|
|
101
103
|
}
|
|
102
104
|
// Input Handlers
|
|
103
|
-
function
|
|
104
|
-
if (
|
|
105
|
+
function onBackdropInteraction(event) {
|
|
106
|
+
if (event.target === elemBackdrop)
|
|
105
107
|
drawerStore.close();
|
|
108
|
+
/** @event {{ event }} backdrop - Fires on backdrop interaction. */
|
|
109
|
+
dispatch('backdrop', event);
|
|
106
110
|
}
|
|
107
|
-
function onKeydownWindow(
|
|
111
|
+
function onKeydownWindow(event) {
|
|
108
112
|
if (!$drawerStore)
|
|
109
113
|
return;
|
|
110
|
-
if (
|
|
114
|
+
if (event.code === 'Escape')
|
|
111
115
|
drawerStore.close();
|
|
112
116
|
}
|
|
113
117
|
// Lifecycle
|
|
@@ -131,11 +135,8 @@ $: classesDrawer = `${cBaseDrawer} ${classesWidth} ${classesHeight} ${bgDrawer}
|
|
|
131
135
|
class="drawer-backdrop {classesBackdrop}"
|
|
132
136
|
data-testid="drawer-backdrop"
|
|
133
137
|
transition:fade|local={{ duration }}
|
|
134
|
-
on:
|
|
135
|
-
|
|
136
|
-
}}
|
|
137
|
-
on:keydown
|
|
138
|
-
on:keyup
|
|
138
|
+
on:mousedown={onBackdropInteraction}
|
|
139
|
+
on:touchstart={onBackdropInteraction}
|
|
139
140
|
on:keypress
|
|
140
141
|
use:focusTrap={true}
|
|
141
142
|
>
|
|
@@ -4,7 +4,7 @@ export declare const drawerStore: {
|
|
|
4
4
|
set: (this: void, value: DrawerSettings) => void;
|
|
5
5
|
update: (this: void, updater: import("svelte/store").Updater<DrawerSettings>) => void;
|
|
6
6
|
/** Open the drawer. */
|
|
7
|
-
open: (newSettings
|
|
7
|
+
open: (newSettings?: DrawerSettings) => void;
|
|
8
8
|
/** Close the drawer. */
|
|
9
9
|
close: () => void;
|
|
10
10
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
<!-- https://tailwindcss.com/docs/dark-mode -->
|
|
2
|
-
<script>import { onMount } from 'svelte';
|
|
3
|
-
//
|
|
4
|
-
|
|
2
|
+
<script>import { createEventDispatcher, onMount } from 'svelte';
|
|
3
|
+
// Event Handler
|
|
4
|
+
const dispatch = createEventDispatcher();
|
|
5
5
|
// Stores
|
|
6
6
|
import { storePrefersDarkScheme, storeLightSwitch } from './stores';
|
|
7
7
|
// Base Classes
|
|
@@ -12,38 +12,51 @@ const cIcon = 'block w-4 h-4';
|
|
|
12
12
|
function setPrefersDarkScheme() {
|
|
13
13
|
const prefersDark = window.matchMedia('(prefers-color-scheme: dark)').matches;
|
|
14
14
|
storePrefersDarkScheme.set(prefersDark);
|
|
15
|
-
}
|
|
16
|
-
// Toggles a 'dark' class on the <html> element
|
|
17
|
-
function setElemHtmlClass() {
|
|
18
|
-
const elemHtmlClassList = document.documentElement.classList;
|
|
19
15
|
// If $storeLightSwitch not set, match the OS preference
|
|
20
16
|
if ($storeLightSwitch === undefined) {
|
|
21
17
|
$storeLightSwitch = $storePrefersDarkScheme;
|
|
22
18
|
}
|
|
19
|
+
}
|
|
20
|
+
// Toggles a 'dark' class on the <html> element
|
|
21
|
+
function setElemHtmlClass() {
|
|
22
|
+
const elemHtmlClassList = document.documentElement.classList;
|
|
23
23
|
// Update HTML element class
|
|
24
|
-
$storeLightSwitch
|
|
24
|
+
$storeLightSwitch ? elemHtmlClassList.add('dark') : elemHtmlClassList.remove('dark');
|
|
25
|
+
}
|
|
26
|
+
// Sets the color scheme based on localStorage or OS preference in
|
|
27
|
+
// the <head> of the document.
|
|
28
|
+
function setColorScheme() {
|
|
29
|
+
if (localStorage.getItem('storeLightSwitch') === 'true' ||
|
|
30
|
+
(!('storeLightSwitch' in localStorage) && window.matchMedia('(prefers-color-scheme: dark)').matches)) {
|
|
31
|
+
document.documentElement.classList.add('dark');
|
|
32
|
+
}
|
|
33
|
+
else {
|
|
34
|
+
document.documentElement.classList.remove('dark');
|
|
35
|
+
}
|
|
25
36
|
}
|
|
26
37
|
// On Click Handler
|
|
27
|
-
function onClick() {
|
|
38
|
+
function onClick(event) {
|
|
28
39
|
// Set the Store Value
|
|
29
40
|
storeLightSwitch.set(($storeLightSwitch = !$storeLightSwitch));
|
|
30
41
|
// Apply to <html> Element
|
|
31
42
|
setElemHtmlClass();
|
|
43
|
+
/** @event {{ event }} click - Fires when the component is clicked. */
|
|
44
|
+
dispatch('click', event);
|
|
32
45
|
}
|
|
33
46
|
// A11y Input Handlers
|
|
34
47
|
function onKeyDown(event) {
|
|
35
48
|
// Enter/Space triggers selecton event
|
|
36
49
|
if (['Enter', 'Space'].includes(event.code)) {
|
|
37
50
|
event.preventDefault();
|
|
38
|
-
event.
|
|
51
|
+
event.currentTarget.click();
|
|
39
52
|
}
|
|
53
|
+
/** @event {{ event }} keydown - Fires when the component has keydown event. */
|
|
54
|
+
dispatch('keydown', event);
|
|
40
55
|
}
|
|
41
56
|
// Lifecycle
|
|
42
57
|
onMount(() => {
|
|
43
58
|
// Determine OS Preference
|
|
44
59
|
setPrefersDarkScheme();
|
|
45
|
-
// Finally, update HTML element class as needed
|
|
46
|
-
setElemHtmlClass();
|
|
47
60
|
});
|
|
48
61
|
// Reactive Classses
|
|
49
62
|
$: classesPosition = $storeLightSwitch ? 'translate-x-full' : 'translate-x-0';
|
|
@@ -51,11 +64,17 @@ $: classesBase = `${cTrack} ${$$props.class ?? ''}`;
|
|
|
51
64
|
$: classesThumb = `${cThumb} ${classesPosition}`;
|
|
52
65
|
</script>
|
|
53
66
|
|
|
67
|
+
<svelte:head>
|
|
68
|
+
{@html `<script>${setColorScheme.toString()} setColorScheme();</script>`}
|
|
69
|
+
</svelte:head>
|
|
70
|
+
|
|
54
71
|
<!-- prettier-ignore -->
|
|
55
72
|
<div
|
|
56
73
|
class="lightswitch {classesBase}"
|
|
57
74
|
on:click={onClick}
|
|
58
75
|
on:keydown={onKeyDown}
|
|
76
|
+
on:keyup
|
|
77
|
+
on:keypress
|
|
59
78
|
role="switch"
|
|
60
79
|
aria-label="Light Switch"
|
|
61
80
|
aria-checked={$storeLightSwitch}
|
|
@@ -64,7 +83,16 @@ $: classesThumb = `${cThumb} ${classesPosition}`;
|
|
|
64
83
|
>
|
|
65
84
|
<!-- Thumb -->
|
|
66
85
|
<div class="lightswitch-thumb {classesThumb}">
|
|
67
|
-
|
|
68
|
-
|
|
86
|
+
{#if $storeLightSwitch === false}
|
|
87
|
+
<!-- Icon Light -->
|
|
88
|
+
<svg class="lightswitch-icon fill-black {cIcon}" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512">
|
|
89
|
+
<path d="M361.5 1.2c5 2.1 8.6 6.6 9.6 11.9L391 121l107.9 19.8c5.3 1 9.8 4.6 11.9 9.6s1.5 10.7-1.6 15.2L446.9 256l62.3 90.3c3.1 4.5 3.7 10.2 1.6 15.2s-6.6 8.6-11.9 9.6L391 391 371.1 498.9c-1 5.3-4.6 9.8-9.6 11.9s-10.7 1.5-15.2-1.6L256 446.9l-90.3 62.3c-4.5 3.1-10.2 3.7-15.2 1.6s-8.6-6.6-9.6-11.9L121 391 13.1 371.1c-5.3-1-9.8-4.6-11.9-9.6s-1.5-10.7 1.6-15.2L65.1 256 2.8 165.7c-3.1-4.5-3.7-10.2-1.6-15.2s6.6-8.6 11.9-9.6L121 121 140.9 13.1c1-5.3 4.6-9.8 9.6-11.9s10.7-1.5 15.2 1.6L256 65.1 346.3 2.8c4.5-3.1 10.2-3.7 15.2-1.6zM352 256c0 53-43 96-96 96s-96-43-96-96s43-96 96-96s96 43 96 96zm32 0c0-70.7-57.3-128-128-128s-128 57.3-128 128s57.3 128 128 128s128-57.3 128-128z"/>
|
|
90
|
+
</svg>
|
|
91
|
+
{:else}
|
|
92
|
+
<!-- Icon Dark -->
|
|
93
|
+
<svg class="lightswitch-icon fill-white {cIcon}" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 384 512">
|
|
94
|
+
<path d="M223.5 32C100 32 0 132.3 0 256S100 480 223.5 480c60.6 0 115.5-24.2 155.8-63.4c5-4.9 6.3-12.5 3.1-18.7s-10.1-9.7-17-8.5c-9.8 1.7-19.8 2.6-30.1 2.6c-96.9 0-175.5-78.8-175.5-176c0-65.8 36-123.1 89.3-153.3c6.1-3.5 9.2-10.5 7.7-17.3s-7.3-11.9-14.3-12.5c-6.3-.5-12.6-.8-19-.8z"/>
|
|
95
|
+
</svg>
|
|
96
|
+
{/if}
|
|
69
97
|
</div>
|
|
70
98
|
</div>
|
|
@@ -1,3 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
export declare const
|
|
3
|
-
export declare const storeLightSwitch: Writable<boolean | undefined>;
|
|
1
|
+
export declare const storePrefersDarkScheme: import("svelte/store").Writable<boolean>;
|
|
2
|
+
export declare const storeLightSwitch: import("svelte/store").Writable<boolean | undefined>;
|
|
@@ -3,8 +3,10 @@ interface Serializer<T> {
|
|
|
3
3
|
parse(text: string): T;
|
|
4
4
|
stringify(object: T): string;
|
|
5
5
|
}
|
|
6
|
+
type StorageType = 'local' | 'session';
|
|
6
7
|
interface Options<T> {
|
|
7
|
-
serializer
|
|
8
|
+
serializer?: Serializer<T>;
|
|
9
|
+
storage?: StorageType;
|
|
8
10
|
}
|
|
9
11
|
export declare function localStorageStore<T>(key: string, initialValue: T, options?: Options<T>): Writable<T>;
|
|
10
12
|
export {};
|
|
@@ -2,18 +2,23 @@
|
|
|
2
2
|
// https://github.com/joshnuss/svelte-local-storage-store/blob/master/index.ts
|
|
3
3
|
// Represents version v0.3.1 (2022-08-21)
|
|
4
4
|
import { writable as internal, get } from 'svelte/store';
|
|
5
|
+
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
5
6
|
const stores = {};
|
|
7
|
+
function getStorage(type) {
|
|
8
|
+
return type === 'local' ? localStorage : sessionStorage;
|
|
9
|
+
}
|
|
6
10
|
export function localStorageStore(key, initialValue, options) {
|
|
7
|
-
const
|
|
8
|
-
const
|
|
11
|
+
const serializer = options?.serializer ?? JSON;
|
|
12
|
+
const storageType = options?.storage ?? 'local';
|
|
13
|
+
const browser = typeof window !== 'undefined' && typeof document !== 'undefined';
|
|
9
14
|
function updateStorage(key, value) {
|
|
10
15
|
if (!browser)
|
|
11
16
|
return;
|
|
12
|
-
|
|
17
|
+
getStorage(storageType).setItem(key, serializer.stringify(value));
|
|
13
18
|
}
|
|
14
19
|
if (!stores[key]) {
|
|
15
20
|
const store = internal(initialValue, (set) => {
|
|
16
|
-
const json = browser ?
|
|
21
|
+
const json = browser ? getStorage(storageType).getItem(key) : null;
|
|
17
22
|
if (json) {
|
|
18
23
|
set(serializer.parse(json));
|
|
19
24
|
}
|
package/utilities/Menu/menu.js
CHANGED
|
@@ -37,9 +37,9 @@ export function menu(node, args) {
|
|
|
37
37
|
args.state({ menu: args.menu, state });
|
|
38
38
|
};
|
|
39
39
|
// Click Handlers ---
|
|
40
|
-
const
|
|
40
|
+
const toggleMenu = () => {
|
|
41
41
|
// When the node is clicked, open the menu if it is closed, otherwise close it
|
|
42
|
-
if (elemMenu.style.display
|
|
42
|
+
if (elemMenu.style.display != 'block') {
|
|
43
43
|
autoUpdateOrigin();
|
|
44
44
|
menuOpen();
|
|
45
45
|
}
|
|
@@ -52,17 +52,23 @@ export function menu(node, args) {
|
|
|
52
52
|
};
|
|
53
53
|
// Interactive FALSE - any click closes the menu
|
|
54
54
|
const standardClickHandler = (event) => {
|
|
55
|
-
// Any click
|
|
55
|
+
// Any click outside the node closes the menu, but a click inside the node toggles the menu.
|
|
56
56
|
const outsideNode = node && !node.contains(event.target);
|
|
57
57
|
if (outsideNode) {
|
|
58
58
|
menuClose();
|
|
59
59
|
}
|
|
60
|
+
else {
|
|
61
|
+
toggleMenu();
|
|
62
|
+
}
|
|
60
63
|
};
|
|
61
64
|
// Interactive TRUE - clicks outside close menu
|
|
62
65
|
const interactiveClickHandler = (event) => {
|
|
63
66
|
const outsideNode = node && !node.contains(event.target);
|
|
64
67
|
const outsideMenu = elemMenu && !elemMenu.contains(event.target);
|
|
65
|
-
if (outsideNode
|
|
68
|
+
if (!outsideNode) {
|
|
69
|
+
toggleMenu();
|
|
70
|
+
}
|
|
71
|
+
else if (outsideNode && outsideMenu) {
|
|
66
72
|
menuClose();
|
|
67
73
|
}
|
|
68
74
|
};
|
|
@@ -85,7 +91,7 @@ export function menu(node, args) {
|
|
|
85
91
|
if (key === 'Enter' || key === 'Space') {
|
|
86
92
|
event.preventDefault();
|
|
87
93
|
// Toggle menu
|
|
88
|
-
|
|
94
|
+
toggleMenu();
|
|
89
95
|
}
|
|
90
96
|
};
|
|
91
97
|
const onWindowKeyDown = (event) => {
|
|
@@ -128,7 +134,6 @@ export function menu(node, args) {
|
|
|
128
134
|
window.addEventListener('click', onWindowClick, true);
|
|
129
135
|
window.addEventListener('keydown', onWindowKeyDown, true);
|
|
130
136
|
// Trigger Node Events
|
|
131
|
-
node.addEventListener('click', onTriggerClick);
|
|
132
137
|
node.addEventListener('keydown', onTriggerKeyDown);
|
|
133
138
|
node.addEventListener('change', (e) => {
|
|
134
139
|
console.log(e);
|
|
@@ -140,7 +145,6 @@ export function menu(node, args) {
|
|
|
140
145
|
window.removeEventListener('resize', onWindowClick, true);
|
|
141
146
|
window.removeEventListener('click', onWindowClick, true);
|
|
142
147
|
window.removeEventListener('keydown', onWindowKeyDown, true);
|
|
143
|
-
node.removeEventListener('click', onTriggerClick);
|
|
144
148
|
node.removeEventListener('keydown', onTriggerKeyDown);
|
|
145
149
|
}
|
|
146
150
|
};
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
<script>import {
|
|
2
|
-
|
|
1
|
+
<script>import { createEventDispatcher } from 'svelte';
|
|
2
|
+
import { fade, fly } from 'svelte/transition';
|
|
3
|
+
// Event Handler
|
|
4
|
+
const dispatch = createEventDispatcher();
|
|
3
5
|
import { focusTrap } from '../../actions/FocusTrap/focusTrap';
|
|
4
|
-
// Stores
|
|
5
6
|
import { modalStore } from './stores';
|
|
6
7
|
// Props
|
|
7
8
|
/** The open/close animation duration. Set '0' (zero) to disable. */
|
|
@@ -43,22 +44,34 @@ export let regionBody = 'max-h-[200px] overflow-hidden';
|
|
|
43
44
|
export let regionFooter = 'flex justify-end space-x-2';
|
|
44
45
|
// Base Styles
|
|
45
46
|
const cBackdrop = 'fixed top-0 left-0 right-0 bottom-0 z-[999] flex justify-center items-center p-4';
|
|
47
|
+
const cModal = 'max-h-full overflow-y-auto overflow-x-hidden';
|
|
46
48
|
const cModalImage = 'w-full h-auto';
|
|
47
49
|
// Local
|
|
48
50
|
let promptValue;
|
|
51
|
+
const buttonTextDefaults = {
|
|
52
|
+
buttonTextCancel,
|
|
53
|
+
buttonTextConfirm,
|
|
54
|
+
buttonTextSubmit
|
|
55
|
+
};
|
|
49
56
|
// Modal Store Subscription
|
|
50
57
|
modalStore.subscribe((dArr) => {
|
|
51
58
|
if (!dArr.length)
|
|
52
59
|
return;
|
|
53
|
-
// Set
|
|
60
|
+
// Set Prompt input value and type
|
|
54
61
|
promptValue = dArr[0].value;
|
|
62
|
+
// Override button text per instance, if available
|
|
63
|
+
buttonTextCancel = dArr[0].buttonTextCancel || buttonTextDefaults.buttonTextCancel;
|
|
64
|
+
buttonTextConfirm = dArr[0].buttonTextConfirm || buttonTextDefaults.buttonTextConfirm;
|
|
65
|
+
buttonTextSubmit = dArr[0].buttonTextSubmit || buttonTextDefaults.buttonTextSubmit;
|
|
55
66
|
});
|
|
56
67
|
// Event Handlers ---
|
|
57
|
-
function onBackdropInteraction(
|
|
58
|
-
if (!(
|
|
68
|
+
function onBackdropInteraction(event) {
|
|
69
|
+
if (!(event.target instanceof Element))
|
|
59
70
|
return;
|
|
60
|
-
if (
|
|
71
|
+
if (event.target.classList.contains('modal-backdrop'))
|
|
61
72
|
onClose();
|
|
73
|
+
/** @event {{ event }} backdrop - Fires on backdrop interaction. */
|
|
74
|
+
dispatch('backdrop', event);
|
|
62
75
|
}
|
|
63
76
|
function onClose() {
|
|
64
77
|
if ($modalStore[0].response)
|
|
@@ -84,7 +97,7 @@ function onKeyDown(event) {
|
|
|
84
97
|
}
|
|
85
98
|
// Reactive
|
|
86
99
|
$: classesBackdrop = `${cBackdrop} ${regionBackdrop} ${$$props.class || ''}`;
|
|
87
|
-
$: classesModal = `${background} ${width} ${height} ${padding} ${spacing} ${rounded} ${shadow}`;
|
|
100
|
+
$: classesModal = `${cModal} ${background} ${width} ${height} ${padding} ${spacing} ${rounded} ${shadow}`;
|
|
88
101
|
// IMPORTANT: add values to pass to the children templates.
|
|
89
102
|
// There is a way to self-reference component values, but it involes svelte-internal and is not yet stable.
|
|
90
103
|
// REPL: https://svelte.dev/repl/badd0f11aa99450ca69dca6690d4d5a4?version=3.52.0
|
|
@@ -119,7 +132,7 @@ $: parent = {
|
|
|
119
132
|
{#key $modalStore}
|
|
120
133
|
<!-- Backdrop -->
|
|
121
134
|
<div
|
|
122
|
-
class="modal-backdrop {classesBackdrop}"
|
|
135
|
+
class="modal-backdrop {classesBackdrop} {$modalStore[0].backdropClasses}"
|
|
123
136
|
on:mousedown={onBackdropInteraction}
|
|
124
137
|
on:touchstart={onBackdropInteraction}
|
|
125
138
|
transition:fade={{ duration }}
|
|
@@ -127,7 +140,7 @@ $: parent = {
|
|
|
127
140
|
>
|
|
128
141
|
<!-- Modal -->
|
|
129
142
|
<div
|
|
130
|
-
class="modal {classesModal} {$modalStore[0].
|
|
143
|
+
class="modal {classesModal} {$modalStore[0].modalClasses}"
|
|
131
144
|
transition:fly={{ duration, opacity: 0, y: 100 }}
|
|
132
145
|
use:focusTrap={true}
|
|
133
146
|
data-testid="modal"
|
|
@@ -163,11 +176,11 @@ $: parent = {
|
|
|
163
176
|
</footer>
|
|
164
177
|
{:else if $modalStore[0].type === 'prompt'}
|
|
165
178
|
<!-- Template: Prompt -->
|
|
166
|
-
<input class="modal-prompt-input" type="text" bind:value={promptValue}
|
|
179
|
+
<input class="modal-prompt-input" type="text" bind:value={promptValue} />
|
|
167
180
|
<!-- prettier-ignore -->
|
|
168
181
|
<footer class="modal-footer {regionFooter}">
|
|
169
182
|
<button class="btn {buttonNeutral}" on:click={onClose}>{buttonTextCancel}</button>
|
|
170
|
-
<button class="btn {buttonPositive}" on:click={onPromptSubmit}>{buttonTextSubmit}</button>
|
|
183
|
+
<button class="btn {buttonPositive}" on:click={onPromptSubmit} disabled={!promptValue}>{buttonTextSubmit}</button>
|
|
171
184
|
</footer>
|
|
172
185
|
{:else if $modalStore[0].type === 'component'}
|
|
173
186
|
<!-- Template: Component -->
|
|
@@ -21,6 +21,16 @@ export interface ModalSettings {
|
|
|
21
21
|
component?: ModalComponent;
|
|
22
22
|
/** Provide a function. Returns the repsonse value. */
|
|
23
23
|
response?: (r: any) => void;
|
|
24
|
-
/** Provide
|
|
25
|
-
|
|
24
|
+
/** Provide abitrary classes to the backdrop. */
|
|
25
|
+
backdropClasses?: string;
|
|
26
|
+
/** Provide abitrary classes to the modal window. */
|
|
27
|
+
modalClasses?: string;
|
|
28
|
+
/** Override the Cancel button label. */
|
|
29
|
+
buttonTextCancel?: string;
|
|
30
|
+
/** Override the Confirm button label. */
|
|
31
|
+
buttonTextConfirm?: string;
|
|
32
|
+
/** Override the Submit button label. */
|
|
33
|
+
buttonTextSubmit?: string;
|
|
34
|
+
/** Pass abitrary data per modal instance. */
|
|
35
|
+
meta?: any;
|
|
26
36
|
}
|