@geoffcox/sterling-svelte 0.0.25 → 0.0.27
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/Button.svelte +79 -24
- package/Button.svelte.d.ts +1 -0
- package/Checkbox.svelte +44 -19
- package/Checkbox.svelte.d.ts +1 -0
- package/ColorPicker.constants.d.ts +1 -0
- package/ColorPicker.constants.js +1 -0
- package/ColorPicker.svelte +226 -0
- package/ColorPicker.svelte.d.ts +22 -0
- package/ColorPicker.types.d.ts +4 -0
- package/ColorPicker.types.js +1 -0
- package/Dialog.svelte +10 -10
- package/Dropdown.svelte +88 -47
- package/Dropdown.svelte.d.ts +4 -0
- package/Field.svelte +34 -46
- package/HexColorSliders.svelte +150 -0
- package/HexColorSliders.svelte.d.ts +22 -0
- package/HslColorSliders.svelte +187 -0
- package/HslColorSliders.svelte.d.ts +22 -0
- package/Input.svelte +49 -21
- package/Input.svelte.d.ts +2 -1
- package/Label.svelte +3 -3
- package/Link.svelte +63 -17
- package/Link.svelte.d.ts +1 -0
- package/List.svelte +31 -30
- package/List.svelte.d.ts +1 -0
- package/List.types.d.ts +4 -3
- package/ListItem.svelte +29 -10
- package/ListItem.svelte.d.ts +1 -1
- package/Menu.svelte +92 -121
- package/Menu.svelte.d.ts +8 -2
- package/MenuBar.svelte +77 -32
- package/MenuBar.types.d.ts +2 -2
- package/MenuButton.svelte +48 -28
- package/MenuItem.constants.d.ts +1 -0
- package/MenuItem.constants.js +1 -0
- package/MenuItem.svelte +202 -139
- package/MenuItem.svelte.d.ts +7 -3
- package/MenuItem.types.d.ts +14 -5
- package/MenuItem.utils.d.ts +2 -0
- package/MenuItem.utils.js +16 -0
- package/MenuItemDisplay.svelte +9 -2
- package/MenuItemDisplay.svelte.d.ts +1 -0
- package/MenuSeparator.svelte +3 -3
- package/Popover.svelte +68 -64
- package/Popover.svelte.d.ts +4 -2
- package/Progress.svelte +14 -14
- package/Radio.svelte +42 -16
- package/Radio.svelte.d.ts +1 -0
- package/RgbColorSliders.svelte +161 -0
- package/RgbColorSliders.svelte.d.ts +22 -0
- package/Select.svelte +50 -32
- package/Slider.svelte +108 -118
- package/Slider.svelte.d.ts +1 -0
- package/Switch.svelte +97 -34
- package/Switch.svelte.d.ts +1 -0
- package/Tab.svelte +53 -30
- package/TabList.svelte +23 -28
- package/TabList.svelte.d.ts +1 -0
- package/TabList.types.d.ts +1 -1
- package/TextArea.svelte +45 -20
- package/TextArea.svelte.d.ts +3 -2
- package/Tooltip.svelte +12 -11
- package/Tree.svelte +37 -35
- package/Tree.svelte.d.ts +2 -0
- package/Tree.types.d.ts +1 -0
- package/TreeChevron.svelte +1 -1
- package/TreeItem.svelte +47 -10
- package/TreeItem.svelte.d.ts +2 -0
- package/TreeItemDisplay.svelte +26 -8
- package/TreeItemDisplay.svelte.d.ts +2 -0
- package/actions/clickOutside.js +1 -1
- package/actions/trapKeyboardFocus.d.ts +3 -0
- package/actions/trapKeyboardFocus.js +52 -0
- package/floating-ui.types.d.ts +2 -0
- package/index.d.ts +10 -5
- package/index.js +8 -3
- package/package.json +12 -1
- package/stores/prefersReducedMotion.d.ts +1 -0
- package/stores/prefersReducedMotion.js +10 -0
- package/stores/usingKeyboard.d.ts +1 -0
- package/stores/usingKeyboard.js +13 -0
- package/theme/applyTheme.js +3 -2
- package/theme/colors.d.ts +1 -0
- package/theme/colors.js +28 -13
- package/theme/darkTheme.js +130 -87
- package/theme/lightTheme.js +107 -87
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
<script>import { createEventDispatcher } from "svelte";
|
|
2
|
+
import Input from "./Input.svelte";
|
|
3
|
+
import Slider from "./Slider.svelte";
|
|
4
|
+
import { round } from "lodash-es";
|
|
5
|
+
export let hue = 180;
|
|
6
|
+
export let saturation = 100;
|
|
7
|
+
export let lightness = 50;
|
|
8
|
+
export let alpha = 1;
|
|
9
|
+
export let colorful = false;
|
|
10
|
+
let hueText = hue.toString();
|
|
11
|
+
let saturationText = saturation.toString();
|
|
12
|
+
let lightnessText = lightness.toString();
|
|
13
|
+
let alphaText = alpha.toString();
|
|
14
|
+
$: {
|
|
15
|
+
hueText = hue.toString();
|
|
16
|
+
}
|
|
17
|
+
$: {
|
|
18
|
+
saturationText = saturation.toString();
|
|
19
|
+
}
|
|
20
|
+
$: {
|
|
21
|
+
lightnessText = lightness.toString();
|
|
22
|
+
}
|
|
23
|
+
$: {
|
|
24
|
+
alphaText = alpha.toString();
|
|
25
|
+
}
|
|
26
|
+
const dispatcher = createEventDispatcher();
|
|
27
|
+
const raiseChange = (hue2, saturation2, lightness2) => {
|
|
28
|
+
dispatcher("change", { hue: hue2, saturation: saturation2, lightness: lightness2 });
|
|
29
|
+
};
|
|
30
|
+
$:
|
|
31
|
+
raiseChange(hue, saturation, lightness);
|
|
32
|
+
const onHueInputChange = (event) => {
|
|
33
|
+
const inputChangeEvent = event;
|
|
34
|
+
const text = inputChangeEvent?.currentTarget?.value;
|
|
35
|
+
const newValue = text ? Number.parseFloat(text) : hue;
|
|
36
|
+
if (newValue && newValue !== Number.NaN) {
|
|
37
|
+
hue = Math.round(Math.max(0, Math.min(360, newValue)));
|
|
38
|
+
hueText = hue.toString();
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
const onSaturationInputChange = (event) => {
|
|
42
|
+
const inputChangeEvent = event;
|
|
43
|
+
const text = inputChangeEvent?.currentTarget?.value?.replace(/%/g, "");
|
|
44
|
+
const newValue = text ? Number.parseFloat(text) : saturation;
|
|
45
|
+
if (newValue && newValue !== Number.NaN) {
|
|
46
|
+
saturation = Math.round(Math.max(0, Math.min(100, newValue)));
|
|
47
|
+
saturationText = saturation.toString();
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
const onLightnessInputChange = (event) => {
|
|
51
|
+
const inputChangeEvent = event;
|
|
52
|
+
const text = inputChangeEvent?.currentTarget?.value?.replace(/%/g, "");
|
|
53
|
+
const newValue = text ? Number.parseFloat(text) : lightness;
|
|
54
|
+
if (newValue && newValue !== Number.NaN) {
|
|
55
|
+
lightness = Math.round(Math.max(0, Math.min(100, newValue)));
|
|
56
|
+
lightnessText = lightness.toString();
|
|
57
|
+
}
|
|
58
|
+
};
|
|
59
|
+
const onAlphaInputchange = (event) => {
|
|
60
|
+
const inputChangeEvent = event;
|
|
61
|
+
const text = inputChangeEvent?.currentTarget?.value;
|
|
62
|
+
const newValue = text ? Number.parseFloat(text) : alpha;
|
|
63
|
+
if (newValue && newValue !== Number.NaN) {
|
|
64
|
+
alpha = round(Math.max(0, Math.min(1, newValue)), 2);
|
|
65
|
+
alphaText = alpha.toString();
|
|
66
|
+
}
|
|
67
|
+
};
|
|
68
|
+
</script>
|
|
69
|
+
|
|
70
|
+
<div class="sterling-hsl-color-sliders">
|
|
71
|
+
<div class="slider hue">
|
|
72
|
+
<Slider min={0} max={360} precision={0} bind:value={hue} {colorful} />
|
|
73
|
+
</div>
|
|
74
|
+
<Input bind:value={hueText} {colorful} on:change={(e) => onHueInputChange(e)} />
|
|
75
|
+
<div class="slider saturation" style={`--hue:${hue};`}>
|
|
76
|
+
<Slider min={0} max={100} precision={0} bind:value={saturation} {colorful} />
|
|
77
|
+
</div>
|
|
78
|
+
<Input bind:value={saturationText} {colorful} on:change={(e) => onSaturationInputChange(e)} />
|
|
79
|
+
<div class="slider lightness" style={`--hue:${hue};--saturation:${saturation}%;`}>
|
|
80
|
+
<Slider min={0} max={100} precision={0} bind:value={lightness} {colorful} />
|
|
81
|
+
</div>
|
|
82
|
+
<Input bind:value={lightnessText} {colorful} on:change={(e) => onLightnessInputChange(e)} />
|
|
83
|
+
<div
|
|
84
|
+
class="slider alpha"
|
|
85
|
+
style={`--hue:${hue};--saturation:${saturation}%;--lightness:${lightness}%`}
|
|
86
|
+
>
|
|
87
|
+
<div class="alpha-hatch" />
|
|
88
|
+
<div class="alpha-gradient" />
|
|
89
|
+
<div class="alpha-slider">
|
|
90
|
+
<Slider min={0} max={1} precision={2} step={0.01} bind:value={alpha} {colorful} />
|
|
91
|
+
</div>
|
|
92
|
+
</div>
|
|
93
|
+
<Input bind:value={alphaText} {colorful} on:change={(e) => onAlphaInputchange(e)} />
|
|
94
|
+
</div>
|
|
95
|
+
|
|
96
|
+
<style>
|
|
97
|
+
.sterling-hsl-color-sliders {
|
|
98
|
+
align-items: center;
|
|
99
|
+
display: grid;
|
|
100
|
+
grid-template-columns: 1fr 5em;
|
|
101
|
+
column-gap: 0.5em;
|
|
102
|
+
row-gap: 0.25em;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
.hue {
|
|
106
|
+
background: linear-gradient(
|
|
107
|
+
to right,
|
|
108
|
+
hsl(0, 100%, 50%) 0%,
|
|
109
|
+
hsl(60, 100%, 50%) 17%,
|
|
110
|
+
hsl(120, 100%, 50%) 33%,
|
|
111
|
+
hsl(180, 100%, 50%) 50%,
|
|
112
|
+
hsl(240, 100%, 50%) 67%,
|
|
113
|
+
hsl(300, 100%, 50%) 83%,
|
|
114
|
+
hsl(0, 100%, 50%) 100%
|
|
115
|
+
);
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
.slider :global(.fill),
|
|
119
|
+
.slider :global(.sterling-slider.colorful .fill) {
|
|
120
|
+
background-color: transparent;
|
|
121
|
+
}
|
|
122
|
+
.slider :global(.track),
|
|
123
|
+
.slider :global(.sterling-slider.colorful .track) {
|
|
124
|
+
background-color: transparent;
|
|
125
|
+
opacity: 0.1;
|
|
126
|
+
background-image: linear-gradient(to right, #7f3a3a, #ffffff 1px, #000000 1px, #000000);
|
|
127
|
+
background-size: 2px 100%;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
.saturation {
|
|
131
|
+
background: linear-gradient(
|
|
132
|
+
to right,
|
|
133
|
+
hsl(var(--hue), 0%, 50%) 0%,
|
|
134
|
+
hsl(var(--hue), 100%, 50%) 100%
|
|
135
|
+
);
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
.lightness {
|
|
139
|
+
background: linear-gradient(
|
|
140
|
+
to right,
|
|
141
|
+
hsl(var(--hue), var(--saturation), 0%) 0%,
|
|
142
|
+
hsl(var(--hue), var(--saturation), 50%) 50%,
|
|
143
|
+
hsl(var(--hue), var(--saturation), 100%) 100%
|
|
144
|
+
);
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
.alpha {
|
|
148
|
+
display: grid;
|
|
149
|
+
grid-template-columns: 1fr;
|
|
150
|
+
grid-template-rows: 1fr;
|
|
151
|
+
place-content: stretch;
|
|
152
|
+
place-items: stretch;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
.alpha-gradient,
|
|
156
|
+
.alpha-hatch,
|
|
157
|
+
.alpha-slider {
|
|
158
|
+
grid-row: 1 / span 1;
|
|
159
|
+
grid-column: 1 / span 1;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
.alpha-hatch {
|
|
163
|
+
background-color: #eee;
|
|
164
|
+
opacity: 0.1;
|
|
165
|
+
background-image: repeating-linear-gradient(
|
|
166
|
+
45deg,
|
|
167
|
+
#444 25%,
|
|
168
|
+
transparent 25%,
|
|
169
|
+
transparent 75%,
|
|
170
|
+
#444 75%,
|
|
171
|
+
#444
|
|
172
|
+
),
|
|
173
|
+
repeating-linear-gradient(45deg, #444 25%, #eee 25%, #eee 75%, #444 75%, #444),
|
|
174
|
+
repeating-linear-gradient(-45deg, #444 25%, transparent 25%, transparent 75%, #444 75%, #444),
|
|
175
|
+
repeating-linear-gradient(-45deg, #444 25%, #eee 25%, #eee 75%, #444 75%, #444);
|
|
176
|
+
background-position: 0 0, 4px 4px;
|
|
177
|
+
background-size: 8px 8px;
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
.alpha-gradient {
|
|
181
|
+
background: linear-gradient(
|
|
182
|
+
to right,
|
|
183
|
+
hsla(var(--hue), var(--saturation), var(--lightness), 0) 0%,
|
|
184
|
+
hsla(var(--hue), var(--saturation), var(--lightness), 1) 100%
|
|
185
|
+
);
|
|
186
|
+
}
|
|
187
|
+
</style>
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { SvelteComponentTyped } from "svelte";
|
|
2
|
+
declare const __propDef: {
|
|
3
|
+
props: {
|
|
4
|
+
hue?: number | undefined;
|
|
5
|
+
saturation?: number | undefined;
|
|
6
|
+
lightness?: number | undefined;
|
|
7
|
+
alpha?: number | undefined;
|
|
8
|
+
colorful?: boolean | undefined;
|
|
9
|
+
};
|
|
10
|
+
events: {
|
|
11
|
+
change: CustomEvent<any>;
|
|
12
|
+
} & {
|
|
13
|
+
[evt: string]: CustomEvent<any>;
|
|
14
|
+
};
|
|
15
|
+
slots: {};
|
|
16
|
+
};
|
|
17
|
+
export type HslColorSlidersProps = typeof __propDef.props;
|
|
18
|
+
export type HslColorSlidersEvents = typeof __propDef.events;
|
|
19
|
+
export type HslColorSlidersSlots = typeof __propDef.slots;
|
|
20
|
+
export default class HslColorSliders extends SvelteComponentTyped<HslColorSlidersProps, HslColorSlidersEvents, HslColorSlidersSlots> {
|
|
21
|
+
}
|
|
22
|
+
export {};
|
package/Input.svelte
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
<script>import { idGenerator } from "./idGenerator";
|
|
2
2
|
import Label from "./Label.svelte";
|
|
3
|
+
export let colorful = false;
|
|
3
4
|
export let composed = false;
|
|
4
5
|
export let disabled = false;
|
|
5
6
|
export let id = void 0;
|
|
@@ -39,7 +40,7 @@ export const setRangeText = (replacement, start, end, selectionMode) => {
|
|
|
39
40
|
<slot {composed} {disabled} {value} />
|
|
40
41
|
</Label>
|
|
41
42
|
{/if}
|
|
42
|
-
<div class="sterling-input" class:composed class:disabled>
|
|
43
|
+
<div class="sterling-input" class:colorful class:composed class:disabled>
|
|
43
44
|
<input
|
|
44
45
|
bind:this={inputRef}
|
|
45
46
|
{disabled}
|
|
@@ -77,7 +78,7 @@ export const setRangeText = (replacement, start, end, selectionMode) => {
|
|
|
77
78
|
on:select
|
|
78
79
|
on:submit
|
|
79
80
|
on:reset
|
|
80
|
-
on:wheel
|
|
81
|
+
on:wheel|passive
|
|
81
82
|
{...$$restProps}
|
|
82
83
|
/>
|
|
83
84
|
</div>
|
|
@@ -92,33 +93,54 @@ export const setRangeText = (replacement, start, end, selectionMode) => {
|
|
|
92
93
|
}
|
|
93
94
|
|
|
94
95
|
input {
|
|
95
|
-
background-color: var(--stsv-
|
|
96
|
-
border-color: var(--stsv-
|
|
97
|
-
border-radius: var(--stsv-
|
|
98
|
-
border-style: var(--stsv-
|
|
99
|
-
border-width: var(--stsv-
|
|
100
|
-
|
|
96
|
+
background-color: var(--stsv-input__background-color);
|
|
97
|
+
border-color: var(--stsv-input__border-color);
|
|
98
|
+
border-radius: var(--stsv-input__border-radius);
|
|
99
|
+
border-style: var(--stsv-input__border-style);
|
|
100
|
+
border-width: var(--stsv-input__border-width);
|
|
101
|
+
box-sizing: border-box;
|
|
102
|
+
color: var(--stsv-input__color);
|
|
103
|
+
display: block;
|
|
101
104
|
font: inherit;
|
|
102
105
|
margin: 0;
|
|
103
106
|
outline: none;
|
|
104
107
|
padding: 0.5em;
|
|
105
108
|
transition: background-color 250ms, color 250ms, border-color 250ms;
|
|
109
|
+
width: 100%;
|
|
106
110
|
}
|
|
107
111
|
|
|
108
|
-
.sterling-input:hover input {
|
|
109
|
-
background-color: var(--stsv-
|
|
110
|
-
border-color: var(--stsv-
|
|
111
|
-
color: var(--stsv-
|
|
112
|
+
.sterling-input:hover input:not(:disabled) {
|
|
113
|
+
background-color: var(--stsv-input__background-color--hover);
|
|
114
|
+
border-color: var(--stsv-input__border-color--hover);
|
|
115
|
+
color: var(--stsv-input__color--hover);
|
|
112
116
|
}
|
|
113
117
|
|
|
114
118
|
input:focus {
|
|
115
|
-
background-color: var(--stsv-
|
|
116
|
-
border-color: var(--stsv-
|
|
117
|
-
color: var(--stsv-
|
|
118
|
-
outline-color: var(--stsv-
|
|
119
|
-
outline-offset: var(--stsv-
|
|
120
|
-
outline-style: var(--stsv-
|
|
121
|
-
outline-width: var(--stsv-
|
|
119
|
+
background-color: var(--stsv-input__background-color--focus);
|
|
120
|
+
border-color: var(--stsv-input__border-color--focus);
|
|
121
|
+
color: var(--stsv-input__color--focus);
|
|
122
|
+
outline-color: var(--stsv-common__outline-color);
|
|
123
|
+
outline-offset: var(--stsv-common__outline-offset);
|
|
124
|
+
outline-style: var(--stsv-common__outline-style);
|
|
125
|
+
outline-width: var(--stsv-common__outline-width);
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
.sterling-input.colorful input {
|
|
129
|
+
background-color: var(--stsv-input--colorful__background-color);
|
|
130
|
+
border-color: var(--stsv-input--colorful__border-color);
|
|
131
|
+
color: var(--stsv-input--colorful__color);
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
.sterling-input.colorful:hover input:not(:disabled) {
|
|
135
|
+
background-color: var(--stsv-input--colorful__background-color--hover);
|
|
136
|
+
border-color: var(--stsv-input--colorful__border-color--hover);
|
|
137
|
+
color: var(--stsv-input--colorful__color--hover);
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
.sterling-input.colorful input:focus {
|
|
141
|
+
background-color: var(--stsv-input--colorful__background-color--focus);
|
|
142
|
+
border-color: var(--stsv-input--colorful__border-color--focus);
|
|
143
|
+
color: var(--stsv-input--colorful__color--focus);
|
|
122
144
|
}
|
|
123
145
|
|
|
124
146
|
.sterling-input.composed input,
|
|
@@ -130,7 +152,7 @@ export const setRangeText = (replacement, start, end, selectionMode) => {
|
|
|
130
152
|
}
|
|
131
153
|
|
|
132
154
|
input::placeholder {
|
|
133
|
-
color: var(--stsv-
|
|
155
|
+
color: var(--stsv-common__color--subtle);
|
|
134
156
|
}
|
|
135
157
|
|
|
136
158
|
.sterling-input.disabled * {
|
|
@@ -139,7 +161,13 @@ export const setRangeText = (replacement, start, end, selectionMode) => {
|
|
|
139
161
|
}
|
|
140
162
|
|
|
141
163
|
.sterling-input::after {
|
|
142
|
-
background:
|
|
164
|
+
background: repeating-linear-gradient(
|
|
165
|
+
45deg,
|
|
166
|
+
var(--stsv-common__background-color1--disabled),
|
|
167
|
+
var(--stsv-common__background-color1--disabled) 3px,
|
|
168
|
+
var(--stsv-common__background-color2--disabled) 3px,
|
|
169
|
+
var(--stsv-common__background-color2--disabled) 6px
|
|
170
|
+
);
|
|
143
171
|
bottom: 0;
|
|
144
172
|
content: '';
|
|
145
173
|
left: 0;
|
package/Input.svelte.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ import { SvelteComponentTyped } from "svelte";
|
|
|
2
2
|
declare const __propDef: {
|
|
3
3
|
props: {
|
|
4
4
|
[x: string]: any;
|
|
5
|
+
colorful?: boolean | undefined;
|
|
5
6
|
composed?: boolean | undefined;
|
|
6
7
|
disabled?: boolean | undefined;
|
|
7
8
|
id?: string | undefined;
|
|
@@ -66,7 +67,7 @@ export default class Input extends SvelteComponentTyped<InputProps, InputEvents,
|
|
|
66
67
|
get click(): () => void;
|
|
67
68
|
get focus(): (options?: FocusOptions | undefined) => void;
|
|
68
69
|
get select(): () => void;
|
|
69
|
-
get setSelectionRange(): (start: number | null, end: number | null, direction?: "
|
|
70
|
+
get setSelectionRange(): (start: number | null, end: number | null, direction?: "forward" | "backward" | "none" | undefined) => void;
|
|
70
71
|
get setRangeText(): (replacement: string, start?: number | undefined, end?: number | undefined, selectionMode?: SelectionMode | undefined) => void;
|
|
71
72
|
}
|
|
72
73
|
export {};
|
package/Label.svelte
CHANGED
|
@@ -41,7 +41,7 @@ export const focus = (options) => {
|
|
|
41
41
|
on:mouseout
|
|
42
42
|
on:mouseup
|
|
43
43
|
on:scroll
|
|
44
|
-
on:wheel
|
|
44
|
+
on:wheel|passive
|
|
45
45
|
on:paste
|
|
46
46
|
{...$$restProps}
|
|
47
47
|
>
|
|
@@ -50,13 +50,13 @@ export const focus = (options) => {
|
|
|
50
50
|
|
|
51
51
|
<style>
|
|
52
52
|
label {
|
|
53
|
-
color: var(--stsv-
|
|
53
|
+
color: var(--stsv-common__color);
|
|
54
54
|
transition: color 250ms;
|
|
55
55
|
font: inherit;
|
|
56
56
|
}
|
|
57
57
|
|
|
58
58
|
label.disabled {
|
|
59
|
-
color: var(--stsv-
|
|
59
|
+
color: var(--stsv-common__color--disabled);
|
|
60
60
|
}
|
|
61
61
|
|
|
62
62
|
@media (prefers-reduced-motion) {
|
package/Link.svelte
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
<script>export let
|
|
1
|
+
<script>export let colorful = false;
|
|
2
|
+
export let href;
|
|
2
3
|
export let disabled = false;
|
|
3
4
|
export let variant = "regular";
|
|
4
5
|
let linkRef;
|
|
@@ -16,6 +17,7 @@ export const focus = (options) => {
|
|
|
16
17
|
<a
|
|
17
18
|
bind:this={linkRef}
|
|
18
19
|
class="sterling-link"
|
|
20
|
+
class:colorful
|
|
19
21
|
class:disabled
|
|
20
22
|
class:ghost={variant === 'ghost'}
|
|
21
23
|
class:undecorated={variant === 'undecorated'}
|
|
@@ -50,7 +52,7 @@ export const focus = (options) => {
|
|
|
50
52
|
on:pointerover
|
|
51
53
|
on:pointerout
|
|
52
54
|
on:pointerup
|
|
53
|
-
on:wheel
|
|
55
|
+
on:wheel|passive
|
|
54
56
|
{...$$restProps}><slot {disabled} {href} {variant} /></a
|
|
55
57
|
>
|
|
56
58
|
|
|
@@ -61,10 +63,10 @@ export const focus = (options) => {
|
|
|
61
63
|
border-left: none;
|
|
62
64
|
border-right: none;
|
|
63
65
|
border-radius: 0;
|
|
64
|
-
border-bottom-style: var(--stsv-
|
|
65
|
-
border-bottom-width: calc(var(--stsv-
|
|
66
|
-
border-bottom-color: var(--stsv-
|
|
67
|
-
color: var(--stsv-
|
|
66
|
+
border-bottom-style: var(--stsv-common__border-style);
|
|
67
|
+
border-bottom-width: calc(var(--stsv-common__border-width));
|
|
68
|
+
border-bottom-color: var(--stsv-common__border-color);
|
|
69
|
+
color: var(--stsv-common__color);
|
|
68
70
|
cursor: pointer;
|
|
69
71
|
font: inherit;
|
|
70
72
|
text-decoration: none;
|
|
@@ -75,34 +77,78 @@ export const focus = (options) => {
|
|
|
75
77
|
}
|
|
76
78
|
|
|
77
79
|
a:visited {
|
|
78
|
-
border-bottom-color: var(--stsv-
|
|
80
|
+
border-bottom-color: var(--stsv-input__border-color);
|
|
79
81
|
}
|
|
80
82
|
|
|
83
|
+
a:hover {
|
|
84
|
+
border-bottom-color: var(--stsv-input__border-color--hover);
|
|
85
|
+
color: var(--stsv-input__color--hover);
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
a:active {
|
|
89
|
+
border-bottom-color: var(--stsv-input__border-color--selected);
|
|
90
|
+
color: var(--stsv-input__color--active);
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
/* ----- colorful ----- */
|
|
94
|
+
|
|
95
|
+
a.colorful,
|
|
96
|
+
a.colorful:visited {
|
|
97
|
+
border-bottom-color: var(--stsv-input--colorful__border-color);
|
|
98
|
+
color: var(--stsv-input--colorful__color);
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
a.colorful:hover {
|
|
102
|
+
border-bottom-color: var(--stsv-input--colorful__border-color--hover);
|
|
103
|
+
color: var(--stsv-input--colorful__color--hover);
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
a.colorful:active {
|
|
107
|
+
border-bottom-color: var(--stsv-input--colorful__border-color--selected);
|
|
108
|
+
color: var(--stsv-input--colorful__color--active);
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
/* ----- ghost ----- */
|
|
112
|
+
|
|
81
113
|
a.ghost {
|
|
82
114
|
border-bottom-color: transparent;
|
|
83
115
|
}
|
|
84
116
|
|
|
85
|
-
a:hover {
|
|
86
|
-
border-bottom-color: var(--stsv-
|
|
87
|
-
color: var(--stsv-Button__color--hover);
|
|
117
|
+
a.ghost:hover {
|
|
118
|
+
border-bottom-color: var(--stsv-input__border-color--hover);
|
|
88
119
|
}
|
|
89
120
|
|
|
90
|
-
a:active {
|
|
91
|
-
border-bottom-color: var(--stsv-
|
|
92
|
-
color: var(--stsv-Button__color--active);
|
|
121
|
+
a.ghost:active {
|
|
122
|
+
border-bottom-color: var(--stsv-input__border-color--selected);
|
|
93
123
|
}
|
|
94
124
|
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
125
|
+
/* ----- ghost colorful ----- */
|
|
126
|
+
|
|
127
|
+
a.ghost.colorful:hover {
|
|
128
|
+
border-bottom-color: var(--stsv-input--colorful__border-color--hover);
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
a.ghost.colorful:active {
|
|
132
|
+
border-bottom-color: var(--stsv-input--colorful__border-color--selected);
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
/* ----- disabled ----- */
|
|
136
|
+
|
|
137
|
+
a.disabled,
|
|
138
|
+
a.disabled:visited,
|
|
139
|
+
a.disabled:hover,
|
|
140
|
+
a.disabled:active {
|
|
141
|
+
border-bottom-color: var(--stsv-common__border-color--disabled);
|
|
142
|
+
color: var(--stsv-common__color--disabled);
|
|
98
143
|
cursor: not-allowed;
|
|
99
144
|
pointer-events: none;
|
|
100
145
|
}
|
|
101
146
|
|
|
147
|
+
/* ----- undecorated ----- */
|
|
102
148
|
a.undecorated,
|
|
103
149
|
a.undecorated:hover,
|
|
104
150
|
a.undecorated:active,
|
|
105
151
|
a.undecorated:visited {
|
|
106
|
-
border:
|
|
152
|
+
border-bottom-color: transparent;
|
|
107
153
|
}
|
|
108
154
|
</style>
|
package/Link.svelte.d.ts
CHANGED
package/List.svelte
CHANGED
|
@@ -1,16 +1,21 @@
|
|
|
1
|
-
<script>import {
|
|
2
|
-
import { createEventDispatcher, onMount, setContext } from "svelte";
|
|
1
|
+
<script>import { createEventDispatcher, setContext } from "svelte";
|
|
3
2
|
import { writable } from "svelte/store";
|
|
4
3
|
import { LIST_CONTEXT_KEY } from "./List.constants";
|
|
4
|
+
import { usingKeyboard } from "./stores/usingKeyboard";
|
|
5
|
+
export let colorful = false;
|
|
5
6
|
export let composed = false;
|
|
6
7
|
export let disabled = false;
|
|
7
8
|
export let horizontal = false;
|
|
8
9
|
export let selectedValue = void 0;
|
|
9
10
|
let listRef;
|
|
10
11
|
let lastSelectedItemRef;
|
|
12
|
+
const colorfulStore = writable(colorful);
|
|
11
13
|
const disabledStore = writable(disabled);
|
|
12
14
|
const horizontalStore = writable(horizontal);
|
|
13
15
|
const selectedValueStore = writable(selectedValue);
|
|
16
|
+
$: {
|
|
17
|
+
colorfulStore.set(colorful);
|
|
18
|
+
}
|
|
14
19
|
$: {
|
|
15
20
|
disabledStore.set(disabled);
|
|
16
21
|
}
|
|
@@ -43,11 +48,6 @@ export const scrollToSelectedItem = () => {
|
|
|
43
48
|
const element = getSelectedItemElement();
|
|
44
49
|
element?.scrollIntoView({ block: "nearest", inline: "nearest" });
|
|
45
50
|
};
|
|
46
|
-
let keyborg = createKeyborg(window);
|
|
47
|
-
let usingKeyboard = keyborg.isNavigatingWithKeyboard();
|
|
48
|
-
const keyborgHandler = (value) => {
|
|
49
|
-
usingKeyboard = value;
|
|
50
|
-
};
|
|
51
51
|
const isElementListItem = (candidate) => {
|
|
52
52
|
return candidate && candidate.getAttribute("data-value") !== null && candidate.getAttribute("data-value") !== void 0 && candidate.getAttribute("role") === "listitem";
|
|
53
53
|
};
|
|
@@ -113,12 +113,6 @@ export const selectLastItem = () => {
|
|
|
113
113
|
}
|
|
114
114
|
return false;
|
|
115
115
|
};
|
|
116
|
-
onMount(() => {
|
|
117
|
-
keyborg.subscribe(keyborgHandler);
|
|
118
|
-
return () => {
|
|
119
|
-
keyborg.unsubscribe(keyborgHandler);
|
|
120
|
-
};
|
|
121
|
-
});
|
|
122
116
|
const onClick = (event) => {
|
|
123
117
|
if (!disabled) {
|
|
124
118
|
let candidate = event.target;
|
|
@@ -177,6 +171,7 @@ const onKeydown = (event) => {
|
|
|
177
171
|
}
|
|
178
172
|
};
|
|
179
173
|
setContext(LIST_CONTEXT_KEY, {
|
|
174
|
+
colorful: colorfulStore,
|
|
180
175
|
disabled: disabledStore,
|
|
181
176
|
selectedValue: selectedValueStore,
|
|
182
177
|
horizontal: horizontalStore
|
|
@@ -197,7 +192,7 @@ A list of items where a single item can be selected.
|
|
|
197
192
|
class:composed
|
|
198
193
|
class:disabled
|
|
199
194
|
class:horizontal
|
|
200
|
-
class:using-keyboard={usingKeyboard}
|
|
195
|
+
class:using-keyboard={$usingKeyboard}
|
|
201
196
|
role="list"
|
|
202
197
|
tabindex={0}
|
|
203
198
|
on:blur
|
|
@@ -227,7 +222,7 @@ A list of items where a single item can be selected.
|
|
|
227
222
|
on:mouseout
|
|
228
223
|
on:mouseup
|
|
229
224
|
on:scroll
|
|
230
|
-
on:wheel
|
|
225
|
+
on:wheel|passive
|
|
231
226
|
on:paste
|
|
232
227
|
{...$$restProps}
|
|
233
228
|
>
|
|
@@ -238,13 +233,13 @@ A list of items where a single item can be selected.
|
|
|
238
233
|
|
|
239
234
|
<style>
|
|
240
235
|
.sterling-list {
|
|
241
|
-
background-color: var(--stsv-
|
|
242
|
-
border-color: var(--stsv-
|
|
243
|
-
border-radius: var(--stsv-
|
|
244
|
-
border-style: var(--stsv-
|
|
245
|
-
border-width: var(--stsv-
|
|
236
|
+
background-color: var(--stsv-common__background-color);
|
|
237
|
+
border-color: var(--stsv-input__border-color);
|
|
238
|
+
border-radius: var(--stsv-input__border-radius);
|
|
239
|
+
border-style: var(--stsv-input__border-style);
|
|
240
|
+
border-width: var(--stsv-input__border-width);
|
|
246
241
|
box-sizing: border-box;
|
|
247
|
-
color: var(--stsv-
|
|
242
|
+
color: var(--stsv-input__color);
|
|
248
243
|
height: 100%;
|
|
249
244
|
overflow-x: hidden;
|
|
250
245
|
overflow-y: auto;
|
|
@@ -263,17 +258,17 @@ A list of items where a single item can be selected.
|
|
|
263
258
|
}
|
|
264
259
|
|
|
265
260
|
.sterling-list:hover {
|
|
266
|
-
border-color: var(--stsv-
|
|
267
|
-
color: var(--stsv-
|
|
261
|
+
border-color: var(--stsv-input__border-color--hover);
|
|
262
|
+
color: var(--stsv-input__color--hover);
|
|
268
263
|
}
|
|
269
264
|
|
|
270
265
|
.sterling-list.using-keyboard:focus-within {
|
|
271
|
-
border-color: var(--stsv-
|
|
272
|
-
color: var(--stsv-
|
|
273
|
-
outline-color: var(--stsv-
|
|
274
|
-
outline-offset: var(--stsv-
|
|
275
|
-
outline-style: var(--stsv-
|
|
276
|
-
outline-width: var(--stsv-
|
|
266
|
+
border-color: var(--stsv-input__border-color--focus);
|
|
267
|
+
color: var(--stsv-input__color--focus);
|
|
268
|
+
outline-color: var(--stsv-common__outline-color);
|
|
269
|
+
outline-offset: var(--stsv-common__outline-offset);
|
|
270
|
+
outline-style: var(--stsv-common__outline-style);
|
|
271
|
+
outline-width: var(--stsv-common__outline-width);
|
|
277
272
|
}
|
|
278
273
|
|
|
279
274
|
.sterling-list.composed,
|
|
@@ -303,7 +298,13 @@ A list of items where a single item can be selected.
|
|
|
303
298
|
}
|
|
304
299
|
|
|
305
300
|
.container::after {
|
|
306
|
-
background:
|
|
301
|
+
background: repeating-linear-gradient(
|
|
302
|
+
45deg,
|
|
303
|
+
var(--stsv-common__background-color1--disabled),
|
|
304
|
+
var(--stsv-common__background-color1--disabled) 3px,
|
|
305
|
+
var(--stsv-common__background-color2--disabled) 3px,
|
|
306
|
+
var(--stsv-common__background-color2--disabled) 6px
|
|
307
|
+
);
|
|
307
308
|
content: '';
|
|
308
309
|
bottom: 0;
|
|
309
310
|
left: 0;
|
package/List.svelte.d.ts
CHANGED
package/List.types.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { Readable, Writable } from 'svelte/store';
|
|
2
2
|
export type ListContext = {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
colorful?: Readable<boolean>;
|
|
4
|
+
disabled?: Readable<boolean>;
|
|
5
|
+
selectedValue?: Writable<string | undefined>;
|
|
6
|
+
horizontal?: Readable<boolean>;
|
|
6
7
|
};
|