@skeletonlabs/skeleton 0.99.5 → 0.132.4
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 -2
- package/actions/Filters/filter.js +6 -9
- package/components/Accordion/Accordion.svelte +34 -0
- package/components/Accordion/Accordion.svelte.d.ts +41 -0
- package/components/Accordion/AccordionItem.svelte +84 -39
- package/components/Accordion/AccordionItem.svelte.d.ts +24 -7
- package/components/AppBar/AppBar.svelte +36 -21
- package/components/AppBar/AppBar.svelte.d.ts +20 -1
- package/components/AppRail/AppRail.svelte +3 -2
- package/components/AppRail/AppRail.svelte.d.ts +13 -1
- package/components/AppRail/AppRailTile.svelte +10 -7
- package/components/AppRail/AppRailTile.svelte.d.ts +10 -4
- package/components/AppShell/AppShell.svelte +3 -2
- package/components/AppShell/AppShell.svelte.d.ts +11 -0
- package/components/Avatar/Avatar.svelte +9 -9
- package/components/Avatar/Avatar.svelte.d.ts +16 -5
- package/components/ConicGradient/ConicGradient.svelte +18 -8
- package/components/ConicGradient/ConicGradient.svelte.d.ts +11 -0
- package/components/ConicGradient/settings.d.ts +1 -5
- package/components/ConicGradient/settings.js +1 -2
- package/components/FileButton/FileButton.svelte +8 -6
- package/components/FileButton/FileButton.svelte.d.ts +3 -1
- package/components/FileDropzone/FileDropzone.svelte +43 -63
- package/components/FileDropzone/FileDropzone.svelte.d.ts +24 -8
- package/components/InputChip/InputChip.svelte +97 -52
- package/components/InputChip/InputChip.svelte.d.ts +28 -4
- package/components/ListBox/ListBox.svelte +13 -29
- package/components/ListBox/ListBox.svelte.d.ts +11 -10
- package/components/ListBox/ListBoxItem.svelte +60 -50
- package/components/ListBox/ListBoxItem.svelte.d.ts +12 -7
- package/components/Paginator/Paginator.svelte +4 -4
- package/components/Paginator/Paginator.svelte.d.ts +13 -2
- package/components/ProgressBar/ProgressBar.svelte +17 -24
- package/components/ProgressBar/ProgressBar.svelte.d.ts +9 -1
- package/components/ProgressRadial/ProgressRadial.svelte +6 -8
- package/components/ProgressRadial/ProgressRadial.svelte.d.ts +9 -2
- package/components/Radio/RadioGroup.svelte +13 -16
- package/components/Radio/RadioGroup.svelte.d.ts +15 -7
- package/components/Radio/RadioItem.svelte +25 -21
- package/components/Radio/RadioItem.svelte.d.ts +12 -7
- package/components/RangeSlider/RangeSlider.svelte +9 -17
- package/components/RangeSlider/RangeSlider.svelte.d.ts +11 -2
- package/components/SlideToggle/SlideToggle.svelte +10 -9
- package/components/SlideToggle/SlideToggle.svelte.d.ts +11 -3
- package/components/Stepper/Step.svelte +64 -107
- package/components/Stepper/Step.svelte.d.ts +17 -18
- package/components/Stepper/Stepper.svelte +58 -37
- package/components/Stepper/Stepper.svelte.d.ts +28 -14
- package/components/Tab/Tab.svelte +40 -38
- package/components/Tab/Tab.svelte.d.ts +20 -14
- package/components/Tab/TabGroup.svelte +28 -41
- package/components/Tab/TabGroup.svelte.d.ts +25 -9
- package/components/Table/Table.svelte.d.ts +9 -0
- package/components/TableOfContents/TableOfContents.svelte +3 -2
- package/components/TableOfContents/TableOfContents.svelte.d.ts +12 -0
- package/index.d.ts +5 -4
- package/index.js +10 -4
- package/package.json +24 -16
- package/styles/all.css +0 -3
- package/styles/elements/breadcrumbs.css +3 -4
- package/styles/elements/buttons.css +2 -4
- package/styles/elements/forms.css +265 -0
- package/styles/elements/lists.css +1 -1
- package/styles/elements/modals.css +15 -0
- package/styles/elements/popups.css +16 -0
- package/styles/elements.css +3 -2
- package/styles/typography.css +5 -5
- package/styles/variants.css +7 -7
- package/tailwind/core.cjs +1 -1
- package/tailwind/generated/intellisense-classes.cjs +1 -1
- package/tailwind/generated/intellisense-classes.d.cts +318 -404
- package/tailwind/intellisense.cjs +2 -2
- package/tailwind/skeleton.cjs +1 -1
- package/types/index.d.ts +1 -0
- package/types/index.js +1 -0
- package/types/tailwind.d.ts +4 -0
- package/types/tailwind.js +2 -0
- package/utilities/CodeBlock/CodeBlock.svelte +14 -8
- package/utilities/CodeBlock/CodeBlock.svelte.d.ts +17 -1
- package/utilities/Drawer/Drawer.svelte +50 -37
- package/utilities/Drawer/Drawer.svelte.d.ts +20 -1
- package/utilities/Drawer/types.d.ts +8 -2
- package/utilities/LightSwitch/LightSwitch.svelte +43 -53
- package/utilities/LightSwitch/LightSwitch.svelte.d.ts +18 -2
- package/utilities/LightSwitch/lightswitch.d.ts +20 -0
- package/utilities/LightSwitch/lightswitch.js +71 -0
- package/utilities/LocalStorageStore/LocalStorageStore.js +1 -1
- package/utilities/Modal/Modal.svelte +96 -64
- package/utilities/Modal/Modal.svelte.d.ts +29 -0
- package/utilities/Modal/types.d.ts +9 -5
- package/utilities/Popup/popup.d.ts +7 -0
- package/utilities/Popup/popup.js +218 -0
- package/utilities/Popup/types.d.ts +32 -0
- package/utilities/Popup/types.js +3 -0
- package/utilities/Toast/Toast.svelte +17 -13
- package/utilities/Toast/Toast.svelte.d.ts +14 -0
- package/utilities/Toast/stores.js +9 -26
- package/utilities/Toast/types.d.ts +6 -1
- package/components/Accordion/AccordionGroup.svelte +0 -33
- package/components/Accordion/AccordionGroup.svelte.d.ts +0 -24
- package/components/SvgIcon/SvgIcon.svelte +0 -33
- package/components/SvgIcon/SvgIcon.svelte.d.ts +0 -26
- package/components/SvgIcon/icons.d.ts +0 -1
- package/components/SvgIcon/icons.js +0 -25
- package/styles/elements/menus.css +0 -29
- package/styles/elements/tooltips.css +0 -83
- package/styles/forms.css +0 -195
- package/utilities/LightSwitch/stores.d.ts +0 -2
- package/utilities/LightSwitch/stores.js +0 -5
- package/utilities/Menu/menu.d.ts +0 -18
- package/utilities/Menu/menu.js +0 -151
- package/utilities/Modal/examples/ModalExampleEmbed.svelte +0 -17
- package/utilities/Modal/examples/ModalExampleEmbed.svelte.d.ts +0 -17
- package/utilities/Modal/examples/ModalExampleForm.svelte +0 -41
- package/utilities/Modal/examples/ModalExampleForm.svelte.d.ts +0 -17
- package/utilities/Modal/examples/ModalExampleImage.svelte +0 -19
- package/utilities/Modal/examples/ModalExampleImage.svelte.d.ts +0 -16
- package/utilities/Modal/examples/ModalExampleList.svelte +0 -27
- package/utilities/Modal/examples/ModalExampleList.svelte.d.ts +0 -17
- package/utilities/Tooltip/tooltip.d.ts +0 -35
- package/utilities/Tooltip/tooltip.js +0 -94
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// The Skeleton Intellisense Tailwind Plugin
|
|
2
2
|
// Tailwind Docs: https://tailwindcss.com/docs/plugins
|
|
3
|
-
// Skeleton Docs: https://www.skeleton.dev/
|
|
3
|
+
// Skeleton Docs: https://www.skeleton.dev/docs/get-started
|
|
4
4
|
|
|
5
5
|
const plugin = require('tailwindcss/plugin');
|
|
6
6
|
|
|
@@ -16,6 +16,6 @@ module.exports = plugin(({ addComponents }) => {
|
|
|
16
16
|
respectImportant: true,
|
|
17
17
|
respectPrefix: true
|
|
18
18
|
});
|
|
19
|
-
} catch {}
|
|
19
|
+
} catch { }
|
|
20
20
|
}
|
|
21
21
|
});
|
package/tailwind/skeleton.cjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// The Skeleton Tailwind Plugin
|
|
2
2
|
// Tailwind Docs: https://tailwindcss.com/docs/plugins
|
|
3
|
-
// Skeleton Docs: https://www.skeleton.dev/
|
|
3
|
+
// Skeleton Docs: https://www.skeleton.dev/docs/get-started
|
|
4
4
|
|
|
5
5
|
const intellisensePlugin = require('./intellisense.cjs');
|
|
6
6
|
const corePlugin = require('./core.cjs');
|
package/types/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './tailwind';
|
package/types/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './tailwind';
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export declare const tailwindNumbers: readonly ["50", "100", "200", "300", "400", "500", "600", "700", "800", "900"];
|
|
2
|
+
export type TailwindNumbers = (typeof tailwindNumbers)[number];
|
|
3
|
+
export declare const semanticNames: readonly ["primary", "secondary", "tertiary", "success", "warning"];
|
|
4
|
+
export type SemanticNames = (typeof semanticNames)[number];
|
|
@@ -4,13 +4,17 @@ import { storeHighlightJs } from "./stores";
|
|
|
4
4
|
import { clipboard } from "../../actions/Clipboard/clipboard";
|
|
5
5
|
export let language = "plaintext";
|
|
6
6
|
export let code = "";
|
|
7
|
-
export let background = "bg-
|
|
7
|
+
export let background = "bg-neutral-900/90";
|
|
8
|
+
export let blur = "";
|
|
8
9
|
export let text = "text-sm";
|
|
9
10
|
export let color = "text-white";
|
|
10
11
|
export let rounded = "rounded-container-token";
|
|
11
|
-
export let
|
|
12
|
+
export let shadow = "shadow";
|
|
13
|
+
export let button = "btn btn-sm variant-soft !text-white";
|
|
14
|
+
export let buttonLabel = "Copy";
|
|
15
|
+
export let buttonCopied = "\u{1F44D}";
|
|
12
16
|
const cBase = "overflow-hidden shadow";
|
|
13
|
-
const cHeader = "text-xs uppercase flex justify-between items-center p-2 pl-4";
|
|
17
|
+
const cHeader = "text-xs text-white/50 uppercase flex justify-between items-center p-2 pl-4";
|
|
14
18
|
const cPre = "whitespace-pre-wrap break-all p-4 pt-1";
|
|
15
19
|
let formatted = false;
|
|
16
20
|
let displayCode = code;
|
|
@@ -18,6 +22,8 @@ let copyState = false;
|
|
|
18
22
|
function languageFormatter(lang) {
|
|
19
23
|
if (lang === "js")
|
|
20
24
|
return "javascript";
|
|
25
|
+
if (lang === "ts")
|
|
26
|
+
return "typescript";
|
|
21
27
|
return lang;
|
|
22
28
|
}
|
|
23
29
|
function onCopyClick() {
|
|
@@ -33,19 +39,19 @@ $:
|
|
|
33
39
|
formatted = true;
|
|
34
40
|
}
|
|
35
41
|
$:
|
|
36
|
-
classesBase = `${cBase} ${background} ${text} ${color} ${rounded} ${$$props.class ?? ""}`;
|
|
42
|
+
classesBase = `${cBase} ${background} ${blur} ${text} ${color} ${rounded} ${shadow} ${$$props.class ?? ""}`;
|
|
37
43
|
</script>
|
|
38
44
|
|
|
39
45
|
<!-- prettier-ignore -->
|
|
40
46
|
{#if language && code}
|
|
41
47
|
<div class="code-block {classesBase}" data-testid="code-block">
|
|
42
48
|
<!-- Header -->
|
|
43
|
-
<header class="code-block-header {cHeader}
|
|
49
|
+
<header class="code-block-header {cHeader}">
|
|
44
50
|
<!-- Language -->
|
|
45
|
-
<span class="code-block-language
|
|
51
|
+
<span class="code-block-language">{languageFormatter(language)}</span>
|
|
46
52
|
<!-- Copy Button -->
|
|
47
|
-
<button class="code-block-btn
|
|
48
|
-
{!copyState ?
|
|
53
|
+
<button class="code-block-btn {button}" on:click={onCopyClick} use:clipboard={code}>
|
|
54
|
+
{!copyState ? buttonLabel : buttonCopied}
|
|
49
55
|
</button>
|
|
50
56
|
</header>
|
|
51
57
|
<!-- Pre/Code -->
|
|
@@ -2,15 +2,31 @@ import { SvelteComponentTyped } from "svelte";
|
|
|
2
2
|
declare const __propDef: {
|
|
3
3
|
props: {
|
|
4
4
|
[x: string]: any;
|
|
5
|
+
/** Sets a language alias for Highlight.js syntax highlighting.*/
|
|
5
6
|
language?: string | undefined;
|
|
7
|
+
/** Provide the code to render. Be mindful to escape as needed!*/
|
|
6
8
|
code?: string | undefined;
|
|
9
|
+
/** Provided classes to set the background color.*/
|
|
7
10
|
background?: string | undefined;
|
|
11
|
+
/** Provided classes to set the backdrop blur.*/
|
|
12
|
+
blur?: string | undefined;
|
|
13
|
+
/** Provided classes to set the text size.*/
|
|
8
14
|
text?: string | undefined;
|
|
15
|
+
/** Provided classes to set the text color.*/
|
|
9
16
|
color?: string | undefined;
|
|
17
|
+
/** Provided classes to set the border radius.*/
|
|
10
18
|
rounded?: string | undefined;
|
|
11
|
-
|
|
19
|
+
/** Provided classes to set the box shadow.*/
|
|
20
|
+
shadow?: string | undefined;
|
|
21
|
+
/** Provided classes to set the button styles.*/
|
|
22
|
+
button?: string | undefined;
|
|
23
|
+
/** Provided the button label text.*/
|
|
24
|
+
buttonLabel?: string | undefined;
|
|
25
|
+
/** Provided the button label text when copied.*/
|
|
26
|
+
buttonCopied?: string | undefined;
|
|
12
27
|
};
|
|
13
28
|
events: {
|
|
29
|
+
/** {{}} copy - Fires when the Copy button is pressed.*/
|
|
14
30
|
copy: CustomEvent<any>;
|
|
15
31
|
} & {
|
|
16
32
|
[evt: string]: CustomEvent<any>;
|
|
@@ -7,77 +7,83 @@ export let position = "left";
|
|
|
7
7
|
export let duration = 150;
|
|
8
8
|
export let bgBackdrop = "bg-surface-backdrop-token";
|
|
9
9
|
export let blur = "backdrop-blur-xs";
|
|
10
|
+
export let padding = "";
|
|
10
11
|
export let bgDrawer = "bg-surface-100-800-token";
|
|
11
12
|
export let border = "";
|
|
12
13
|
export let rounded = "";
|
|
14
|
+
export let shadow = "shadow-xl";
|
|
13
15
|
export let width = "";
|
|
14
16
|
export let height = "";
|
|
15
|
-
export let
|
|
17
|
+
export let regionBackdrop = "";
|
|
18
|
+
export let regionDrawer = "";
|
|
16
19
|
export let labelledby = "";
|
|
17
20
|
export let describedby = "";
|
|
18
|
-
const
|
|
19
|
-
|
|
21
|
+
const presets = {
|
|
22
|
+
top: { alignment: "items-start", width: "w-full", height: "h-[50%]", rounded: "rounded-bl-container-token rounded-br-container-token" },
|
|
23
|
+
bottom: { alignment: "items-end", width: "w-full", height: " h-[50%]", rounded: "rounded-tl-container-token rounded-tr-container-token" },
|
|
24
|
+
left: { alignment: "justify-start", width: "w-[90%]", height: "h-full", rounded: "rounded-tr-container-token rounded-br-container-token" },
|
|
25
|
+
right: { alignment: "justify-end", width: "w-[90%]", height: "h-full", rounded: "rounded-tl-container-token rounded-bl-container-token" }
|
|
26
|
+
};
|
|
27
|
+
const cBackdrop = "fixed top-0 left-0 right-0 bottom-0 z-40 flex";
|
|
28
|
+
const cDrawer = "ox-border overflow-y-auto transition-transform";
|
|
20
29
|
let elemBackdrop;
|
|
21
|
-
let
|
|
22
|
-
let
|
|
23
|
-
let animSettings = { x: 0, y: 0 };
|
|
30
|
+
let elemDrawer;
|
|
31
|
+
let anim = { x: 0, y: 0 };
|
|
24
32
|
const propDefaults = {
|
|
25
33
|
position,
|
|
26
34
|
duration,
|
|
27
35
|
bgBackdrop,
|
|
28
36
|
blur,
|
|
37
|
+
padding,
|
|
29
38
|
bgDrawer,
|
|
30
39
|
border,
|
|
31
40
|
rounded,
|
|
41
|
+
shadow,
|
|
32
42
|
width,
|
|
33
43
|
height,
|
|
34
|
-
margin,
|
|
35
44
|
labelledby,
|
|
36
|
-
describedby
|
|
45
|
+
describedby,
|
|
46
|
+
regionBackdrop,
|
|
47
|
+
regionDrawer
|
|
37
48
|
};
|
|
38
|
-
|
|
39
|
-
if (settings.open === false)
|
|
40
|
-
return;
|
|
41
|
-
applySettings(settings);
|
|
42
|
-
setPosition();
|
|
43
|
-
});
|
|
44
|
-
function applySettings(settings) {
|
|
49
|
+
function applyPropSettings(settings) {
|
|
45
50
|
position = settings.position || propDefaults.position;
|
|
46
51
|
duration = settings.duration || propDefaults.duration;
|
|
47
52
|
bgBackdrop = settings.bgBackdrop || propDefaults.bgBackdrop;
|
|
48
53
|
blur = settings.blur || propDefaults.blur;
|
|
54
|
+
padding = settings.padding || propDefaults.padding;
|
|
49
55
|
bgDrawer = settings.bgDrawer || propDefaults.bgDrawer;
|
|
50
56
|
border = settings.border || propDefaults.border;
|
|
51
57
|
rounded = settings.rounded || propDefaults.rounded;
|
|
58
|
+
shadow = settings.shadow || propDefaults.shadow;
|
|
52
59
|
width = settings.width || propDefaults.width;
|
|
53
60
|
height = settings.height || propDefaults.height;
|
|
54
|
-
|
|
61
|
+
regionBackdrop = settings.regionBackdrop || propDefaults.regionBackdrop;
|
|
62
|
+
regionDrawer = settings.regionDrawer || propDefaults.regionDrawer;
|
|
55
63
|
labelledby = settings.labelledby || propDefaults.labelledby;
|
|
56
64
|
describedby = settings.describedby || propDefaults.describedby;
|
|
57
65
|
}
|
|
58
|
-
function
|
|
66
|
+
function applyAnimationSettings() {
|
|
67
|
+
if (window === void 0)
|
|
68
|
+
return;
|
|
59
69
|
switch (position) {
|
|
60
70
|
case "top":
|
|
61
|
-
|
|
62
|
-
animSettings = { x: 0, y: -percentage(40, windowSettings.height) };
|
|
71
|
+
anim = { x: 0, y: -window.innerWidth };
|
|
63
72
|
break;
|
|
64
73
|
case "bottom":
|
|
65
|
-
|
|
66
|
-
|
|
74
|
+
anim = { x: 0, y: window.innerWidth };
|
|
75
|
+
break;
|
|
76
|
+
case "left":
|
|
77
|
+
anim = { x: -window.innerHeight, y: 0 };
|
|
67
78
|
break;
|
|
68
79
|
case "right":
|
|
69
|
-
|
|
70
|
-
animSettings = { x: percentage(90, windowSettings.width), y: 0 };
|
|
80
|
+
anim = { x: window.innerHeight, y: 0 };
|
|
71
81
|
break;
|
|
72
82
|
default:
|
|
73
|
-
|
|
74
|
-
animSettings = { x: -percentage(90, windowSettings.width), y: 0 };
|
|
83
|
+
console.error("Error: unknown position property value.");
|
|
75
84
|
break;
|
|
76
85
|
}
|
|
77
86
|
}
|
|
78
|
-
function percentage(percent, amount) {
|
|
79
|
-
return amount / 100 * percent;
|
|
80
|
-
}
|
|
81
87
|
function onBackdropInteraction(event) {
|
|
82
88
|
if (event.target === elemBackdrop)
|
|
83
89
|
drawerStore.close();
|
|
@@ -89,18 +95,24 @@ function onKeydownWindow(event) {
|
|
|
89
95
|
if (event.code === "Escape")
|
|
90
96
|
drawerStore.close();
|
|
91
97
|
}
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
98
|
+
drawerStore.subscribe((settings) => {
|
|
99
|
+
if (settings.open !== true)
|
|
100
|
+
return;
|
|
101
|
+
applyPropSettings(settings);
|
|
102
|
+
applyAnimationSettings();
|
|
95
103
|
});
|
|
96
104
|
$:
|
|
97
|
-
|
|
105
|
+
classesPosition = presets[position].alignment;
|
|
106
|
+
$:
|
|
107
|
+
classesWidth = width ? width : presets[position].width;
|
|
98
108
|
$:
|
|
99
|
-
classesHeight = height ? height :
|
|
109
|
+
classesHeight = height ? height : presets[position].height;
|
|
100
110
|
$:
|
|
101
|
-
|
|
111
|
+
classesRounded = rounded ? rounded : presets[position].rounded;
|
|
102
112
|
$:
|
|
103
|
-
|
|
113
|
+
classesBackdrop = `${cBackdrop} ${bgBackdrop} ${padding} ${blur} ${classesPosition} ${regionBackdrop} ${$$props.class ?? ""}`;
|
|
114
|
+
$:
|
|
115
|
+
classesDrawer = `${cDrawer} ${bgDrawer} ${border} ${rounded} ${shadow} ${classesWidth} ${classesHeight} ${classesRounded} ${regionDrawer}`;
|
|
104
116
|
</script>
|
|
105
117
|
|
|
106
118
|
<svelte:window on:keydown={onKeydownWindow} />
|
|
@@ -111,21 +123,22 @@ $:
|
|
|
111
123
|
bind:this={elemBackdrop}
|
|
112
124
|
class="drawer-backdrop {classesBackdrop}"
|
|
113
125
|
data-testid="drawer-backdrop"
|
|
114
|
-
transition:fade|local={{ duration }}
|
|
115
126
|
on:mousedown={onBackdropInteraction}
|
|
116
127
|
on:touchstart={onBackdropInteraction}
|
|
117
128
|
on:keypress
|
|
129
|
+
transition:fade|local={{ duration }}
|
|
118
130
|
use:focusTrap={true}
|
|
119
131
|
>
|
|
120
132
|
<!-- Drawer -->
|
|
121
133
|
<div
|
|
134
|
+
bind:this={elemDrawer}
|
|
122
135
|
class="drawer {classesDrawer}"
|
|
123
136
|
data-testid="drawer"
|
|
124
|
-
transition:fly|local={{ x: animSettings.x, y: animSettings.y, duration }}
|
|
125
137
|
role="dialog"
|
|
126
138
|
aria-modal="true"
|
|
127
139
|
aria-labelledby={labelledby}
|
|
128
140
|
aria-describedby={describedby}
|
|
141
|
+
transition:fly|local={{ x: anim.x, y: anim.y, duration }}
|
|
129
142
|
>
|
|
130
143
|
<!-- Slot: Default -->
|
|
131
144
|
<slot />
|
|
@@ -2,21 +2,40 @@ import { SvelteComponentTyped } from "svelte";
|
|
|
2
2
|
declare const __propDef: {
|
|
3
3
|
props: {
|
|
4
4
|
[x: string]: any;
|
|
5
|
+
/** Set the anchor position.*/
|
|
5
6
|
position?: "left" | "top" | "right" | "bottom" | undefined;
|
|
7
|
+
/** Define the Svelte transition animation duration.*/
|
|
6
8
|
duration?: number | undefined;
|
|
9
|
+
/** Backdrop - Provide classes to set the backdrop background color*/
|
|
7
10
|
bgBackdrop?: string | undefined;
|
|
11
|
+
/** Backdrop - Provide classes to set the blur style.*/
|
|
8
12
|
blur?: string | undefined;
|
|
13
|
+
/** Drawer - Provide classes to set padding.*/
|
|
14
|
+
padding?: string | undefined;
|
|
15
|
+
/** Drawer - Provide classes to set the drawer background color.*/
|
|
9
16
|
bgDrawer?: string | undefined;
|
|
17
|
+
/** Drawer - Provide classes to set border color.*/
|
|
10
18
|
border?: string | undefined;
|
|
19
|
+
/** Drawer - Provide classes to set border radius.*/
|
|
11
20
|
rounded?: string | undefined;
|
|
21
|
+
/** Drawer - Provide classes to set the box shadow.*/
|
|
22
|
+
shadow?: string | undefined;
|
|
23
|
+
/** Drawer - Provide classes to override the width.*/
|
|
12
24
|
width?: string | undefined;
|
|
25
|
+
/** Drawer - Provide classes to override the height.*/
|
|
13
26
|
height?: string | undefined;
|
|
14
|
-
|
|
27
|
+
/** Provide abitrary classes to the backdrop region.*/
|
|
28
|
+
regionBackdrop?: string | undefined;
|
|
29
|
+
/** Provide abitrary classes to the drawer region.*/
|
|
30
|
+
regionDrawer?: string | undefined;
|
|
31
|
+
/** Provide an ID of the element labeling the drawer.*/
|
|
15
32
|
labelledby?: string | undefined;
|
|
33
|
+
/** Provide an ID of the element describing the drawer.*/
|
|
16
34
|
describedby?: string | undefined;
|
|
17
35
|
};
|
|
18
36
|
events: {
|
|
19
37
|
keypress: KeyboardEvent;
|
|
38
|
+
/** {{ event }} backdrop - Fires on backdrop interaction.*/
|
|
20
39
|
backdrop: CustomEvent<any>;
|
|
21
40
|
} & {
|
|
22
41
|
[evt: string]: CustomEvent<any>;
|
|
@@ -14,18 +14,24 @@ export interface DrawerSettings {
|
|
|
14
14
|
bgBackdrop?: string;
|
|
15
15
|
/** Backdrop - Provide classes to set the blur style.*/
|
|
16
16
|
blur?: string;
|
|
17
|
+
/** Drawer - Provide classes to set padding.*/
|
|
18
|
+
padding?: string;
|
|
17
19
|
/** Drawer - Provide classes to set the drawer background color.*/
|
|
18
20
|
bgDrawer?: string;
|
|
19
21
|
/** Drawer - Provide classes to set border color.*/
|
|
20
22
|
border?: string;
|
|
21
23
|
/** Drawer - Provide classes to set border radius.*/
|
|
22
24
|
rounded?: string;
|
|
25
|
+
/** Drawer - Provide classes to set box shadow.*/
|
|
26
|
+
shadow?: string;
|
|
23
27
|
/** Drawer - Provide classes to override the width.*/
|
|
24
28
|
width?: string;
|
|
25
29
|
/** Drawer - Provide classes to override the height.*/
|
|
26
30
|
height?: string;
|
|
27
|
-
/**
|
|
28
|
-
|
|
31
|
+
/** Provide abitrary classes to the backdrop region. */
|
|
32
|
+
regionBackdrop?: string;
|
|
33
|
+
/** Provide abitrary classes to the drawer region. */
|
|
34
|
+
regionDrawer?: string;
|
|
29
35
|
/** Provide an ID of the element labeling the drawer.*/
|
|
30
36
|
labelledby?: string;
|
|
31
37
|
/** Provide an ID of the element describing the drawer.*/
|
|
@@ -1,80 +1,70 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
} else {
|
|
23
|
-
document.documentElement.classList.remove("dark");
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
function onClick(event) {
|
|
27
|
-
storeLightSwitch.set($storeLightSwitch = !$storeLightSwitch);
|
|
28
|
-
setElemHtmlClass();
|
|
29
|
-
dispatch("click", event);
|
|
1
|
+
<script>import { modeCurrent, setModeUserPrefers, setModeCurrent, setInitialClassState } from "./lightswitch";
|
|
2
|
+
export let bgLight = "bg-surface-50";
|
|
3
|
+
export let bgDark = "bg-surface-900";
|
|
4
|
+
export let fillLight = "fill-surface-50";
|
|
5
|
+
export let fillDark = "fill-surface-900";
|
|
6
|
+
export let width = "w-12";
|
|
7
|
+
export let height = "w-6";
|
|
8
|
+
export let ring = "ring-[1px] ring-surface-500/30";
|
|
9
|
+
export let rounded = "rounded-token";
|
|
10
|
+
const cTransition = `transition-all duration-[200ms]`;
|
|
11
|
+
const cTrack = "cursor-pointer";
|
|
12
|
+
const cThumb = "aspect-square scale-[0.8] flex justify-center items-center";
|
|
13
|
+
const cIcon = "w-[70%] aspect-square";
|
|
14
|
+
const svgPath = {
|
|
15
|
+
sun: "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",
|
|
16
|
+
moon: "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"
|
|
17
|
+
};
|
|
18
|
+
function onToggleHandler() {
|
|
19
|
+
$modeCurrent = !$modeCurrent;
|
|
20
|
+
setModeUserPrefers($modeCurrent);
|
|
21
|
+
setModeCurrent($modeCurrent);
|
|
30
22
|
}
|
|
31
23
|
function onKeyDown(event) {
|
|
32
24
|
if (["Enter", "Space"].includes(event.code)) {
|
|
33
25
|
event.preventDefault();
|
|
34
26
|
event.currentTarget.click();
|
|
35
27
|
}
|
|
36
|
-
dispatch("keydown", event);
|
|
37
28
|
}
|
|
38
|
-
onMount(() => {
|
|
39
|
-
setPrefersDarkScheme();
|
|
40
|
-
});
|
|
41
29
|
$:
|
|
42
|
-
|
|
30
|
+
trackBg = $modeCurrent === true ? bgLight : bgDark;
|
|
31
|
+
$:
|
|
32
|
+
thumbBg = $modeCurrent === true ? bgDark : bgLight;
|
|
33
|
+
$:
|
|
34
|
+
thumbPosition = $modeCurrent === true ? "translate-x-[100%]" : "";
|
|
35
|
+
$:
|
|
36
|
+
iconFill = $modeCurrent === true ? fillLight : fillDark;
|
|
37
|
+
$:
|
|
38
|
+
classesTrack = `${cTrack} ${cTransition} ${width} ${height} ${ring} ${rounded} ${trackBg} ${$$props.class ?? ""}`;
|
|
43
39
|
$:
|
|
44
|
-
|
|
40
|
+
classesThumb = `${cThumb} ${cTransition} ${height} ${rounded} ${thumbBg} ${thumbPosition}`;
|
|
45
41
|
$:
|
|
46
|
-
|
|
42
|
+
classesIcon = `${cIcon} ${iconFill}`;
|
|
47
43
|
</script>
|
|
48
44
|
|
|
49
45
|
<svelte:head>
|
|
50
|
-
{@html `<script>${
|
|
46
|
+
{@html `<script>${setInitialClassState.toString()} setInitialClassState();</script>`}
|
|
51
47
|
</svelte:head>
|
|
52
48
|
|
|
53
|
-
<!-- prettier-ignore -->
|
|
54
49
|
<div
|
|
55
|
-
class="lightswitch {
|
|
56
|
-
on:click={
|
|
50
|
+
class="lightswitch-track {classesTrack}"
|
|
51
|
+
on:click={onToggleHandler}
|
|
52
|
+
on:click
|
|
57
53
|
on:keydown={onKeyDown}
|
|
54
|
+
on:keydown
|
|
58
55
|
on:keyup
|
|
59
56
|
on:keypress
|
|
60
57
|
role="switch"
|
|
61
58
|
aria-label="Light Switch"
|
|
62
|
-
aria-checked={$
|
|
63
|
-
title="Toggle {$
|
|
59
|
+
aria-checked={$modeCurrent}
|
|
60
|
+
title="Toggle {$modeCurrent === true ? 'Dark' : 'Light'} Mode"
|
|
64
61
|
tabindex="0"
|
|
65
62
|
>
|
|
66
63
|
<!-- Thumb -->
|
|
67
64
|
<div class="lightswitch-thumb {classesThumb}">
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
<
|
|
71
|
-
|
|
72
|
-
</svg>
|
|
73
|
-
{:else}
|
|
74
|
-
<!-- Icon Dark -->
|
|
75
|
-
<svg class="lightswitch-icon fill-white {cIcon}" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 384 512">
|
|
76
|
-
<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"/>
|
|
77
|
-
</svg>
|
|
78
|
-
{/if}
|
|
65
|
+
<!-- SVG -->
|
|
66
|
+
<svg class="lightswitch-icon {classesIcon}" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512">
|
|
67
|
+
<path d={$modeCurrent ? svgPath.sun : svgPath.moon} />
|
|
68
|
+
</svg>
|
|
79
69
|
</div>
|
|
80
70
|
</div>
|
|
@@ -2,12 +2,28 @@ import { SvelteComponentTyped } from "svelte";
|
|
|
2
2
|
declare const __propDef: {
|
|
3
3
|
props: {
|
|
4
4
|
[x: string]: any;
|
|
5
|
+
/** Provide classes to set the light background color.*/
|
|
6
|
+
bgLight?: string | undefined;
|
|
7
|
+
/** Provide classes to set the dark background color.*/
|
|
8
|
+
bgDark?: string | undefined;
|
|
9
|
+
/** Provide classes to set the light SVG fill color.*/
|
|
10
|
+
fillLight?: string | undefined;
|
|
11
|
+
/** Provide classes to set the dark SVG fill color.*/
|
|
12
|
+
fillDark?: string | undefined;
|
|
13
|
+
/** Provide classes to set width styles.*/
|
|
14
|
+
width?: string | undefined;
|
|
15
|
+
/** Provide classes to set height styles. Should be half of width.*/
|
|
16
|
+
height?: string | undefined;
|
|
17
|
+
/** Provide classes to set ring styles.*/
|
|
18
|
+
ring?: string | undefined;
|
|
19
|
+
/** Provide classes to set border radius styles.*/
|
|
20
|
+
rounded?: string | undefined;
|
|
5
21
|
};
|
|
6
22
|
events: {
|
|
23
|
+
click: MouseEvent;
|
|
24
|
+
keydown: KeyboardEvent;
|
|
7
25
|
keyup: KeyboardEvent;
|
|
8
26
|
keypress: KeyboardEvent;
|
|
9
|
-
click: CustomEvent<any>;
|
|
10
|
-
keydown: CustomEvent<any>;
|
|
11
27
|
} & {
|
|
12
28
|
[evt: string]: CustomEvent<any>;
|
|
13
29
|
};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/** Store: OS Preference Mode */
|
|
2
|
+
export declare const modeOsPrefers: import("svelte/store").Writable<boolean>;
|
|
3
|
+
/** Store: User Preference Mode */
|
|
4
|
+
export declare const modeUserPrefers: import("svelte/store").Writable<boolean | undefined>;
|
|
5
|
+
/** Store: Current Mode State */
|
|
6
|
+
export declare const modeCurrent: import("svelte/store").Writable<boolean>;
|
|
7
|
+
/** Get the OS Preference for light/dark mode */
|
|
8
|
+
export declare function getModeOsPrefers(): boolean;
|
|
9
|
+
/** Get the User for light/dark mode */
|
|
10
|
+
export declare function getModeUserPrefers(): boolean | undefined;
|
|
11
|
+
/** Get the Automatic Preference light/dark mode */
|
|
12
|
+
export declare function getModeAutoPrefers(): boolean;
|
|
13
|
+
/** Set the User Preference for light/dark mode */
|
|
14
|
+
export declare function setModeUserPrefers(value: boolean): void;
|
|
15
|
+
/** Set the the current light/dark mode */
|
|
16
|
+
export declare function setModeCurrent(value: boolean): void;
|
|
17
|
+
/** Set the visible light/dark mode on page load. */
|
|
18
|
+
export declare function setInitialClassState(): void;
|
|
19
|
+
/** Automatically set the visible light/dark, updates on change. */
|
|
20
|
+
export declare function autoModeWatcher(): void;
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
// Lightswitch Service
|
|
2
|
+
import { get } from 'svelte/store';
|
|
3
|
+
import { localStorageStore } from '../LocalStorageStore/LocalStorageStore';
|
|
4
|
+
// Stores ---
|
|
5
|
+
// TRUE: light, FALSE: dark
|
|
6
|
+
/** Store: OS Preference Mode */
|
|
7
|
+
export const modeOsPrefers = localStorageStore('modeOsPrefers', false);
|
|
8
|
+
/** Store: User Preference Mode */
|
|
9
|
+
export const modeUserPrefers = localStorageStore('modeUserPrefers', undefined);
|
|
10
|
+
/** Store: Current Mode State */
|
|
11
|
+
export const modeCurrent = localStorageStore('modeCurrent', false);
|
|
12
|
+
// Get ---
|
|
13
|
+
/** Get the OS Preference for light/dark mode */
|
|
14
|
+
export function getModeOsPrefers() {
|
|
15
|
+
const prefersLightMode = window.matchMedia('(prefers-color-scheme: light)').matches;
|
|
16
|
+
modeOsPrefers.set(prefersLightMode);
|
|
17
|
+
return prefersLightMode;
|
|
18
|
+
}
|
|
19
|
+
/** Get the User for light/dark mode */
|
|
20
|
+
export function getModeUserPrefers() {
|
|
21
|
+
return get(modeUserPrefers);
|
|
22
|
+
}
|
|
23
|
+
/** Get the Automatic Preference light/dark mode */
|
|
24
|
+
export function getModeAutoPrefers() {
|
|
25
|
+
const os = getModeOsPrefers();
|
|
26
|
+
const user = getModeUserPrefers();
|
|
27
|
+
const modeValue = user !== undefined ? user : os;
|
|
28
|
+
return modeValue;
|
|
29
|
+
}
|
|
30
|
+
// Set ---
|
|
31
|
+
/** Set the User Preference for light/dark mode */
|
|
32
|
+
export function setModeUserPrefers(value) {
|
|
33
|
+
modeUserPrefers.set(value);
|
|
34
|
+
}
|
|
35
|
+
/** Set the the current light/dark mode */
|
|
36
|
+
export function setModeCurrent(value) {
|
|
37
|
+
const elemHtmlClasses = document.documentElement.classList;
|
|
38
|
+
const classDark = `dark`;
|
|
39
|
+
value === true ? elemHtmlClasses.remove(classDark) : elemHtmlClasses.add(classDark);
|
|
40
|
+
modeCurrent.set(value);
|
|
41
|
+
}
|
|
42
|
+
// Lightswitch Utility
|
|
43
|
+
/** Set the visible light/dark mode on page load. */
|
|
44
|
+
export function setInitialClassState() {
|
|
45
|
+
const elemHtmlClasses = document.documentElement.classList;
|
|
46
|
+
// Conditions
|
|
47
|
+
const condLocalStroageUserPrefs = localStorage.getItem('modeUserPrefers') === 'false';
|
|
48
|
+
const condLocalStroageUserPrefsExists = !('modeUserPrefers' in localStorage);
|
|
49
|
+
const condMatchMedia = window.matchMedia('(prefers-color-scheme: dark)').matches;
|
|
50
|
+
// Add/remove `.dark` class to HTML element
|
|
51
|
+
if (condLocalStroageUserPrefs || (condLocalStroageUserPrefsExists && condMatchMedia)) {
|
|
52
|
+
elemHtmlClasses.add('dark');
|
|
53
|
+
}
|
|
54
|
+
else {
|
|
55
|
+
elemHtmlClasses.remove('dark');
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
// Auto-Switch Utility
|
|
59
|
+
/** Automatically set the visible light/dark, updates on change. */
|
|
60
|
+
export function autoModeWatcher() {
|
|
61
|
+
const mql = window.matchMedia('(prefers-color-scheme: light)');
|
|
62
|
+
function setMode(value) {
|
|
63
|
+
const elemHtmlClasses = document.documentElement.classList;
|
|
64
|
+
const classDark = `dark`;
|
|
65
|
+
value === true ? elemHtmlClasses.remove(classDark) : elemHtmlClasses.add(classDark);
|
|
66
|
+
}
|
|
67
|
+
setMode(mql.matches);
|
|
68
|
+
mql.onchange = () => {
|
|
69
|
+
setMode(mql.matches);
|
|
70
|
+
};
|
|
71
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// Source: https://github.com/joshnuss/svelte-local-storage-store
|
|
2
2
|
// https://github.com/joshnuss/svelte-local-storage-store/blob/master/index.ts
|
|
3
|
-
// Represents version v0.
|
|
3
|
+
// Represents version v0.4.0 (2023-01-18)
|
|
4
4
|
import { writable as internal, get } from 'svelte/store';
|
|
5
5
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
6
6
|
const stores = {};
|