@geoffcox/sterling-svelte 0.0.6 → 0.0.8
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/@types/clickOutside.d.ts +5 -0
- package/buttons/Button.svelte.d.ts +1 -1
- package/buttons/{types.d.ts → Button.types.d.ts} +0 -0
- package/buttons/{types.js → Button.types.js} +0 -0
- package/display/Progress.svelte +172 -0
- package/display/Progress.svelte.d.ts +42 -0
- package/display/Progress.types.d.ts +1 -0
- package/display/Progress.types.js +1 -0
- package/index.d.ts +9 -3
- package/index.js +9 -3
- package/inputs/Input.svelte +2 -0
- package/inputs/Radio.svelte +1 -0
- package/inputs/Select.svelte +23 -17
- package/inputs/Select.svelte.d.ts +4 -5
- package/inputs/Slider.svelte +157 -77
- package/inputs/Slider.svelte.d.ts +3 -1
- package/lists/List.svelte +10 -2
- package/package.json +6 -2
- package/theme/lightTheme.js +2 -2
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
<script>export let value = 0;
|
|
2
|
+
export let max = 100;
|
|
3
|
+
export let percent = 0;
|
|
4
|
+
export let vertical = false;
|
|
5
|
+
export let colorful = "none";
|
|
6
|
+
export let disabled = false;
|
|
7
|
+
let clientHeight;
|
|
8
|
+
let clientWidth;
|
|
9
|
+
$:
|
|
10
|
+
clampMax = Math.max(1, max);
|
|
11
|
+
$:
|
|
12
|
+
clampValue = Math.max(0, Math.min(value, clampMax));
|
|
13
|
+
$:
|
|
14
|
+
ratio = clampValue / clampMax;
|
|
15
|
+
$: {
|
|
16
|
+
percent = Math.round(ratio * 100);
|
|
17
|
+
}
|
|
18
|
+
$:
|
|
19
|
+
percentHeight = clientHeight * ratio;
|
|
20
|
+
$:
|
|
21
|
+
percentWidth = clientWidth * ratio;
|
|
22
|
+
$:
|
|
23
|
+
indicatorStyle = vertical ? `height: ${percentHeight}px` : `width: ${percentWidth}px`;
|
|
24
|
+
$:
|
|
25
|
+
indicatorColor = colorful === "auto" ? percent === 100 ? "success" : "progress" : colorful;
|
|
26
|
+
</script>
|
|
27
|
+
|
|
28
|
+
<!--
|
|
29
|
+
@component
|
|
30
|
+
An indicator of a value between 0 and a maximum value.ß
|
|
31
|
+
Does not use the HTML progress element.
|
|
32
|
+
-->
|
|
33
|
+
<!-- svelte-ignore a11y-label-has-associated-control -->
|
|
34
|
+
|
|
35
|
+
<div
|
|
36
|
+
class="sterling-progress"
|
|
37
|
+
class:disabled
|
|
38
|
+
class:vertical
|
|
39
|
+
on:click
|
|
40
|
+
on:dblclick
|
|
41
|
+
on:focus
|
|
42
|
+
on:blur
|
|
43
|
+
on:mousedown
|
|
44
|
+
on:mouseenter
|
|
45
|
+
on:mouseleave
|
|
46
|
+
on:mousemove
|
|
47
|
+
on:mouseover
|
|
48
|
+
on:mouseout
|
|
49
|
+
on:mouseup
|
|
50
|
+
on:wheel
|
|
51
|
+
{...$$restProps}
|
|
52
|
+
>
|
|
53
|
+
{#if $$slots.label}
|
|
54
|
+
<div class="label-content" class:disabled>
|
|
55
|
+
<slot name="label" />
|
|
56
|
+
</div>
|
|
57
|
+
{/if}
|
|
58
|
+
<div class="progress-bar">
|
|
59
|
+
<div class="container" bind:clientWidth bind:clientHeight>
|
|
60
|
+
<div
|
|
61
|
+
class="indicator"
|
|
62
|
+
class:progress={indicatorColor === 'progress'}
|
|
63
|
+
class:success={indicatorColor === 'success'}
|
|
64
|
+
class:warning={indicatorColor === 'warning'}
|
|
65
|
+
class:error={indicatorColor === 'error'}
|
|
66
|
+
style={indicatorStyle}
|
|
67
|
+
/>
|
|
68
|
+
</div>
|
|
69
|
+
</div>
|
|
70
|
+
</div>
|
|
71
|
+
|
|
72
|
+
<style>
|
|
73
|
+
.sterling-progress {
|
|
74
|
+
display: flex;
|
|
75
|
+
flex-direction: column;
|
|
76
|
+
align-content: flex-start;
|
|
77
|
+
align-items: flex-start;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
.label-content {
|
|
81
|
+
font-size: 0.7em;
|
|
82
|
+
margin: 0.5em 0;
|
|
83
|
+
color: var(--Display__color--subtle);
|
|
84
|
+
transition: background-color 250ms, color 250ms, border-color 250ms;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
.progress-bar {
|
|
88
|
+
display: block;
|
|
89
|
+
background: var(--Common__background-color);
|
|
90
|
+
box-sizing: border-box;
|
|
91
|
+
height: 1em;
|
|
92
|
+
padding: 0.2em;
|
|
93
|
+
border-width: var(--Common__border-width);
|
|
94
|
+
border-style: var(--Common__border-style);
|
|
95
|
+
border-color: var(--Common__border-color);
|
|
96
|
+
border-radius: var(--Common__border-radius);
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
.container {
|
|
100
|
+
display: flex;
|
|
101
|
+
justify-content: flex-start;
|
|
102
|
+
width: 100%;
|
|
103
|
+
height: 100%;
|
|
104
|
+
min-width: 100px;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
.indicator {
|
|
108
|
+
background-color: var(--Display__color);
|
|
109
|
+
box-sizing: border-box;
|
|
110
|
+
height: 100%;
|
|
111
|
+
min-height: 1px;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
/* ----- Vertical ----- */
|
|
115
|
+
|
|
116
|
+
.sterling-progress.vertical {
|
|
117
|
+
align-items: center;
|
|
118
|
+
align-content: center;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
.sterling-progress.vertical .progress-bar {
|
|
122
|
+
height: unset;
|
|
123
|
+
width: 1em;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
.sterling-progress.vertical .container {
|
|
127
|
+
flex-direction: column;
|
|
128
|
+
justify-content: flex-end;
|
|
129
|
+
min-width: unset;
|
|
130
|
+
min-height: 100px;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
.sterling-progress.vertical .indicator {
|
|
134
|
+
height: unset;
|
|
135
|
+
min-height: unset;
|
|
136
|
+
min-width: 1px;
|
|
137
|
+
width: 100%;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
/* ----- Colorful ----- */
|
|
141
|
+
|
|
142
|
+
.indicator.progress {
|
|
143
|
+
background-color: var(--Display__color--progress);
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
.indicator.success {
|
|
147
|
+
background-color: var(--Display__color--success);
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
.indicator.warning {
|
|
151
|
+
background-color: var(--Display__color--warning);
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
.indicator.error {
|
|
155
|
+
background-color: var(--Display__color--error);
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
/* ----- Disabled ----- */
|
|
159
|
+
|
|
160
|
+
.label-content.disabled {
|
|
161
|
+
color: var(--Display__color--disabled);
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
.sterling-progress.disabled .progress-bar {
|
|
165
|
+
background: var(--Common__background-color--disabled);
|
|
166
|
+
border-color: var(--Common__border-color--disabled);
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
.sterling-progress.disabled .indicator {
|
|
170
|
+
background-color: var(--Display__color--disabled);
|
|
171
|
+
}
|
|
172
|
+
</style>
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { SvelteComponentTyped } from "svelte";
|
|
2
|
+
import type { ProgressColorful } from './Progress.types';
|
|
3
|
+
declare const __propDef: {
|
|
4
|
+
props: {
|
|
5
|
+
[x: string]: any;
|
|
6
|
+
value?: number | undefined;
|
|
7
|
+
max?: number | undefined;
|
|
8
|
+
percent?: number | undefined;
|
|
9
|
+
vertical?: boolean | undefined;
|
|
10
|
+
colorful?: ProgressColorful | undefined;
|
|
11
|
+
disabled?: boolean | undefined;
|
|
12
|
+
};
|
|
13
|
+
events: {
|
|
14
|
+
click: MouseEvent;
|
|
15
|
+
dblclick: MouseEvent;
|
|
16
|
+
focus: FocusEvent;
|
|
17
|
+
blur: FocusEvent;
|
|
18
|
+
mousedown: MouseEvent;
|
|
19
|
+
mouseenter: MouseEvent;
|
|
20
|
+
mouseleave: MouseEvent;
|
|
21
|
+
mousemove: MouseEvent;
|
|
22
|
+
mouseover: MouseEvent;
|
|
23
|
+
mouseout: MouseEvent;
|
|
24
|
+
mouseup: MouseEvent;
|
|
25
|
+
wheel: WheelEvent;
|
|
26
|
+
} & {
|
|
27
|
+
[evt: string]: CustomEvent<any>;
|
|
28
|
+
};
|
|
29
|
+
slots: {
|
|
30
|
+
label: {};
|
|
31
|
+
};
|
|
32
|
+
};
|
|
33
|
+
export type ProgressProps = typeof __propDef.props;
|
|
34
|
+
export type ProgressEvents = typeof __propDef.events;
|
|
35
|
+
export type ProgressSlots = typeof __propDef.slots;
|
|
36
|
+
/**
|
|
37
|
+
* An indicator of a value between 0 and a maximum value.ß
|
|
38
|
+
* Does not use the HTML progress element.
|
|
39
|
+
*/
|
|
40
|
+
export default class Progress extends SvelteComponentTyped<ProgressProps, ProgressEvents, ProgressSlots> {
|
|
41
|
+
}
|
|
42
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export type ProgressColorful = 'none' | 'auto' | 'progress' | 'success' | 'warning' | 'error';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/index.d.ts
CHANGED
|
@@ -6,9 +6,15 @@ export { darkTheme } from './theme/darkTheme';
|
|
|
6
6
|
export { lightTheme } from './theme/lightTheme';
|
|
7
7
|
export { neutrals } from './theme/colors';
|
|
8
8
|
export { toggleDarkTheme } from './theme/toggleDarkTheme';
|
|
9
|
-
export { type ButtonVariant, type ButtonShape } from './buttons/types';
|
|
9
|
+
export { type ButtonVariant, type ButtonShape } from './buttons/Button.types';
|
|
10
|
+
export { type ProgressColorful } from './display/Progress.types';
|
|
11
|
+
export { clickOutside } from './clickOutside';
|
|
10
12
|
import Button from './buttons/Button.svelte';
|
|
11
|
-
import Input from './inputs/Input.svelte';
|
|
12
13
|
import Checkbox from './inputs/Checkbox.svelte';
|
|
14
|
+
import Input from './inputs/Input.svelte';
|
|
15
|
+
import List from './lists/List.svelte';
|
|
16
|
+
import Progress from './display/Progress.svelte';
|
|
13
17
|
import Radio from './inputs/Radio.svelte';
|
|
14
|
-
|
|
18
|
+
import Select from './inputs/Select.svelte';
|
|
19
|
+
import Slider from './inputs/Slider.svelte';
|
|
20
|
+
export { Button, Checkbox, Input, List, Progress, Radio, Select, Slider };
|
package/index.js
CHANGED
|
@@ -6,9 +6,15 @@ export { darkTheme } from './theme/darkTheme';
|
|
|
6
6
|
export { lightTheme } from './theme/lightTheme';
|
|
7
7
|
export { neutrals } from './theme/colors';
|
|
8
8
|
export { toggleDarkTheme } from './theme/toggleDarkTheme';
|
|
9
|
-
export {} from './buttons/types';
|
|
9
|
+
export {} from './buttons/Button.types';
|
|
10
|
+
export {} from './display/Progress.types';
|
|
11
|
+
export { clickOutside } from './clickOutside';
|
|
10
12
|
import Button from './buttons/Button.svelte';
|
|
11
|
-
import Input from './inputs/Input.svelte';
|
|
12
13
|
import Checkbox from './inputs/Checkbox.svelte';
|
|
14
|
+
import Input from './inputs/Input.svelte';
|
|
15
|
+
import List from './lists/List.svelte';
|
|
16
|
+
import Progress from './display/Progress.svelte';
|
|
13
17
|
import Radio from './inputs/Radio.svelte';
|
|
14
|
-
|
|
18
|
+
import Select from './inputs/Select.svelte';
|
|
19
|
+
import Slider from './inputs/Slider.svelte';
|
|
20
|
+
export { Button, Checkbox, Input, List, Progress, Radio, Select, Slider };
|
package/inputs/Input.svelte
CHANGED
|
@@ -90,6 +90,7 @@ export let disabled = false;
|
|
|
90
90
|
font-size: 0.7em;
|
|
91
91
|
margin: 0.5em 0 0 0.7em;
|
|
92
92
|
color: var(--Display__color--subtle);
|
|
93
|
+
transition: background-color 250ms, color 250ms, border-color 250ms;
|
|
93
94
|
}
|
|
94
95
|
|
|
95
96
|
.label-content.disabled {
|
|
@@ -151,6 +152,7 @@ export let disabled = false;
|
|
|
151
152
|
|
|
152
153
|
.sterling-input::placeholder {
|
|
153
154
|
color: var(--Display__color--faint);
|
|
155
|
+
transition: background-color 250ms, color 250ms, border-color 250ms;
|
|
154
156
|
}
|
|
155
157
|
|
|
156
158
|
.sterling-input:disabled::placeholder {
|
package/inputs/Radio.svelte
CHANGED
package/inputs/Select.svelte
CHANGED
|
@@ -137,8 +137,7 @@ const onPendingItemSelected = (event) => {
|
|
|
137
137
|
|
|
138
138
|
<!--
|
|
139
139
|
@component
|
|
140
|
-
|
|
141
|
-
A single item can be selected and is displayed as the value.
|
|
140
|
+
A single item that can be selected from a popup list of items.
|
|
142
141
|
-->
|
|
143
142
|
<div
|
|
144
143
|
bind:this={selectRef}
|
|
@@ -178,7 +177,7 @@ A single item can be selected and is displayed as the value.
|
|
|
178
177
|
<!-- svelte-ignore a11y-label-has-associated-control -->
|
|
179
178
|
<label class="sterling-select-label">
|
|
180
179
|
{#if $$slots.label}
|
|
181
|
-
<div class="label-content">
|
|
180
|
+
<div class="label-content" class:disabled>
|
|
182
181
|
<slot name="label" />
|
|
183
182
|
</div>
|
|
184
183
|
{/if}
|
|
@@ -189,7 +188,7 @@ A single item can be selected and is displayed as the value.
|
|
|
189
188
|
</slot>
|
|
190
189
|
</div>
|
|
191
190
|
<div class="button">
|
|
192
|
-
<slot name="button">
|
|
191
|
+
<slot name="button" {open}>
|
|
193
192
|
<div class="chevron" />
|
|
194
193
|
</slot>
|
|
195
194
|
</div>
|
|
@@ -241,6 +240,15 @@ A single item can be selected and is displayed as the value.
|
|
|
241
240
|
</div>
|
|
242
241
|
|
|
243
242
|
<style>
|
|
243
|
+
/*
|
|
244
|
+
sterling-select
|
|
245
|
+
sterling-select-label
|
|
246
|
+
label-content
|
|
247
|
+
input
|
|
248
|
+
value
|
|
249
|
+
button
|
|
250
|
+
(popup)
|
|
251
|
+
*/
|
|
244
252
|
.sterling-select {
|
|
245
253
|
background-color: var(--Input__background-color);
|
|
246
254
|
border-color: var(--Input__border-color);
|
|
@@ -248,10 +256,7 @@ A single item can be selected and is displayed as the value.
|
|
|
248
256
|
border-style: var(--Input__border-style);
|
|
249
257
|
border-width: var(--Input__border-width);
|
|
250
258
|
color: var(--Input__color);
|
|
251
|
-
display: flex;
|
|
252
|
-
flex-direction: row;
|
|
253
259
|
padding: 0;
|
|
254
|
-
position: relative;
|
|
255
260
|
transition: background-color 250ms, color 250ms, border-color 250ms;
|
|
256
261
|
}
|
|
257
262
|
|
|
@@ -279,21 +284,23 @@ A single item can be selected and is displayed as the value.
|
|
|
279
284
|
outline: none;
|
|
280
285
|
}
|
|
281
286
|
|
|
282
|
-
.label {
|
|
283
|
-
display: flex;
|
|
284
|
-
flex-direction: column;
|
|
285
|
-
}
|
|
286
|
-
|
|
287
287
|
.label-content {
|
|
288
288
|
font-size: 0.7em;
|
|
289
289
|
margin: 0.5em 0.7em 0 0.7em;
|
|
290
290
|
color: var(--Display__color--subtle);
|
|
291
|
+
transition: background-color 250ms, color 250ms, border-color 250ms;
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
.label-content.disabled {
|
|
295
|
+
color: var(--Display__color--disabled);
|
|
291
296
|
}
|
|
292
297
|
|
|
293
298
|
.input {
|
|
294
|
-
display:
|
|
295
|
-
|
|
296
|
-
|
|
299
|
+
display: grid;
|
|
300
|
+
grid-template-columns: 1fr auto;
|
|
301
|
+
grid-template-rows: auto;
|
|
302
|
+
align-content: center;
|
|
303
|
+
align-items: center;
|
|
297
304
|
}
|
|
298
305
|
|
|
299
306
|
.value {
|
|
@@ -341,8 +348,7 @@ A single item can be selected and is displayed as the value.
|
|
|
341
348
|
display: none;
|
|
342
349
|
overflow: hidden;
|
|
343
350
|
position: absolute;
|
|
344
|
-
box-shadow: rgba(0, 0, 0, 0.
|
|
345
|
-
rgba(0, 0, 0, 0.12) 0px 1px 3px 0px;
|
|
351
|
+
box-shadow: rgba(0, 0, 0, 0.4) 2px 2px 4px -1px;
|
|
346
352
|
width: fit-content;
|
|
347
353
|
height: fit-content;
|
|
348
354
|
z-index: 1;
|
|
@@ -37,7 +37,9 @@ declare const __propDef: {
|
|
|
37
37
|
slots: {
|
|
38
38
|
label: {};
|
|
39
39
|
value: {};
|
|
40
|
-
button: {
|
|
40
|
+
button: {
|
|
41
|
+
open: boolean;
|
|
42
|
+
};
|
|
41
43
|
list: {};
|
|
42
44
|
default: {
|
|
43
45
|
disabled: boolean;
|
|
@@ -50,10 +52,7 @@ declare const __propDef: {
|
|
|
50
52
|
export type SelectProps = typeof __propDef.props;
|
|
51
53
|
export type SelectEvents = typeof __propDef.events;
|
|
52
54
|
export type SelectSlots = typeof __propDef.slots;
|
|
53
|
-
/**
|
|
54
|
-
* Pops up a list of items when clicked.
|
|
55
|
-
* A single item can be selected and is displayed as the value.
|
|
56
|
-
*/
|
|
55
|
+
/** A single item that can be selected from a popup list of items. */
|
|
57
56
|
export default class Select extends SvelteComponentTyped<SelectProps, SelectEvents, SelectSlots> {
|
|
58
57
|
}
|
|
59
58
|
export {};
|
package/inputs/Slider.svelte
CHANGED
|
@@ -121,64 +121,112 @@ const onKeyDown = (event) => {
|
|
|
121
121
|
<!-- @component
|
|
122
122
|
Slider lets the user chose a value within a min/max range by dragging a thumb button.
|
|
123
123
|
-->
|
|
124
|
-
|
|
125
|
-
class="sterling-slider"
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
124
|
+
{#if $$slots.label}
|
|
125
|
+
<label class="sterling-slider-label" class:vertical>
|
|
126
|
+
<div class="label-content" class:disabled>
|
|
127
|
+
<slot name="label" />
|
|
128
|
+
</div>
|
|
129
|
+
<div
|
|
130
|
+
class="sterling-slider labeled"
|
|
131
|
+
class:disabled
|
|
132
|
+
class:horizontal={!vertical}
|
|
133
|
+
class:vertical
|
|
134
|
+
role="slider"
|
|
135
|
+
aria-valuemin={0}
|
|
136
|
+
aria-valuenow={value}
|
|
137
|
+
aria-valuemax={max}
|
|
138
|
+
tabindex={!disabled ? 0 : undefined}
|
|
139
|
+
{...$$restProps}
|
|
140
|
+
on:keydown={onKeyDown}
|
|
141
|
+
on:pointerdown={onPointerDown}
|
|
142
|
+
on:pointermove={onPointerMove}
|
|
143
|
+
on:pointerup={onPointerUp}
|
|
144
|
+
>
|
|
145
|
+
<div
|
|
146
|
+
class="container"
|
|
147
|
+
bind:this={sliderRef}
|
|
148
|
+
bind:clientWidth={sliderWidth}
|
|
149
|
+
bind:clientHeight={sliderHeight}
|
|
150
|
+
>
|
|
151
|
+
<div class="track" />
|
|
152
|
+
<div
|
|
153
|
+
class="fill"
|
|
154
|
+
style={vertical ? `height: ${valueOffset}px` : `width: ${valueOffset}px`}
|
|
155
|
+
/>
|
|
156
|
+
<div
|
|
157
|
+
class="thumb"
|
|
158
|
+
style={vertical ? `bottom: ${valueOffset}px` : `left: ${valueOffset}px`}
|
|
159
|
+
/>
|
|
160
|
+
</div>
|
|
161
|
+
</div>
|
|
162
|
+
</label>
|
|
163
|
+
{:else}
|
|
136
164
|
<div
|
|
137
|
-
class="
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
165
|
+
class="sterling-slider"
|
|
166
|
+
class:disabled
|
|
167
|
+
class:horizontal={!vertical}
|
|
168
|
+
class:vertical
|
|
169
|
+
role="slider"
|
|
170
|
+
aria-valuemin={0}
|
|
171
|
+
aria-valuenow={value}
|
|
172
|
+
aria-valuemax={max}
|
|
173
|
+
tabindex={!disabled ? 0 : undefined}
|
|
174
|
+
{...$$restProps}
|
|
175
|
+
on:keydown={onKeyDown}
|
|
176
|
+
on:pointerdown={onPointerDown}
|
|
177
|
+
on:pointermove={onPointerMove}
|
|
178
|
+
on:pointerup={onPointerUp}
|
|
141
179
|
>
|
|
142
|
-
<div
|
|
143
|
-
|
|
144
|
-
|
|
180
|
+
<div
|
|
181
|
+
class="container"
|
|
182
|
+
bind:this={sliderRef}
|
|
183
|
+
bind:clientWidth={sliderWidth}
|
|
184
|
+
bind:clientHeight={sliderHeight}
|
|
185
|
+
>
|
|
186
|
+
<div class="track" />
|
|
187
|
+
<div class="fill" style={vertical ? `height: ${valueOffset}px` : `width: ${valueOffset}px`} />
|
|
188
|
+
<div class="thumb" style={vertical ? `bottom: ${valueOffset}px` : `left: ${valueOffset}px`} />
|
|
189
|
+
</div>
|
|
145
190
|
</div>
|
|
146
|
-
|
|
191
|
+
{/if}
|
|
147
192
|
|
|
148
193
|
<style>
|
|
149
|
-
.sterling-slider {
|
|
150
|
-
box-sizing: border-box;
|
|
151
|
-
outline: none;
|
|
152
|
-
padding: 0;
|
|
153
|
-
overflow: visible;
|
|
194
|
+
.sterling-slider-label {
|
|
154
195
|
display: grid;
|
|
196
|
+
grid-template-columns: 1fr;
|
|
197
|
+
grid-template-rows: auto 1fr;
|
|
155
198
|
}
|
|
156
199
|
|
|
157
|
-
.sterling-slider.
|
|
158
|
-
|
|
200
|
+
.sterling-slider-label.vertical {
|
|
201
|
+
justify-items: center;
|
|
202
|
+
height: 100%;
|
|
159
203
|
}
|
|
160
204
|
|
|
161
|
-
.
|
|
162
|
-
|
|
205
|
+
.label-content {
|
|
206
|
+
font-size: 0.7em;
|
|
207
|
+
color: var(--Display__color--subtle);
|
|
208
|
+
transition: background-color 250ms, color 250ms, border-color 250ms;
|
|
163
209
|
}
|
|
164
210
|
|
|
165
|
-
.
|
|
166
|
-
|
|
167
|
-
outline-offset: var(--Common__outline-offset);
|
|
168
|
-
outline-style: var(--Common__outline-style);
|
|
169
|
-
outline-width: var(--Common__outline-width);
|
|
211
|
+
.label-content.disabled {
|
|
212
|
+
color: var(--Display__color--disabled);
|
|
170
213
|
}
|
|
171
214
|
|
|
172
|
-
.
|
|
173
|
-
|
|
215
|
+
.sterling-slider {
|
|
216
|
+
box-sizing: border-box;
|
|
217
|
+
outline: none;
|
|
218
|
+
padding: 0;
|
|
219
|
+
overflow: visible;
|
|
220
|
+
display: grid;
|
|
221
|
+
height: 100%;
|
|
174
222
|
}
|
|
175
223
|
|
|
176
|
-
.sterling-slider.
|
|
177
|
-
|
|
224
|
+
.sterling-slider.labeled {
|
|
225
|
+
height: unset;
|
|
178
226
|
}
|
|
179
227
|
|
|
180
|
-
.
|
|
181
|
-
|
|
228
|
+
.container {
|
|
229
|
+
position: relative;
|
|
182
230
|
}
|
|
183
231
|
|
|
184
232
|
.track {
|
|
@@ -186,48 +234,11 @@ Slider lets the user chose a value within a min/max range by dragging a thumb bu
|
|
|
186
234
|
background: var(--Display__background-color);
|
|
187
235
|
}
|
|
188
236
|
|
|
189
|
-
.sterling-slider.horizontal .track {
|
|
190
|
-
left: 0;
|
|
191
|
-
right: 0;
|
|
192
|
-
top: 50%;
|
|
193
|
-
height: 3px;
|
|
194
|
-
transform: translate(0, -50%);
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
.sterling-slider.vertical .track {
|
|
198
|
-
bottom: 0;
|
|
199
|
-
left: 50%;
|
|
200
|
-
top: 0;
|
|
201
|
-
transform: translate(-50%, 0);
|
|
202
|
-
width: 3px;
|
|
203
|
-
}
|
|
204
|
-
|
|
205
|
-
.sterling-slider.disabled .track {
|
|
206
|
-
background: var(--Common__background-color--disabled);
|
|
207
|
-
}
|
|
208
|
-
|
|
209
237
|
.fill {
|
|
210
238
|
background: var(--Display__color);
|
|
211
239
|
position: absolute;
|
|
212
240
|
}
|
|
213
241
|
|
|
214
|
-
.sterling-slider.horizontal .fill {
|
|
215
|
-
height: 3px;
|
|
216
|
-
top: 50%;
|
|
217
|
-
transform: translate(0, -50%);
|
|
218
|
-
}
|
|
219
|
-
|
|
220
|
-
.sterling-slider.vertical .fill {
|
|
221
|
-
bottom: 0;
|
|
222
|
-
left: 50%;
|
|
223
|
-
transform: translate(-50%, 0);
|
|
224
|
-
width: 3px;
|
|
225
|
-
}
|
|
226
|
-
|
|
227
|
-
.sterling-slider.disabled .fill {
|
|
228
|
-
background: var(--Common__color--disabled);
|
|
229
|
-
}
|
|
230
|
-
|
|
231
242
|
.thumb {
|
|
232
243
|
background-color: var(--Button__background-color);
|
|
233
244
|
border-color: var(--Button__border-color);
|
|
@@ -249,28 +260,97 @@ Slider lets the user chose a value within a min/max range by dragging a thumb bu
|
|
|
249
260
|
width: 1.5em;
|
|
250
261
|
}
|
|
251
262
|
|
|
263
|
+
/* ----- horizontal ----- */
|
|
264
|
+
|
|
265
|
+
.sterling-slider.horizontal {
|
|
266
|
+
height: 2em;
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
.sterling-slider.horizontal .container {
|
|
270
|
+
margin: 0 0.75em;
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
.sterling-slider.horizontal .track {
|
|
274
|
+
left: 0;
|
|
275
|
+
right: 0;
|
|
276
|
+
top: 50%;
|
|
277
|
+
height: 3px;
|
|
278
|
+
transform: translate(0, -50%);
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
.sterling-slider.horizontal .fill {
|
|
282
|
+
height: 3px;
|
|
283
|
+
top: 50%;
|
|
284
|
+
transform: translate(0, -50%);
|
|
285
|
+
}
|
|
286
|
+
|
|
252
287
|
.sterling-slider.horizontal .thumb {
|
|
253
288
|
top: 50%;
|
|
254
289
|
transform: translate(-50%, -50%);
|
|
255
290
|
}
|
|
256
291
|
|
|
292
|
+
/* ----- vertical ----- */
|
|
293
|
+
|
|
294
|
+
.sterling-slider.vertical {
|
|
295
|
+
width: 2em;
|
|
296
|
+
}
|
|
297
|
+
.sterling-slider.vertical .container {
|
|
298
|
+
margin: 0.75em 0;
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
.sterling-slider.vertical .track {
|
|
302
|
+
bottom: 0;
|
|
303
|
+
left: 50%;
|
|
304
|
+
top: 0;
|
|
305
|
+
transform: translate(-50%, 0);
|
|
306
|
+
width: 3px;
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
.sterling-slider.vertical .fill {
|
|
310
|
+
bottom: 0;
|
|
311
|
+
left: 50%;
|
|
312
|
+
transform: translate(-50%, 0);
|
|
313
|
+
width: 3px;
|
|
314
|
+
}
|
|
315
|
+
|
|
257
316
|
.sterling-slider.vertical .thumb {
|
|
258
317
|
left: 50%;
|
|
259
318
|
transform: translate(-50%, 50%);
|
|
260
319
|
}
|
|
261
320
|
|
|
321
|
+
/* ----- hover ----- */
|
|
322
|
+
|
|
262
323
|
.thumb:hover {
|
|
263
324
|
background-color: var(--Button__background-color--hover);
|
|
264
325
|
border-color: var(--Button__border-color--hover);
|
|
265
326
|
color: var(--Button__color--hover);
|
|
266
327
|
}
|
|
267
328
|
|
|
329
|
+
/* ----- active ----- */
|
|
330
|
+
|
|
268
331
|
.thumb:active {
|
|
269
332
|
background-color: var(--Button__background-color--active);
|
|
270
333
|
border-color: var(--Button__border-color--active);
|
|
271
334
|
color: var(--Button__color--active);
|
|
272
335
|
}
|
|
273
336
|
|
|
337
|
+
/* ----- focus ----- */
|
|
338
|
+
.sterling-slider:focus-visible {
|
|
339
|
+
outline-color: var(--Common__outline-color);
|
|
340
|
+
outline-offset: var(--Common__outline-offset);
|
|
341
|
+
outline-style: var(--Common__outline-style);
|
|
342
|
+
outline-width: var(--Common__outline-width);
|
|
343
|
+
}
|
|
344
|
+
/* ----- disabled ----- */
|
|
345
|
+
|
|
346
|
+
.sterling-slider.disabled .track {
|
|
347
|
+
background: var(--Common__background-color--disabled);
|
|
348
|
+
}
|
|
349
|
+
|
|
350
|
+
.sterling-slider.disabled .fill {
|
|
351
|
+
background: var(--Common__color--disabled);
|
|
352
|
+
}
|
|
353
|
+
|
|
274
354
|
.sterling-slider.disabled .thumb {
|
|
275
355
|
background-color: var(--Common__background-color--disabled);
|
|
276
356
|
border-color: var(--Common__border-color--disabled);
|
package/lists/List.svelte
CHANGED
|
@@ -93,7 +93,7 @@ A list of items where a single item can be selected.
|
|
|
93
93
|
{#if $$slots.label}
|
|
94
94
|
<!-- svelte-ignore a11y-label-has-associated-control -->
|
|
95
95
|
<label class="sterling-list-label" class:horizontal class:disabled>
|
|
96
|
-
<div class="label-content">
|
|
96
|
+
<div class="label-content" class:disabled>
|
|
97
97
|
<slot name="label" />
|
|
98
98
|
</div>
|
|
99
99
|
<div
|
|
@@ -265,6 +265,7 @@ A list of items where a single item can be selected.
|
|
|
265
265
|
cursor: not-allowed;
|
|
266
266
|
}
|
|
267
267
|
|
|
268
|
+
/* The background, border, and outline are removed when labeled as the label provides them */
|
|
268
269
|
.sterling-list.labeled,
|
|
269
270
|
.sterling-list.labeled:hover,
|
|
270
271
|
.sterling-list.labeled:focus-visible,
|
|
@@ -284,6 +285,13 @@ A list of items where a single item can be selected.
|
|
|
284
285
|
font-size: 0.7em;
|
|
285
286
|
margin: 0.5em 0.7em;
|
|
286
287
|
color: var(--Display__color--subtle);
|
|
288
|
+
transition: background-color 250ms, color 250ms, border-color 250ms;
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
.label-content.disabled {
|
|
292
|
+
font-size: 0.7em;
|
|
293
|
+
margin: 0.5em 0.7em;
|
|
294
|
+
color: var(--Display__color--disabled);
|
|
287
295
|
}
|
|
288
296
|
|
|
289
297
|
.list-item {
|
|
@@ -293,7 +301,7 @@ A list of items where a single item can be selected.
|
|
|
293
301
|
padding: 0.5em;
|
|
294
302
|
outline: none;
|
|
295
303
|
text-overflow: ellipsis;
|
|
296
|
-
transition: background-color
|
|
304
|
+
transition: background-color 250ms, color 250ms, border-color 250ms;
|
|
297
305
|
white-space: nowrap;
|
|
298
306
|
}
|
|
299
307
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@geoffcox/sterling-svelte",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.8",
|
|
4
4
|
"devDependencies": {
|
|
5
5
|
"@fontsource/fira-mono": "^4.5.10",
|
|
6
6
|
"@fontsource/overpass": "^4.5.10",
|
|
@@ -9,6 +9,7 @@
|
|
|
9
9
|
"@sveltejs/adapter-static": "^1.0.0",
|
|
10
10
|
"@sveltejs/kit": "^1.0.0",
|
|
11
11
|
"@sveltejs/package": "^1.0.0",
|
|
12
|
+
"@types/uuid": "^9.0.0",
|
|
12
13
|
"@typescript-eslint/eslint-plugin": "^5.45.0",
|
|
13
14
|
"@typescript-eslint/parser": "^5.45.0",
|
|
14
15
|
"eslint": "^8.28.0",
|
|
@@ -27,13 +28,16 @@
|
|
|
27
28
|
"type": "module",
|
|
28
29
|
"dependencies": {
|
|
29
30
|
"@floating-ui/dom": "^1.1.0",
|
|
31
|
+
"lodash-es": "^4.17.21",
|
|
30
32
|
"uuid": "^9.0.0"
|
|
31
33
|
},
|
|
32
34
|
"exports": {
|
|
33
35
|
"./package.json": "./package.json",
|
|
34
36
|
"./buttons/Button.svelte": "./buttons/Button.svelte",
|
|
35
|
-
"./buttons/types": "./buttons/types.js",
|
|
37
|
+
"./buttons/Button.types": "./buttons/Button.types.js",
|
|
36
38
|
"./clickOutside": "./clickOutside.js",
|
|
39
|
+
"./display/Progress.svelte": "./display/Progress.svelte",
|
|
40
|
+
"./display/Progress.types": "./display/Progress.types.js",
|
|
37
41
|
".": "./index.js",
|
|
38
42
|
"./inputs/Checkbox.svelte": "./inputs/Checkbox.svelte",
|
|
39
43
|
"./inputs/Input.svelte": "./inputs/Input.svelte",
|
package/theme/lightTheme.js
CHANGED
|
@@ -22,8 +22,8 @@ export const lightTheme = {
|
|
|
22
22
|
'--Common__outline-width': '2px',
|
|
23
23
|
// disabled
|
|
24
24
|
'--Common__background-color--disabled': neutrals.neutral96,
|
|
25
|
-
'--Common__border-color--disabled': neutrals.
|
|
26
|
-
'--Common__color--disabled': neutrals.
|
|
25
|
+
'--Common__border-color--disabled': neutrals.neutral75,
|
|
26
|
+
'--Common__color--disabled': neutrals.neutral75,
|
|
27
27
|
// ----- Layer ---- //
|
|
28
28
|
'--Layer__background-color--1': neutrals.neutral98,
|
|
29
29
|
'--Layer__color--1': neutrals.neutral15,
|