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,78 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import type { Snippet } from "svelte";
|
|
3
|
+
import type { HTMLAttributes } from "svelte/elements";
|
|
4
|
+
|
|
5
|
+
interface Props extends HTMLAttributes<HTMLElement> {
|
|
6
|
+
width?: string;
|
|
7
|
+
header?: Snippet;
|
|
8
|
+
footer?: Snippet;
|
|
9
|
+
children?: Snippet;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
let {
|
|
13
|
+
width = "240px",
|
|
14
|
+
header,
|
|
15
|
+
footer,
|
|
16
|
+
children,
|
|
17
|
+
class: customClass = "",
|
|
18
|
+
style = "",
|
|
19
|
+
...restProps
|
|
20
|
+
}: Props = $props();
|
|
21
|
+
</script>
|
|
22
|
+
|
|
23
|
+
<aside
|
|
24
|
+
class="plasma-sidebar {customClass}"
|
|
25
|
+
style="width: {width}; {style}"
|
|
26
|
+
{...restProps}
|
|
27
|
+
>
|
|
28
|
+
{#if header}
|
|
29
|
+
<div class="plasma-sidebar-header">
|
|
30
|
+
{@render header()}
|
|
31
|
+
</div>
|
|
32
|
+
{/if}
|
|
33
|
+
|
|
34
|
+
<nav class="plasma-sidebar-content">
|
|
35
|
+
{@render children?.()}
|
|
36
|
+
</nav>
|
|
37
|
+
|
|
38
|
+
{#if footer}
|
|
39
|
+
<div class="plasma-sidebar-footer">
|
|
40
|
+
{@render footer()}
|
|
41
|
+
</div>
|
|
42
|
+
{/if}
|
|
43
|
+
</aside>
|
|
44
|
+
|
|
45
|
+
<style>
|
|
46
|
+
.plasma-sidebar {
|
|
47
|
+
display: flex;
|
|
48
|
+
flex-direction: column;
|
|
49
|
+
height: 100%;
|
|
50
|
+
min-height: 320px;
|
|
51
|
+
background-color: var(--plasma-color-surface);
|
|
52
|
+
border-right: 1px solid var(--plasma-color-border-subtle);
|
|
53
|
+
font-family: var(--plasma-font-sans);
|
|
54
|
+
box-sizing: border-box;
|
|
55
|
+
flex-shrink: 0;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
.plasma-sidebar-header {
|
|
59
|
+
padding: var(--plasma-space-md);
|
|
60
|
+
border-bottom: 1px solid var(--plasma-color-border-subtle);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
.plasma-sidebar-content {
|
|
64
|
+
flex: 1;
|
|
65
|
+
overflow-y: auto;
|
|
66
|
+
padding: var(--plasma-space-md) var(--plasma-space-sm);
|
|
67
|
+
display: flex;
|
|
68
|
+
flex-direction: column;
|
|
69
|
+
scrollbar-width: thin;
|
|
70
|
+
scrollbar-color: var(--plasma-color-border) transparent;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
.plasma-sidebar-footer {
|
|
74
|
+
padding: var(--plasma-space-md);
|
|
75
|
+
border-top: 1px solid var(--plasma-color-border-subtle);
|
|
76
|
+
background-color: var(--plasma-color-surface-sunken);
|
|
77
|
+
}
|
|
78
|
+
</style>
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { Snippet } from "svelte";
|
|
2
|
+
import type { HTMLAttributes } from "svelte/elements";
|
|
3
|
+
interface Props extends HTMLAttributes<HTMLElement> {
|
|
4
|
+
width?: string;
|
|
5
|
+
header?: Snippet;
|
|
6
|
+
footer?: Snippet;
|
|
7
|
+
children?: Snippet;
|
|
8
|
+
}
|
|
9
|
+
declare const Sidebar: import("svelte").Component<Props, {}, "">;
|
|
10
|
+
type Sidebar = ReturnType<typeof Sidebar>;
|
|
11
|
+
export default Sidebar;
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import type { Snippet } from "svelte";
|
|
3
|
+
import type { HTMLAttributes } from "svelte/elements";
|
|
4
|
+
|
|
5
|
+
interface Props extends HTMLAttributes<HTMLDivElement> {
|
|
6
|
+
title?: string;
|
|
7
|
+
children?: Snippet;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
let {
|
|
11
|
+
title = "",
|
|
12
|
+
children,
|
|
13
|
+
class: customClass = "",
|
|
14
|
+
...restProps
|
|
15
|
+
}: Props = $props();
|
|
16
|
+
</script>
|
|
17
|
+
|
|
18
|
+
<div class="plasma-sidebar-group {customClass}" {...restProps}>
|
|
19
|
+
{#if title}
|
|
20
|
+
<div class="plasma-sidebar-group-title">{title}</div>
|
|
21
|
+
{/if}
|
|
22
|
+
<div class="plasma-sidebar-group-items">
|
|
23
|
+
{@render children?.()}
|
|
24
|
+
</div>
|
|
25
|
+
</div>
|
|
26
|
+
|
|
27
|
+
<style>
|
|
28
|
+
.plasma-sidebar-group {
|
|
29
|
+
display: flex;
|
|
30
|
+
flex-direction: column;
|
|
31
|
+
gap: 2px;
|
|
32
|
+
margin-bottom: var(--plasma-space-md);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
.plasma-sidebar-group-title {
|
|
36
|
+
padding: var(--plasma-space-xs) var(--plasma-space-md);
|
|
37
|
+
font-family: var(--plasma-font-sans);
|
|
38
|
+
font-size: 11px;
|
|
39
|
+
font-weight: var(--plasma-font-weight-bold);
|
|
40
|
+
color: var(--plasma-color-text-muted);
|
|
41
|
+
text-transform: uppercase;
|
|
42
|
+
letter-spacing: 0.06em;
|
|
43
|
+
user-select: none;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
.plasma-sidebar-group-items {
|
|
47
|
+
display: flex;
|
|
48
|
+
flex-direction: column;
|
|
49
|
+
gap: 2px;
|
|
50
|
+
}
|
|
51
|
+
</style>
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { Snippet } from "svelte";
|
|
2
|
+
import type { HTMLAttributes } from "svelte/elements";
|
|
3
|
+
interface Props extends HTMLAttributes<HTMLDivElement> {
|
|
4
|
+
title?: string;
|
|
5
|
+
children?: Snippet;
|
|
6
|
+
}
|
|
7
|
+
declare const SidebarGroup: import("svelte").Component<Props, {}, "">;
|
|
8
|
+
type SidebarGroup = ReturnType<typeof SidebarGroup>;
|
|
9
|
+
export default SidebarGroup;
|
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import type { Snippet } from "svelte";
|
|
3
|
+
import type { HTMLAttributes } from "svelte/elements";
|
|
4
|
+
|
|
5
|
+
interface Props extends HTMLAttributes<HTMLAnchorElement | HTMLButtonElement> {
|
|
6
|
+
id?: string;
|
|
7
|
+
label?: string;
|
|
8
|
+
active?: boolean;
|
|
9
|
+
disabled?: boolean;
|
|
10
|
+
href?: string;
|
|
11
|
+
icon?: Snippet;
|
|
12
|
+
badge?: string | number;
|
|
13
|
+
children?: Snippet;
|
|
14
|
+
onclick?: (e: MouseEvent) => void;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
let {
|
|
18
|
+
id = "",
|
|
19
|
+
label = "",
|
|
20
|
+
active = false,
|
|
21
|
+
disabled = false,
|
|
22
|
+
href,
|
|
23
|
+
icon,
|
|
24
|
+
badge,
|
|
25
|
+
children,
|
|
26
|
+
class: customClass = "",
|
|
27
|
+
onclick,
|
|
28
|
+
...restProps
|
|
29
|
+
}: Props = $props();
|
|
30
|
+
|
|
31
|
+
function handleClick(e: MouseEvent) {
|
|
32
|
+
if (disabled) {
|
|
33
|
+
e.preventDefault();
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
onclick?.(e);
|
|
37
|
+
}
|
|
38
|
+
</script>
|
|
39
|
+
|
|
40
|
+
{#if href}
|
|
41
|
+
<a
|
|
42
|
+
{href}
|
|
43
|
+
class="plasma-sidebar-item {customClass}"
|
|
44
|
+
class:plasma-sidebar-item--active={active}
|
|
45
|
+
class:plasma-sidebar-item--disabled={disabled}
|
|
46
|
+
aria-current={active ? "page" : undefined}
|
|
47
|
+
aria-disabled={disabled}
|
|
48
|
+
onclick={handleClick}
|
|
49
|
+
{...restProps}
|
|
50
|
+
>
|
|
51
|
+
{#if icon}
|
|
52
|
+
<span class="plasma-sidebar-item-icon">
|
|
53
|
+
{@render icon()}
|
|
54
|
+
</span>
|
|
55
|
+
{/if}
|
|
56
|
+
|
|
57
|
+
<span class="plasma-sidebar-item-label">
|
|
58
|
+
{#if children}
|
|
59
|
+
{@render children()}
|
|
60
|
+
{:else}
|
|
61
|
+
{label}
|
|
62
|
+
{/if}
|
|
63
|
+
</span>
|
|
64
|
+
|
|
65
|
+
{#if badge !== undefined}
|
|
66
|
+
<span class="plasma-sidebar-item-badge">{badge}</span>
|
|
67
|
+
{/if}
|
|
68
|
+
</a>
|
|
69
|
+
{:else}
|
|
70
|
+
<button
|
|
71
|
+
type="button"
|
|
72
|
+
class="plasma-sidebar-item {customClass}"
|
|
73
|
+
class:plasma-sidebar-item--active={active}
|
|
74
|
+
class:plasma-sidebar-item--disabled={disabled}
|
|
75
|
+
aria-pressed={active}
|
|
76
|
+
{disabled}
|
|
77
|
+
onclick={handleClick}
|
|
78
|
+
{...restProps}
|
|
79
|
+
>
|
|
80
|
+
{#if icon}
|
|
81
|
+
<span class="plasma-sidebar-item-icon">
|
|
82
|
+
{@render icon()}
|
|
83
|
+
</span>
|
|
84
|
+
{/if}
|
|
85
|
+
|
|
86
|
+
<span class="plasma-sidebar-item-label">
|
|
87
|
+
{#if children}
|
|
88
|
+
{@render children()}
|
|
89
|
+
{:else}
|
|
90
|
+
{label}
|
|
91
|
+
{/if}
|
|
92
|
+
</span>
|
|
93
|
+
|
|
94
|
+
{#if badge !== undefined}
|
|
95
|
+
<span class="plasma-sidebar-item-badge">{badge}</span>
|
|
96
|
+
{/if}
|
|
97
|
+
</button>
|
|
98
|
+
{/if}
|
|
99
|
+
|
|
100
|
+
<style>
|
|
101
|
+
.plasma-sidebar-item {
|
|
102
|
+
position: relative;
|
|
103
|
+
display: flex;
|
|
104
|
+
align-items: center;
|
|
105
|
+
gap: var(--plasma-space-sm);
|
|
106
|
+
width: 100%;
|
|
107
|
+
padding: 7px var(--plasma-space-md);
|
|
108
|
+
border: none;
|
|
109
|
+
border-radius: var(--plasma-radius-md);
|
|
110
|
+
background: transparent;
|
|
111
|
+
font-family: var(--plasma-font-sans);
|
|
112
|
+
font-size: var(--plasma-font-size-base);
|
|
113
|
+
color: var(--plasma-color-text);
|
|
114
|
+
text-decoration: none;
|
|
115
|
+
text-align: left;
|
|
116
|
+
cursor: pointer;
|
|
117
|
+
user-select: none;
|
|
118
|
+
box-sizing: border-box;
|
|
119
|
+
transition: var(--plasma-transition-fast);
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
.plasma-sidebar-item:hover:not(.plasma-sidebar-item--disabled) {
|
|
123
|
+
background-color: var(--plasma-color-surface-hover);
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
/* Active KDE Breeze Row Indicator */
|
|
127
|
+
.plasma-sidebar-item--active {
|
|
128
|
+
background-color: var(--plasma-color-highlight-soft);
|
|
129
|
+
color: var(--plasma-color-highlight);
|
|
130
|
+
font-weight: var(--plasma-font-weight-medium);
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
.plasma-sidebar-item--active::before {
|
|
134
|
+
content: "";
|
|
135
|
+
position: absolute;
|
|
136
|
+
left: 0;
|
|
137
|
+
top: 6px;
|
|
138
|
+
bottom: 6px;
|
|
139
|
+
width: 3px;
|
|
140
|
+
border-radius: var(--plasma-radius-full);
|
|
141
|
+
background-color: var(--plasma-color-highlight);
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
.plasma-sidebar-item--active .plasma-sidebar-item-icon {
|
|
145
|
+
color: var(--plasma-color-highlight);
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
.plasma-sidebar-item--disabled {
|
|
149
|
+
opacity: 0.45;
|
|
150
|
+
cursor: not-allowed;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
.plasma-sidebar-item-icon {
|
|
154
|
+
display: inline-flex;
|
|
155
|
+
align-items: center;
|
|
156
|
+
justify-content: center;
|
|
157
|
+
width: 18px;
|
|
158
|
+
height: 18px;
|
|
159
|
+
color: var(--plasma-color-text-muted);
|
|
160
|
+
flex-shrink: 0;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
.plasma-sidebar-item-label {
|
|
164
|
+
flex: 1;
|
|
165
|
+
overflow: hidden;
|
|
166
|
+
text-overflow: ellipsis;
|
|
167
|
+
white-space: nowrap;
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
.plasma-sidebar-item-badge {
|
|
171
|
+
padding: 1px 6px;
|
|
172
|
+
font-size: 11px;
|
|
173
|
+
font-weight: var(--plasma-font-weight-bold);
|
|
174
|
+
border-radius: var(--plasma-radius-full);
|
|
175
|
+
background-color: var(--plasma-color-surface-sunken);
|
|
176
|
+
color: var(--plasma-color-text-muted);
|
|
177
|
+
border: 1px solid var(--plasma-color-border-subtle);
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
.plasma-sidebar-item--active .plasma-sidebar-item-badge {
|
|
181
|
+
background-color: var(--plasma-color-highlight);
|
|
182
|
+
color: #ffffff;
|
|
183
|
+
border-color: transparent;
|
|
184
|
+
}
|
|
185
|
+
</style>
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { Snippet } from "svelte";
|
|
2
|
+
import type { HTMLAttributes } from "svelte/elements";
|
|
3
|
+
interface Props extends HTMLAttributes<HTMLAnchorElement | HTMLButtonElement> {
|
|
4
|
+
id?: string;
|
|
5
|
+
label?: string;
|
|
6
|
+
active?: boolean;
|
|
7
|
+
disabled?: boolean;
|
|
8
|
+
href?: string;
|
|
9
|
+
icon?: Snippet;
|
|
10
|
+
badge?: string | number;
|
|
11
|
+
children?: Snippet;
|
|
12
|
+
onclick?: (e: MouseEvent) => void;
|
|
13
|
+
}
|
|
14
|
+
declare const SidebarItem: import("svelte").Component<Props, {}, "">;
|
|
15
|
+
type SidebarItem = ReturnType<typeof SidebarItem>;
|
|
16
|
+
export default SidebarItem;
|
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import type { Snippet } from "svelte";
|
|
3
|
+
import type { HTMLInputAttributes } from "svelte/elements";
|
|
4
|
+
|
|
5
|
+
interface Props extends Omit<HTMLInputAttributes, "size" | "type" | "value"> {
|
|
6
|
+
value?: number;
|
|
7
|
+
min?: number;
|
|
8
|
+
max?: number;
|
|
9
|
+
step?: number;
|
|
10
|
+
disabled?: boolean;
|
|
11
|
+
showValue?: boolean;
|
|
12
|
+
label?: string;
|
|
13
|
+
children?: Snippet;
|
|
14
|
+
style?: string;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
let {
|
|
18
|
+
value = $bindable(50),
|
|
19
|
+
min = 0,
|
|
20
|
+
max = 100,
|
|
21
|
+
step = 1,
|
|
22
|
+
disabled = false,
|
|
23
|
+
showValue = false,
|
|
24
|
+
label,
|
|
25
|
+
children,
|
|
26
|
+
class: customClass = "",
|
|
27
|
+
style: customStyle = "",
|
|
28
|
+
id,
|
|
29
|
+
...restProps
|
|
30
|
+
}: Props = $props();
|
|
31
|
+
|
|
32
|
+
const percentage = $derived(
|
|
33
|
+
Math.min(100, Math.max(0, ((value - min) / (max - min)) * 100))
|
|
34
|
+
);
|
|
35
|
+
|
|
36
|
+
function handleInput(e: Event) {
|
|
37
|
+
const target = e.target as HTMLInputElement;
|
|
38
|
+
value = parseFloat(target.value);
|
|
39
|
+
}
|
|
40
|
+
</script>
|
|
41
|
+
|
|
42
|
+
<div
|
|
43
|
+
class="plasma-slider-wrapper {customClass}"
|
|
44
|
+
class:plasma-slider--disabled={disabled}
|
|
45
|
+
style={customStyle}
|
|
46
|
+
>
|
|
47
|
+
|
|
48
|
+
{#if label || children || showValue}
|
|
49
|
+
<div class="plasma-slider-header">
|
|
50
|
+
{#if children}
|
|
51
|
+
<span class="plasma-slider-label">
|
|
52
|
+
{@render children()}
|
|
53
|
+
</span>
|
|
54
|
+
{:else if label}
|
|
55
|
+
<label for={id} class="plasma-slider-label">
|
|
56
|
+
{label}
|
|
57
|
+
</label>
|
|
58
|
+
{/if}
|
|
59
|
+
|
|
60
|
+
{#if showValue}
|
|
61
|
+
<span class="plasma-slider-value">
|
|
62
|
+
{value}
|
|
63
|
+
</span>
|
|
64
|
+
{/if}
|
|
65
|
+
</div>
|
|
66
|
+
{/if}
|
|
67
|
+
|
|
68
|
+
<div class="plasma-slider-track-container">
|
|
69
|
+
<input
|
|
70
|
+
{id}
|
|
71
|
+
type="range"
|
|
72
|
+
{min}
|
|
73
|
+
{max}
|
|
74
|
+
{step}
|
|
75
|
+
{disabled}
|
|
76
|
+
{value}
|
|
77
|
+
oninput={handleInput}
|
|
78
|
+
style="--slider-percent: {percentage}%;"
|
|
79
|
+
class="plasma-slider-input"
|
|
80
|
+
{...restProps}
|
|
81
|
+
/>
|
|
82
|
+
</div>
|
|
83
|
+
</div>
|
|
84
|
+
|
|
85
|
+
<style>
|
|
86
|
+
.plasma-slider-wrapper {
|
|
87
|
+
display: inline-flex;
|
|
88
|
+
flex-direction: column;
|
|
89
|
+
gap: var(--plasma-space-xs);
|
|
90
|
+
width: 100%;
|
|
91
|
+
font-family: var(--plasma-font-sans);
|
|
92
|
+
color: var(--plasma-color-text);
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
.plasma-slider--disabled {
|
|
96
|
+
opacity: 0.45;
|
|
97
|
+
cursor: not-allowed;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
.plasma-slider-header {
|
|
101
|
+
display: flex;
|
|
102
|
+
justify-content: space-between;
|
|
103
|
+
align-items: center;
|
|
104
|
+
font-size: var(--plasma-font-size-sm);
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
.plasma-slider-label {
|
|
108
|
+
color: var(--plasma-color-text);
|
|
109
|
+
font-weight: var(--plasma-font-weight-medium);
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
.plasma-slider-value {
|
|
113
|
+
font-family: var(--plasma-font-mono);
|
|
114
|
+
font-size: var(--plasma-font-size-xs);
|
|
115
|
+
color: var(--plasma-color-text-muted);
|
|
116
|
+
background-color: var(--plasma-color-surface-sunken);
|
|
117
|
+
padding: 1px 6px;
|
|
118
|
+
border-radius: var(--plasma-radius-sm);
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
.plasma-slider-track-container {
|
|
122
|
+
position: relative;
|
|
123
|
+
display: flex;
|
|
124
|
+
align-items: center;
|
|
125
|
+
height: 20px;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
/* --------------------------------------------------------------------------
|
|
129
|
+
Range Input Reset & Breeze Styling
|
|
130
|
+
-------------------------------------------------------------------------- */
|
|
131
|
+
.plasma-slider-input {
|
|
132
|
+
-webkit-appearance: none;
|
|
133
|
+
appearance: none;
|
|
134
|
+
width: 100%;
|
|
135
|
+
height: 6px;
|
|
136
|
+
border-radius: var(--plasma-radius-full);
|
|
137
|
+
outline: none;
|
|
138
|
+
background: linear-gradient(
|
|
139
|
+
to right,
|
|
140
|
+
var(--plasma-color-highlight) 0%,
|
|
141
|
+
var(--plasma-color-highlight) var(--slider-percent),
|
|
142
|
+
var(--plasma-color-border) var(--slider-percent),
|
|
143
|
+
var(--plasma-color-border) 100%
|
|
144
|
+
);
|
|
145
|
+
margin: 0;
|
|
146
|
+
cursor: pointer;
|
|
147
|
+
transition: var(--plasma-transition-fast);
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
.plasma-slider--disabled .plasma-slider-input {
|
|
151
|
+
cursor: not-allowed;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
/* WebKit Thumb */
|
|
155
|
+
.plasma-slider-input::-webkit-slider-thumb {
|
|
156
|
+
-webkit-appearance: none;
|
|
157
|
+
appearance: none;
|
|
158
|
+
width: 16px;
|
|
159
|
+
height: 16px;
|
|
160
|
+
border-radius: var(--plasma-radius-full);
|
|
161
|
+
background-color: var(--plasma-color-surface);
|
|
162
|
+
border: 1px solid var(--plasma-color-border);
|
|
163
|
+
box-shadow: var(--plasma-shadow-xs);
|
|
164
|
+
cursor: pointer;
|
|
165
|
+
transition: var(--plasma-transition-fast);
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
.plasma-slider-input:hover:not(:disabled)::-webkit-slider-thumb {
|
|
169
|
+
border-color: var(--plasma-color-border-hover);
|
|
170
|
+
background-color: var(--plasma-color-surface-hover);
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
.plasma-slider-input:active:not(:disabled)::-webkit-slider-thumb {
|
|
174
|
+
border-color: var(--plasma-color-highlight-hover);
|
|
175
|
+
background-color: var(--plasma-color-surface-active);
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
/* Firefox Thumb */
|
|
179
|
+
.plasma-slider-input::-moz-range-thumb {
|
|
180
|
+
width: 16px;
|
|
181
|
+
height: 16px;
|
|
182
|
+
border-radius: var(--plasma-radius-full);
|
|
183
|
+
background-color: var(--plasma-color-surface);
|
|
184
|
+
border: 1px solid var(--plasma-color-border);
|
|
185
|
+
box-shadow: var(--plasma-shadow-xs);
|
|
186
|
+
cursor: pointer;
|
|
187
|
+
transition: var(--plasma-transition-fast);
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
.plasma-slider-input:hover:not(:disabled)::-moz-range-thumb {
|
|
191
|
+
border-color: var(--plasma-color-border-hover);
|
|
192
|
+
background-color: var(--plasma-color-surface-hover);
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
.plasma-slider-input:active:not(:disabled)::-moz-range-thumb {
|
|
196
|
+
border-color: var(--plasma-color-highlight-hover);
|
|
197
|
+
background-color: var(--plasma-color-surface-active);
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
/* Focus visible */
|
|
201
|
+
.plasma-slider-input:focus-visible {
|
|
202
|
+
box-shadow: var(--plasma-shadow-focus);
|
|
203
|
+
}
|
|
204
|
+
</style>
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { Snippet } from "svelte";
|
|
2
|
+
import type { HTMLInputAttributes } from "svelte/elements";
|
|
3
|
+
interface Props extends Omit<HTMLInputAttributes, "size" | "type" | "value"> {
|
|
4
|
+
value?: number;
|
|
5
|
+
min?: number;
|
|
6
|
+
max?: number;
|
|
7
|
+
step?: number;
|
|
8
|
+
disabled?: boolean;
|
|
9
|
+
showValue?: boolean;
|
|
10
|
+
label?: string;
|
|
11
|
+
children?: Snippet;
|
|
12
|
+
style?: string;
|
|
13
|
+
}
|
|
14
|
+
declare const Slider: import("svelte").Component<Props, {}, "value">;
|
|
15
|
+
type Slider = ReturnType<typeof Slider>;
|
|
16
|
+
export default Slider;
|