plasma-svelte 0.0.1
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 +65 -0
- package/dist/accordion/Accordion.svelte +28 -0
- package/dist/accordion/Accordion.svelte.d.ts +8 -0
- package/dist/accordion/AccordionItem.svelte +193 -0
- package/dist/accordion/AccordionItem.svelte.d.ts +14 -0
- package/dist/avatar/Avatar.svelte +178 -0
- package/dist/avatar/Avatar.svelte.d.ts +16 -0
- package/dist/badge/Badge.svelte +162 -0
- package/dist/badge/Badge.svelte.d.ts +16 -0
- package/dist/breadcrumb/Breadcrumb.svelte +59 -0
- package/dist/breadcrumb/Breadcrumb.svelte.d.ts +9 -0
- package/dist/breadcrumb/BreadcrumbItem.svelte +151 -0
- package/dist/breadcrumb/BreadcrumbItem.svelte.d.ts +14 -0
- package/dist/button/Button.svelte +274 -0
- package/dist/button/Button.svelte.d.ts +22 -0
- package/dist/button/ButtonGroup.svelte +98 -0
- package/dist/button/ButtonGroup.svelte.d.ts +12 -0
- package/dist/card/Card.svelte +191 -0
- package/dist/card/Card.svelte.d.ts +18 -0
- package/dist/checkbox/Checkbox.svelte +199 -0
- package/dist/checkbox/Checkbox.svelte.d.ts +12 -0
- package/dist/datepicker/DatePicker.svelte +509 -0
- package/dist/datepicker/DatePicker.svelte.d.ts +14 -0
- package/dist/divider/Divider.svelte +112 -0
- package/dist/divider/Divider.svelte.d.ts +13 -0
- package/dist/drawer/Drawer.svelte +330 -0
- package/dist/drawer/Drawer.svelte.d.ts +21 -0
- package/dist/dropzone/DropZone.svelte +282 -0
- package/dist/dropzone/DropZone.svelte.d.ts +17 -0
- package/dist/emptystate/EmptyState.svelte +169 -0
- package/dist/emptystate/EmptyState.svelte.d.ts +15 -0
- package/dist/headerbar/HeaderBar.svelte +210 -0
- package/dist/headerbar/HeaderBar.svelte.d.ts +17 -0
- package/dist/index.d.ts +44 -0
- package/dist/index.js +44 -0
- package/dist/input/Input.svelte +227 -0
- package/dist/input/Input.svelte.d.ts +14 -0
- package/dist/layout/Flex.svelte +110 -0
- package/dist/layout/Flex.svelte.d.ts +20 -0
- package/dist/layout/Grid.svelte +78 -0
- package/dist/layout/Grid.svelte.d.ts +19 -0
- package/dist/layout/Space.svelte +64 -0
- package/dist/layout/Space.svelte.d.ts +16 -0
- package/dist/layout/utils.d.ts +2 -0
- package/dist/layout/utils.js +19 -0
- package/dist/menu/Menu.svelte +156 -0
- package/dist/menu/Menu.svelte.d.ts +14 -0
- package/dist/menu/MenuDivider.svelte +19 -0
- package/dist/menu/MenuDivider.svelte.d.ts +6 -0
- package/dist/menu/MenuItem.svelte +126 -0
- package/dist/menu/MenuItem.svelte.d.ts +13 -0
- package/dist/message/InlineMessage.svelte +226 -0
- package/dist/message/InlineMessage.svelte.d.ts +15 -0
- package/dist/modal/ConfirmDialog.svelte +151 -0
- package/dist/modal/ConfirmDialog.svelte.d.ts +19 -0
- package/dist/modal/Modal.svelte +279 -0
- package/dist/modal/Modal.svelte.d.ts +18 -0
- package/dist/pagination/Pagination.svelte +258 -0
- package/dist/pagination/Pagination.svelte.d.ts +16 -0
- package/dist/progress/ProgressBar.svelte +179 -0
- package/dist/progress/ProgressBar.svelte.d.ts +15 -0
- package/dist/radio/Radio.svelte +161 -0
- package/dist/radio/Radio.svelte.d.ts +13 -0
- package/dist/searchfield/SearchField.svelte +246 -0
- package/dist/searchfield/SearchField.svelte.d.ts +15 -0
- package/dist/select/Select.svelte +392 -0
- package/dist/select/Select.svelte.d.ts +20 -0
- package/dist/sidebar/Sidebar.svelte +78 -0
- package/dist/sidebar/Sidebar.svelte.d.ts +11 -0
- package/dist/sidebar/SidebarGroup.svelte +51 -0
- package/dist/sidebar/SidebarGroup.svelte.d.ts +9 -0
- package/dist/sidebar/SidebarItem.svelte +185 -0
- package/dist/sidebar/SidebarItem.svelte.d.ts +16 -0
- package/dist/slider/Slider.svelte +204 -0
- package/dist/slider/Slider.svelte.d.ts +16 -0
- package/dist/spinbox/SpinBox.svelte +299 -0
- package/dist/spinbox/SpinBox.svelte.d.ts +20 -0
- package/dist/spinner/Spinner.svelte +130 -0
- package/dist/spinner/Spinner.svelte.d.ts +11 -0
- package/dist/style/base.css +178 -0
- package/dist/style/index.css +2 -0
- package/dist/style/token.css +230 -0
- package/dist/switch/Switch.svelte +199 -0
- package/dist/switch/Switch.svelte.d.ts +13 -0
- package/dist/table/Table.svelte +305 -0
- package/dist/table/Table.svelte.d.ts +32 -0
- package/dist/tabs/Tabs.svelte +216 -0
- package/dist/tabs/Tabs.svelte.d.ts +21 -0
- package/dist/textarea/TextArea.svelte +114 -0
- package/dist/textarea/TextArea.svelte.d.ts +14 -0
- package/dist/timepicker/TimePicker.svelte +452 -0
- package/dist/timepicker/TimePicker.svelte.d.ts +16 -0
- package/dist/tooltip/Tooltip.svelte +122 -0
- package/dist/tooltip/Tooltip.svelte.d.ts +12 -0
- package/package.json +66 -0
|
@@ -0,0 +1,230 @@
|
|
|
1
|
+
/* ==========================================================================
|
|
2
|
+
Plasma / KDE Breeze Design System Tokens
|
|
3
|
+
Based on KDE Breeze, Plasma 6, Kirigami & KColorScheme specifications
|
|
4
|
+
========================================================================== */
|
|
5
|
+
|
|
6
|
+
:root {
|
|
7
|
+
/* ------------------------------------------------------------------------
|
|
8
|
+
Base Typography
|
|
9
|
+
------------------------------------------------------------------------ */
|
|
10
|
+
--plasma-font-sans: "Noto Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
|
|
11
|
+
--plasma-font-mono: "Hack", "JetBrains Mono", "Cascadia Code", "Fira Code", monospace;
|
|
12
|
+
|
|
13
|
+
--plasma-font-size-xs: 0.75rem; /* 12px */
|
|
14
|
+
--plasma-font-size-sm: 0.8125rem; /* 13px - KDE standard small label */
|
|
15
|
+
--plasma-font-size-base: 0.875rem; /* 14px - KDE standard UI text */
|
|
16
|
+
--plasma-font-size-md: 1rem; /* 16px */
|
|
17
|
+
--plasma-font-size-lg: 1.125rem; /* 18px */
|
|
18
|
+
--plasma-font-size-xl: 1.375rem; /* 22px */
|
|
19
|
+
--plasma-font-size-2xl: 1.75rem; /* 28px */
|
|
20
|
+
|
|
21
|
+
--plasma-font-weight-normal: 400;
|
|
22
|
+
--plasma-font-weight-medium: 500;
|
|
23
|
+
--plasma-font-weight-bold: 600;
|
|
24
|
+
|
|
25
|
+
--plasma-line-height-tight: 1.25;
|
|
26
|
+
--plasma-line-height-base: 1.5;
|
|
27
|
+
|
|
28
|
+
/* ------------------------------------------------------------------------
|
|
29
|
+
Spacing & Sizing Grid (4px / 8px base)
|
|
30
|
+
------------------------------------------------------------------------ */
|
|
31
|
+
--plasma-space-2xs: 0.125rem; /* 2px */
|
|
32
|
+
--plasma-space-xs: 0.25rem; /* 4px */
|
|
33
|
+
--plasma-space-sm: 0.5rem; /* 8px */
|
|
34
|
+
--plasma-space-md: 0.75rem; /* 12px */
|
|
35
|
+
--plasma-space-lg: 1rem; /* 16px */
|
|
36
|
+
--plasma-space-xl: 1.5rem; /* 24px */
|
|
37
|
+
--plasma-space-2xl: 2rem; /* 32px */
|
|
38
|
+
|
|
39
|
+
/* ------------------------------------------------------------------------
|
|
40
|
+
Control Geometry (Breeze / Plasma 6 metrics)
|
|
41
|
+
------------------------------------------------------------------------ */
|
|
42
|
+
--plasma-radius-xs: 2px;
|
|
43
|
+
--plasma-radius-sm: 4px;
|
|
44
|
+
--plasma-radius-md: 5px; /* Plasma 6 control standard */
|
|
45
|
+
--plasma-radius-lg: 8px; /* Cards, Popups, Menus */
|
|
46
|
+
--plasma-radius-xl: 12px; /* Floating sheets & panels */
|
|
47
|
+
--plasma-radius-full: 9999px; /* Pills, Avatars, Switches */
|
|
48
|
+
|
|
49
|
+
--plasma-control-height-sm: 1.5rem; /* 24px */
|
|
50
|
+
--plasma-control-height-md: 2rem; /* 32px standard */
|
|
51
|
+
--plasma-control-height-lg: 2.5rem; /* 40px */
|
|
52
|
+
|
|
53
|
+
/* ------------------------------------------------------------------------
|
|
54
|
+
Transitions & Motion
|
|
55
|
+
------------------------------------------------------------------------ */
|
|
56
|
+
--plasma-duration-fast: 100ms;
|
|
57
|
+
--plasma-duration-base: 150ms;
|
|
58
|
+
--plasma-duration-slow: 250ms;
|
|
59
|
+
--plasma-ease-default: cubic-bezier(0.4, 0, 0.2, 1);
|
|
60
|
+
|
|
61
|
+
--plasma-transition-fast: all 100ms ease-out;
|
|
62
|
+
--plasma-transition-base: all 150ms cubic-bezier(0.4, 0, 0.2, 1);
|
|
63
|
+
--plasma-transition-slow: all 250ms cubic-bezier(0.4, 0, 0.2, 1);
|
|
64
|
+
|
|
65
|
+
/* ------------------------------------------------------------------------
|
|
66
|
+
KDE Plasma Accent & Semantic Roles
|
|
67
|
+
------------------------------------------------------------------------ */
|
|
68
|
+
--plasma-color-highlight: #3daee9;
|
|
69
|
+
--plasma-color-highlight-hover: #1d99f3;
|
|
70
|
+
--plasma-color-highlight-active: #1881c7;
|
|
71
|
+
--plasma-color-highlight-text: #ffffff;
|
|
72
|
+
--plasma-color-highlight-soft: rgba(61, 174, 233, 0.15);
|
|
73
|
+
--plasma-color-highlight-glow: rgba(61, 174, 233, 0.35);
|
|
74
|
+
|
|
75
|
+
--plasma-color-positive: #27ae60;
|
|
76
|
+
--plasma-color-positive-hover: #2ecc71;
|
|
77
|
+
--plasma-color-positive-soft: rgba(39, 174, 96, 0.15);
|
|
78
|
+
|
|
79
|
+
--plasma-color-neutral: #f67400;
|
|
80
|
+
--plasma-color-neutral-hover: #fdbc4b;
|
|
81
|
+
--plasma-color-neutral-soft: rgba(246, 116, 0, 0.15);
|
|
82
|
+
|
|
83
|
+
--plasma-color-negative: #da4453;
|
|
84
|
+
--plasma-color-negative-hover: #ed1515;
|
|
85
|
+
--plasma-color-negative-soft: rgba(218, 68, 83, 0.15);
|
|
86
|
+
|
|
87
|
+
/* ------------------------------------------------------------------------
|
|
88
|
+
Default Dark Theme (Breeze Dark)
|
|
89
|
+
------------------------------------------------------------------------ */
|
|
90
|
+
--plasma-color-window-bg: #2a2e32;
|
|
91
|
+
--plasma-color-view-bg: #232629;
|
|
92
|
+
--plasma-color-surface: #31363b;
|
|
93
|
+
--plasma-color-surface-hover: #3b4045;
|
|
94
|
+
--plasma-color-surface-active: #232629;
|
|
95
|
+
--plasma-color-surface-sunken: #1d2023;
|
|
96
|
+
|
|
97
|
+
--plasma-color-border: #4d545c;
|
|
98
|
+
--plasma-color-border-subtle: rgba(255, 255, 255, 0.1);
|
|
99
|
+
--plasma-color-border-hover: #3daee9;
|
|
100
|
+
--plasma-color-border-focus: #3daee9;
|
|
101
|
+
|
|
102
|
+
--plasma-color-text: #fcfcfc;
|
|
103
|
+
--plasma-color-text-muted: #a1a8b0;
|
|
104
|
+
--plasma-color-text-disabled: #616569;
|
|
105
|
+
--plasma-color-text-link: #1d99f3;
|
|
106
|
+
|
|
107
|
+
--plasma-color-tooltip-bg: #1b1e20;
|
|
108
|
+
--plasma-color-tooltip-text: #fcfcfc;
|
|
109
|
+
|
|
110
|
+
--plasma-shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.2);
|
|
111
|
+
--plasma-shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.25);
|
|
112
|
+
--plasma-shadow-md: 0 4px 12px rgba(0, 0, 0, 0.35);
|
|
113
|
+
--plasma-shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.45);
|
|
114
|
+
--plasma-shadow-focus: 0 0 0 2px var(--plasma-color-highlight-glow);
|
|
115
|
+
|
|
116
|
+
/* ------------------------------------------------------------------------
|
|
117
|
+
Backward Compatibility Aliases
|
|
118
|
+
------------------------------------------------------------------------ */
|
|
119
|
+
--color-primary: var(--plasma-color-highlight);
|
|
120
|
+
--color-primary-hover: var(--plasma-color-highlight-hover);
|
|
121
|
+
--color-bg: var(--plasma-color-window-bg);
|
|
122
|
+
--color-surface: var(--plasma-color-surface);
|
|
123
|
+
--color-surface-alt: var(--plasma-color-view-bg);
|
|
124
|
+
--color-border: var(--plasma-color-border);
|
|
125
|
+
--color-text: var(--plasma-color-text);
|
|
126
|
+
--color-text-muted: var(--plasma-color-text-muted);
|
|
127
|
+
--color-danger: var(--plasma-color-negative);
|
|
128
|
+
|
|
129
|
+
--font-family-base: var(--plasma-font-sans);
|
|
130
|
+
--font-size-sm: var(--plasma-font-size-sm);
|
|
131
|
+
--font-size-base: var(--plasma-font-size-base);
|
|
132
|
+
|
|
133
|
+
--radius-sm: var(--plasma-radius-sm);
|
|
134
|
+
--radius-md: var(--plasma-radius-md);
|
|
135
|
+
--shadow-card: var(--plasma-shadow-md);
|
|
136
|
+
--transition-default: var(--plasma-transition-base);
|
|
137
|
+
--transition-fast: var(--plasma-transition-fast);
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
/* ==========================================================================
|
|
141
|
+
Light Mode Theme (Breeze Light)
|
|
142
|
+
Triggered via data-theme="light" or prefers-color-scheme: light (when not explicit dark)
|
|
143
|
+
========================================================================== */
|
|
144
|
+
[data-theme="light"] {
|
|
145
|
+
--plasma-color-window-bg: #eff0f1;
|
|
146
|
+
--plasma-color-view-bg: #ffffff;
|
|
147
|
+
--plasma-color-surface: #f7f7f7;
|
|
148
|
+
--plasma-color-surface-hover: #ffffff;
|
|
149
|
+
--plasma-color-surface-active: #e0e2e4;
|
|
150
|
+
--plasma-color-surface-sunken: #e2e4e6;
|
|
151
|
+
|
|
152
|
+
--plasma-color-border: #bcbebf;
|
|
153
|
+
--plasma-color-border-subtle: rgba(0, 0, 0, 0.08);
|
|
154
|
+
--plasma-color-border-hover: #3daee9;
|
|
155
|
+
--plasma-color-border-focus: #3daee9;
|
|
156
|
+
|
|
157
|
+
--plasma-color-text: #232629;
|
|
158
|
+
--plasma-color-text-muted: #5c636b;
|
|
159
|
+
--plasma-color-text-disabled: #9fa4a8;
|
|
160
|
+
--plasma-color-text-link: #2980b9;
|
|
161
|
+
|
|
162
|
+
--plasma-color-tooltip-bg: #31363b;
|
|
163
|
+
--plasma-color-tooltip-text: #fcfcfc;
|
|
164
|
+
|
|
165
|
+
--plasma-shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.06);
|
|
166
|
+
--plasma-shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.08);
|
|
167
|
+
--plasma-shadow-md: 0 4px 12px rgba(0, 0, 0, 0.12);
|
|
168
|
+
--plasma-shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.16);
|
|
169
|
+
--plasma-shadow-focus: 0 0 0 2px rgba(61, 174, 233, 0.35);
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
@media (prefers-color-scheme: light) {
|
|
173
|
+
:root:not([data-theme="dark"]) {
|
|
174
|
+
--plasma-color-window-bg: #eff0f1;
|
|
175
|
+
--plasma-color-view-bg: #ffffff;
|
|
176
|
+
--plasma-color-surface: #f7f7f7;
|
|
177
|
+
--plasma-color-surface-hover: #ffffff;
|
|
178
|
+
--plasma-color-surface-active: #e0e2e4;
|
|
179
|
+
--plasma-color-surface-sunken: #e2e4e6;
|
|
180
|
+
|
|
181
|
+
--plasma-color-border: #bcbebf;
|
|
182
|
+
--plasma-color-border-subtle: rgba(0, 0, 0, 0.08);
|
|
183
|
+
--plasma-color-border-hover: #3daee9;
|
|
184
|
+
--plasma-color-border-focus: #3daee9;
|
|
185
|
+
|
|
186
|
+
--plasma-color-text: #232629;
|
|
187
|
+
--plasma-color-text-muted: #5c636b;
|
|
188
|
+
--plasma-color-text-disabled: #9fa4a8;
|
|
189
|
+
--plasma-color-text-link: #2980b9;
|
|
190
|
+
|
|
191
|
+
--plasma-color-tooltip-bg: #31363b;
|
|
192
|
+
--plasma-color-tooltip-text: #fcfcfc;
|
|
193
|
+
|
|
194
|
+
--plasma-shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.06);
|
|
195
|
+
--plasma-shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.08);
|
|
196
|
+
--plasma-shadow-md: 0 4px 12px rgba(0, 0, 0, 0.12);
|
|
197
|
+
--plasma-shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.16);
|
|
198
|
+
--plasma-shadow-focus: 0 0 0 2px rgba(61, 174, 233, 0.35);
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
/* Explicit dark theme override */
|
|
203
|
+
[data-theme="dark"] {
|
|
204
|
+
--plasma-color-window-bg: #2a2e32;
|
|
205
|
+
--plasma-color-view-bg: #232629;
|
|
206
|
+
--plasma-color-surface: #31363b;
|
|
207
|
+
--plasma-color-surface-hover: #3b4045;
|
|
208
|
+
--plasma-color-surface-active: #232629;
|
|
209
|
+
--plasma-color-surface-sunken: #1d2023;
|
|
210
|
+
|
|
211
|
+
--plasma-color-border: #4d545c;
|
|
212
|
+
--plasma-color-border-subtle: rgba(255, 255, 255, 0.1);
|
|
213
|
+
--plasma-color-border-hover: #3daee9;
|
|
214
|
+
--plasma-color-border-focus: #3daee9;
|
|
215
|
+
|
|
216
|
+
--plasma-color-text: #fcfcfc;
|
|
217
|
+
--plasma-color-text-muted: #a1a8b0;
|
|
218
|
+
--plasma-color-text-disabled: #616569;
|
|
219
|
+
--plasma-color-text-link: #1d99f3;
|
|
220
|
+
|
|
221
|
+
--plasma-color-tooltip-bg: #1b1e20;
|
|
222
|
+
--plasma-color-tooltip-text: #fcfcfc;
|
|
223
|
+
|
|
224
|
+
--plasma-shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.2);
|
|
225
|
+
--plasma-shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.25);
|
|
226
|
+
--plasma-shadow-md: 0 4px 12px rgba(0, 0, 0, 0.35);
|
|
227
|
+
--plasma-shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.45);
|
|
228
|
+
--plasma-shadow-focus: 0 0 0 2px var(--plasma-color-highlight-glow);
|
|
229
|
+
}
|
|
230
|
+
|
|
@@ -0,0 +1,199 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import type { Snippet } from "svelte";
|
|
3
|
+
import type { HTMLInputAttributes } from "svelte/elements";
|
|
4
|
+
|
|
5
|
+
type SwitchSize = "sm" | "md" | "lg" | "small" | "medium" | "large";
|
|
6
|
+
|
|
7
|
+
interface Props extends Omit<HTMLInputAttributes, "size" | "type"> {
|
|
8
|
+
checked?: boolean;
|
|
9
|
+
size?: SwitchSize;
|
|
10
|
+
disabled?: boolean;
|
|
11
|
+
label?: string;
|
|
12
|
+
children?: Snippet;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
let {
|
|
16
|
+
checked = $bindable(false),
|
|
17
|
+
size = "md",
|
|
18
|
+
disabled = false,
|
|
19
|
+
label,
|
|
20
|
+
children,
|
|
21
|
+
class: customClass = "",
|
|
22
|
+
id,
|
|
23
|
+
onchange,
|
|
24
|
+
...restProps
|
|
25
|
+
}: Props = $props();
|
|
26
|
+
|
|
27
|
+
const resolvedSize = $derived(
|
|
28
|
+
size === "small"
|
|
29
|
+
? "sm"
|
|
30
|
+
: size === "large"
|
|
31
|
+
? "lg"
|
|
32
|
+
: size === "medium"
|
|
33
|
+
? "md"
|
|
34
|
+
: size,
|
|
35
|
+
);
|
|
36
|
+
|
|
37
|
+
function handleChange(e: Event) {
|
|
38
|
+
const target = e.target as HTMLInputElement;
|
|
39
|
+
checked = target.checked;
|
|
40
|
+
(onchange as ((e: Event) => void) | undefined)?.(e);
|
|
41
|
+
}
|
|
42
|
+
</script>
|
|
43
|
+
|
|
44
|
+
<label
|
|
45
|
+
class="plasma-switch-container plasma-switch--{resolvedSize} {customClass}"
|
|
46
|
+
class:plasma-switch--disabled={disabled}
|
|
47
|
+
for={id}
|
|
48
|
+
>
|
|
49
|
+
<input
|
|
50
|
+
{id}
|
|
51
|
+
type="checkbox"
|
|
52
|
+
role="switch"
|
|
53
|
+
aria-checked={checked}
|
|
54
|
+
{checked}
|
|
55
|
+
{disabled}
|
|
56
|
+
onchange={handleChange}
|
|
57
|
+
class="plasma-switch-input"
|
|
58
|
+
{...restProps}
|
|
59
|
+
/>
|
|
60
|
+
|
|
61
|
+
<span class="plasma-switch-track" class:plasma-switch-track--checked={checked}>
|
|
62
|
+
<span class="plasma-switch-thumb"></span>
|
|
63
|
+
</span>
|
|
64
|
+
|
|
65
|
+
{#if children}
|
|
66
|
+
<span class="plasma-switch-label">
|
|
67
|
+
{@render children()}
|
|
68
|
+
</span>
|
|
69
|
+
{:else if label}
|
|
70
|
+
<span class="plasma-switch-label">
|
|
71
|
+
{label}
|
|
72
|
+
</span>
|
|
73
|
+
{/if}
|
|
74
|
+
</label>
|
|
75
|
+
|
|
76
|
+
<style>
|
|
77
|
+
.plasma-switch-container {
|
|
78
|
+
display: inline-flex;
|
|
79
|
+
align-items: center;
|
|
80
|
+
gap: var(--plasma-space-sm);
|
|
81
|
+
cursor: pointer;
|
|
82
|
+
font-family: var(--plasma-font-sans);
|
|
83
|
+
font-size: var(--plasma-font-size-base);
|
|
84
|
+
color: var(--plasma-color-text);
|
|
85
|
+
user-select: none;
|
|
86
|
+
line-height: 1.2;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
.plasma-switch--disabled {
|
|
90
|
+
opacity: 0.45;
|
|
91
|
+
cursor: not-allowed;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
/* Visually hide native input */
|
|
95
|
+
.plasma-switch-input {
|
|
96
|
+
position: absolute;
|
|
97
|
+
opacity: 0;
|
|
98
|
+
width: 0;
|
|
99
|
+
height: 0;
|
|
100
|
+
margin: 0;
|
|
101
|
+
pointer-events: none;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
/* --------------------------------------------------------------------------
|
|
105
|
+
Track (Pill)
|
|
106
|
+
-------------------------------------------------------------------------- */
|
|
107
|
+
.plasma-switch-track {
|
|
108
|
+
position: relative;
|
|
109
|
+
display: inline-flex;
|
|
110
|
+
align-items: center;
|
|
111
|
+
border-radius: var(--plasma-radius-full);
|
|
112
|
+
background-color: var(--plasma-color-surface-sunken);
|
|
113
|
+
border: 1px solid var(--plasma-color-border);
|
|
114
|
+
flex-shrink: 0;
|
|
115
|
+
transition:
|
|
116
|
+
background-color var(--plasma-duration-base) var(--plasma-ease-default),
|
|
117
|
+
border-color var(--plasma-duration-base) var(--plasma-ease-default);
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
.plasma-switch-container:hover:not(.plasma-switch--disabled) .plasma-switch-track {
|
|
121
|
+
border-color: var(--plasma-color-border-hover);
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
.plasma-switch-input:focus-visible + .plasma-switch-track {
|
|
125
|
+
outline: 2px solid var(--plasma-color-highlight);
|
|
126
|
+
outline-offset: 2px;
|
|
127
|
+
box-shadow: var(--plasma-shadow-focus);
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
.plasma-switch-track--checked {
|
|
131
|
+
background-color: var(--plasma-color-highlight);
|
|
132
|
+
border-color: var(--plasma-color-highlight-hover);
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
.plasma-switch-container:hover:not(.plasma-switch--disabled) .plasma-switch-track--checked {
|
|
136
|
+
background-color: var(--plasma-color-highlight-hover);
|
|
137
|
+
border-color: var(--plasma-color-highlight-active);
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
/* --------------------------------------------------------------------------
|
|
141
|
+
Thumb (Circular slider)
|
|
142
|
+
-------------------------------------------------------------------------- */
|
|
143
|
+
.plasma-switch-thumb {
|
|
144
|
+
position: absolute;
|
|
145
|
+
border-radius: var(--plasma-radius-full);
|
|
146
|
+
background-color: #ffffff;
|
|
147
|
+
box-shadow: var(--plasma-shadow-xs);
|
|
148
|
+
transition: transform var(--plasma-duration-base) var(--plasma-ease-default);
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
/* --------------------------------------------------------------------------
|
|
152
|
+
Sizes
|
|
153
|
+
-------------------------------------------------------------------------- */
|
|
154
|
+
/* SM */
|
|
155
|
+
.plasma-switch--sm .plasma-switch-track {
|
|
156
|
+
width: 28px;
|
|
157
|
+
height: 16px;
|
|
158
|
+
}
|
|
159
|
+
.plasma-switch--sm .plasma-switch-thumb {
|
|
160
|
+
width: 12px;
|
|
161
|
+
height: 12px;
|
|
162
|
+
left: 1px;
|
|
163
|
+
}
|
|
164
|
+
.plasma-switch--sm .plasma-switch-track--checked .plasma-switch-thumb {
|
|
165
|
+
transform: translateX(12px);
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
/* MD (Standard Breeze) */
|
|
169
|
+
.plasma-switch--md .plasma-switch-track {
|
|
170
|
+
width: 36px;
|
|
171
|
+
height: 20px;
|
|
172
|
+
}
|
|
173
|
+
.plasma-switch--md .plasma-switch-thumb {
|
|
174
|
+
width: 14px;
|
|
175
|
+
height: 14px;
|
|
176
|
+
left: 2px;
|
|
177
|
+
}
|
|
178
|
+
.plasma-switch--md .plasma-switch-track--checked .plasma-switch-thumb {
|
|
179
|
+
transform: translateX(16px);
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
/* LG */
|
|
183
|
+
.plasma-switch--lg .plasma-switch-track {
|
|
184
|
+
width: 44px;
|
|
185
|
+
height: 24px;
|
|
186
|
+
}
|
|
187
|
+
.plasma-switch--lg .plasma-switch-thumb {
|
|
188
|
+
width: 18px;
|
|
189
|
+
height: 18px;
|
|
190
|
+
left: 2px;
|
|
191
|
+
}
|
|
192
|
+
.plasma-switch--lg .plasma-switch-track--checked .plasma-switch-thumb {
|
|
193
|
+
transform: translateX(20px);
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
.plasma-switch-label {
|
|
197
|
+
display: inline-block;
|
|
198
|
+
}
|
|
199
|
+
</style>
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { Snippet } from "svelte";
|
|
2
|
+
import type { HTMLInputAttributes } from "svelte/elements";
|
|
3
|
+
type SwitchSize = "sm" | "md" | "lg" | "small" | "medium" | "large";
|
|
4
|
+
interface Props extends Omit<HTMLInputAttributes, "size" | "type"> {
|
|
5
|
+
checked?: boolean;
|
|
6
|
+
size?: SwitchSize;
|
|
7
|
+
disabled?: boolean;
|
|
8
|
+
label?: string;
|
|
9
|
+
children?: Snippet;
|
|
10
|
+
}
|
|
11
|
+
declare const Switch: import("svelte").Component<Props, {}, "checked">;
|
|
12
|
+
type Switch = ReturnType<typeof Switch>;
|
|
13
|
+
export default Switch;
|