@geoffcox/sterling-svelte 0.0.23 → 0.0.24
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 +17 -22
- package/Button.svelte.d.ts +1 -0
- package/Checkbox.svelte +41 -14
- package/Dropdown.svelte +26 -7
- package/Field.svelte +11 -12
- package/Input.svelte +78 -60
- package/List.svelte +46 -16
- package/ListItem.svelte +30 -7
- package/MenuItem.svelte +6 -7
- package/MenuItemDisplay.svelte +33 -2
- package/MenuItemDisplay.svelte.d.ts +1 -0
- package/Progress.svelte +0 -13
- package/Progress.svelte.d.ts +0 -1
- package/Radio.svelte +28 -9
- package/Select.svelte +24 -4
- package/Slider.svelte +19 -10
- package/Switch.svelte +31 -11
- package/Tab.svelte +25 -3
- package/TabList.svelte +2 -2
- package/TextArea.svelte +81 -56
- package/TextArea.svelte.d.ts +1 -0
- package/Tree.svelte +44 -13
- package/TreeItem.svelte +8 -8
- package/TreeItem.svelte.d.ts +0 -1
- package/TreeItemDisplay.svelte +36 -11
- package/package.json +1 -1
- package/theme/darkTheme.js +9 -0
- package/theme/lightTheme.js +9 -0
package/Button.svelte
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
<script>export let
|
|
1
|
+
<script>export let disabled = false;
|
|
2
|
+
export let variant = "regular";
|
|
2
3
|
export let shape = "rounded";
|
|
3
4
|
let buttonRef;
|
|
4
5
|
export const click = () => {
|
|
@@ -23,6 +24,7 @@ export const focus = (options) => {
|
|
|
23
24
|
class:circular={shape === 'circular'}
|
|
24
25
|
class:outline={variant === 'outline'}
|
|
25
26
|
class:ghost={variant === 'ghost'}
|
|
27
|
+
{disabled}
|
|
26
28
|
type="button"
|
|
27
29
|
on:blur
|
|
28
30
|
on:click
|
|
@@ -122,13 +124,6 @@ export const focus = (options) => {
|
|
|
122
124
|
outline-width: var(--stsv-Common__outline-width);
|
|
123
125
|
}
|
|
124
126
|
|
|
125
|
-
button:disabled {
|
|
126
|
-
background-color: var(--stsv-Common__background-color--disabled);
|
|
127
|
-
border-color: var(--stsv-Common__border-color--disabled);
|
|
128
|
-
color: var(--stsv-Common__color--disabled);
|
|
129
|
-
cursor: not-allowed;
|
|
130
|
-
}
|
|
131
|
-
|
|
132
127
|
button.outline {
|
|
133
128
|
background-color: transparent;
|
|
134
129
|
}
|
|
@@ -141,14 +136,6 @@ export const focus = (options) => {
|
|
|
141
136
|
background-color: var(--stsv-Button__background-color--active);
|
|
142
137
|
}
|
|
143
138
|
|
|
144
|
-
button.outline:disabled {
|
|
145
|
-
background-color: transparent;
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
button.outline:disabled:hover {
|
|
149
|
-
border-color: var(--stsv-Common__border-color--disabled);
|
|
150
|
-
}
|
|
151
|
-
|
|
152
139
|
button.ghost {
|
|
153
140
|
background-color: transparent;
|
|
154
141
|
border-color: transparent;
|
|
@@ -168,12 +155,20 @@ export const focus = (options) => {
|
|
|
168
155
|
border-color: var(--stsv-Button__border-color--focus);
|
|
169
156
|
}
|
|
170
157
|
|
|
171
|
-
button
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
158
|
+
button:disabled {
|
|
159
|
+
cursor: not-allowed;
|
|
160
|
+
position: relative;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
button:disabled::after {
|
|
164
|
+
content: '';
|
|
165
|
+
position: absolute;
|
|
166
|
+
left: 0;
|
|
167
|
+
right: 0;
|
|
168
|
+
top: 0;
|
|
169
|
+
bottom: 0;
|
|
170
|
+
background: var(--stsv-Disabled__background);
|
|
171
|
+
pointer-events: none;
|
|
177
172
|
}
|
|
178
173
|
|
|
179
174
|
@media (prefers-reduced-motion) {
|
package/Button.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
|
+
disabled?: boolean | undefined;
|
|
5
6
|
variant?: "regular" | "outline" | "ghost" | undefined;
|
|
6
7
|
shape?: "circular" | "rounded" | "square" | undefined;
|
|
7
8
|
click?: (() => void) | undefined;
|
package/Checkbox.svelte
CHANGED
|
@@ -24,10 +24,11 @@ export const focus = (options) => {
|
|
|
24
24
|
@component
|
|
25
25
|
A styled HTML input type=checkbox element.
|
|
26
26
|
-->
|
|
27
|
-
<div class="sterling-checkbox">
|
|
27
|
+
<div class="sterling-checkbox" class:disabled>
|
|
28
28
|
<div class="container">
|
|
29
29
|
<input
|
|
30
30
|
bind:this={inputRef}
|
|
31
|
+
bind:checked
|
|
31
32
|
{disabled}
|
|
32
33
|
{id}
|
|
33
34
|
type="checkbox"
|
|
@@ -56,13 +57,12 @@ export const focus = (options) => {
|
|
|
56
57
|
on:mouseout
|
|
57
58
|
on:mouseup
|
|
58
59
|
on:wheel
|
|
59
|
-
bind:checked
|
|
60
60
|
{...$$restProps}
|
|
61
61
|
/>
|
|
62
62
|
<div class="indicator" />
|
|
63
63
|
</div>
|
|
64
64
|
{#if $$slots.default}
|
|
65
|
-
<Label
|
|
65
|
+
<Label for={id}>
|
|
66
66
|
<slot {checked} {disabled} inputId={id} value={$$restProps.value}>
|
|
67
67
|
{$$restProps.value}
|
|
68
68
|
</slot>
|
|
@@ -133,6 +133,11 @@ export const focus = (options) => {
|
|
|
133
133
|
border-color: var(--stsv-Input__border-color);
|
|
134
134
|
}
|
|
135
135
|
|
|
136
|
+
.sterling-checkbox:hover .indicator {
|
|
137
|
+
background-color: var(--stsv-Input__background-color--hover);
|
|
138
|
+
border-color: var(--stsv-Input__border-color--hover);
|
|
139
|
+
}
|
|
140
|
+
|
|
136
141
|
input:focus-visible + .indicator {
|
|
137
142
|
outline-color: var(--stsv-Common__outline-color);
|
|
138
143
|
outline-offset: var(--stsv-Common__outline-offset);
|
|
@@ -140,15 +145,10 @@ export const focus = (options) => {
|
|
|
140
145
|
outline-width: var(--stsv-Common__outline-width);
|
|
141
146
|
}
|
|
142
147
|
|
|
143
|
-
input:disabled + .indicator {
|
|
144
|
-
background-color: var(--stsv-Common__background-color--disabled);
|
|
145
|
-
border-color: var(--stsv-Common__border-color--disabled);
|
|
146
|
-
}
|
|
147
|
-
|
|
148
148
|
/*
|
|
149
149
|
The checkmark is a rotated L centered in the box.
|
|
150
150
|
*/
|
|
151
|
-
|
|
151
|
+
.indicator::after {
|
|
152
152
|
border-color: var(--stsv-Input__color);
|
|
153
153
|
border-style: solid;
|
|
154
154
|
border-width: 0 3px 3px 0;
|
|
@@ -160,18 +160,45 @@ export const focus = (options) => {
|
|
|
160
160
|
top: 45%;
|
|
161
161
|
transform: translate(-50%, -50%) rotate(45deg);
|
|
162
162
|
transform-origin: center;
|
|
163
|
-
transition: border-color 250ms;
|
|
163
|
+
transition: border-color 250ms, opacity 150ms;
|
|
164
164
|
width: 7px;
|
|
165
|
-
|
|
165
|
+
opacity: 0;
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
input:checked + .indicator::after {
|
|
169
|
+
opacity: 1;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
.sterling-checkbox:hover input:checked + .indicator::after {
|
|
173
|
+
border-color: var(--stsv-Input__color--hover);
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
.sterling-checkbox.disabled,
|
|
177
|
+
.sterling-checkbox.disabled input {
|
|
178
|
+
cursor: not-allowed;
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
.container::after {
|
|
182
|
+
background: var(--stsv-Disabled__background);
|
|
183
|
+
bottom: 0;
|
|
184
|
+
content: '';
|
|
185
|
+
left: 0;
|
|
186
|
+
opacity: 0;
|
|
187
|
+
position: absolute;
|
|
188
|
+
right: 0;
|
|
189
|
+
top: 0;
|
|
190
|
+
pointer-events: none;
|
|
191
|
+
transition: opacity 250ms;
|
|
166
192
|
}
|
|
167
193
|
|
|
168
|
-
|
|
169
|
-
|
|
194
|
+
.sterling-checkbox.disabled .container::after {
|
|
195
|
+
opacity: 1;
|
|
170
196
|
}
|
|
171
197
|
|
|
172
198
|
@media (prefers-reduced-motion) {
|
|
173
199
|
.indicator,
|
|
174
|
-
|
|
200
|
+
.indicator::after,
|
|
201
|
+
.container::after {
|
|
175
202
|
transition: none;
|
|
176
203
|
}
|
|
177
204
|
}
|
package/Dropdown.svelte
CHANGED
|
@@ -123,7 +123,7 @@ const onClickOutside = (event) => {
|
|
|
123
123
|
<div
|
|
124
124
|
bind:this={popupRef}
|
|
125
125
|
class="popup"
|
|
126
|
-
class:open
|
|
126
|
+
class:open={open && !disabled}
|
|
127
127
|
id={popupId}
|
|
128
128
|
style="left:{popupPosition.x}px; top:{popupPosition.y}px"
|
|
129
129
|
>
|
|
@@ -146,6 +146,7 @@ const onClickOutside = (event) => {
|
|
|
146
146
|
grid-template-rows: auto;
|
|
147
147
|
outline: none;
|
|
148
148
|
padding: 0;
|
|
149
|
+
position: relative;
|
|
149
150
|
transition: background-color 250ms, color 250ms, border-color 250ms;
|
|
150
151
|
}
|
|
151
152
|
|
|
@@ -166,22 +167,39 @@ const onClickOutside = (event) => {
|
|
|
166
167
|
}
|
|
167
168
|
|
|
168
169
|
.sterling-dropdown.disabled {
|
|
169
|
-
background-color: var(--stsv-Common__background-color--disabled);
|
|
170
|
-
border-color: var(--stsv--Common__border-color--disabled);
|
|
171
|
-
color: var(--stsv-Common__color--disabled);
|
|
172
170
|
cursor: not-allowed;
|
|
173
171
|
outline: none;
|
|
174
172
|
}
|
|
175
173
|
|
|
174
|
+
.sterling-dropdown::after {
|
|
175
|
+
background: var(--stsv-Disabled__background);
|
|
176
|
+
bottom: 0;
|
|
177
|
+
content: '';
|
|
178
|
+
left: 0;
|
|
179
|
+
opacity: 0;
|
|
180
|
+
position: absolute;
|
|
181
|
+
right: 0;
|
|
182
|
+
top: 0;
|
|
183
|
+
pointer-events: none;
|
|
184
|
+
transition: opacity 250ms;
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
.sterling-dropdown.disabled::after {
|
|
188
|
+
opacity: 1;
|
|
189
|
+
}
|
|
190
|
+
|
|
176
191
|
.sterling-dropdown.composed,
|
|
177
192
|
.sterling-dropdown.composed:hover,
|
|
178
|
-
.sterling-dropdown.composed.focus
|
|
179
|
-
.sterling-dropdown.composed.disabled {
|
|
193
|
+
.sterling-dropdown.composed.focus {
|
|
180
194
|
background: none;
|
|
181
195
|
border: none;
|
|
182
196
|
outline: none;
|
|
183
197
|
}
|
|
184
198
|
|
|
199
|
+
.sterling-dropdown.composed.disabled::after {
|
|
200
|
+
opacity: 0;
|
|
201
|
+
}
|
|
202
|
+
|
|
185
203
|
.button {
|
|
186
204
|
grid-column-start: 2;
|
|
187
205
|
grid-row-start: 1;
|
|
@@ -249,7 +267,8 @@ const onClickOutside = (event) => {
|
|
|
249
267
|
}
|
|
250
268
|
|
|
251
269
|
@media (prefers-reduced-motion) {
|
|
252
|
-
.sterling-dropdown
|
|
270
|
+
.sterling-dropdown,
|
|
271
|
+
.sterling-dropdown::after {
|
|
253
272
|
transition: none;
|
|
254
273
|
}
|
|
255
274
|
}
|
package/Field.svelte
CHANGED
|
@@ -180,7 +180,7 @@ const onClick = () => {
|
|
|
180
180
|
transition: background-color 250ms, color 250ms, border-color 250ms;
|
|
181
181
|
}
|
|
182
182
|
|
|
183
|
-
.sterling-field:hover {
|
|
183
|
+
.sterling-field:not(.disabled):hover {
|
|
184
184
|
background-color: var(--stsv-Input__background-color--hover);
|
|
185
185
|
border-color: var(--stsv-Input__border-color--hover);
|
|
186
186
|
color: var(--stsv-Input__color--hover);
|
|
@@ -196,9 +196,11 @@ const onClick = () => {
|
|
|
196
196
|
}
|
|
197
197
|
|
|
198
198
|
.sterling-field.disabled {
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
199
|
+
cursor: not-allowed;
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
.sterling-field.disabled * {
|
|
203
|
+
cursor: not-allowed;
|
|
202
204
|
}
|
|
203
205
|
|
|
204
206
|
.label-text {
|
|
@@ -211,15 +213,17 @@ const onClick = () => {
|
|
|
211
213
|
margin: 0;
|
|
212
214
|
}
|
|
213
215
|
|
|
214
|
-
.
|
|
215
|
-
|
|
216
|
+
.content {
|
|
217
|
+
display: grid;
|
|
216
218
|
}
|
|
217
219
|
|
|
218
220
|
.message {
|
|
221
|
+
box-sizing: border-box;
|
|
219
222
|
font-size: 0.8em;
|
|
220
223
|
background-color: var(--stsv-Display__background-color);
|
|
221
224
|
color: var(--stsv-Display__color);
|
|
222
225
|
padding: 0.5em;
|
|
226
|
+
width: 100%;
|
|
223
227
|
transition: background-color 250ms, color 250ms, border-color 250ms;
|
|
224
228
|
}
|
|
225
229
|
|
|
@@ -247,12 +251,6 @@ const onClick = () => {
|
|
|
247
251
|
color: var(--stsv-Error__color);
|
|
248
252
|
}
|
|
249
253
|
|
|
250
|
-
.sterling-field.disabled .message {
|
|
251
|
-
background-color: var(--stsv-Common__background-color--disabled);
|
|
252
|
-
border-color: var(--stsv--Common__border-color--disabled);
|
|
253
|
-
color: var(--stsv-Common__color--disabled);
|
|
254
|
-
}
|
|
255
|
-
|
|
256
254
|
.required {
|
|
257
255
|
text-align: center;
|
|
258
256
|
font-weight: bold;
|
|
@@ -271,6 +269,7 @@ const onClick = () => {
|
|
|
271
269
|
|
|
272
270
|
@media (prefers-reduced-motion) {
|
|
273
271
|
.sterling-field,
|
|
272
|
+
.sterling-field::after,
|
|
274
273
|
.message {
|
|
275
274
|
transition: none;
|
|
276
275
|
}
|
package/Input.svelte
CHANGED
|
@@ -39,51 +39,59 @@ export const setRangeText = (replacement, start, end, selectionMode) => {
|
|
|
39
39
|
<slot {composed} {disabled} {value} />
|
|
40
40
|
</Label>
|
|
41
41
|
{/if}
|
|
42
|
-
<input
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
42
|
+
<div class="sterling-input" class:composed class:disabled>
|
|
43
|
+
<input
|
|
44
|
+
bind:this={inputRef}
|
|
45
|
+
{disabled}
|
|
46
|
+
{id}
|
|
47
|
+
bind:value
|
|
48
|
+
on:beforeinput
|
|
49
|
+
on:blur
|
|
50
|
+
on:click
|
|
51
|
+
on:change
|
|
52
|
+
on:copy
|
|
53
|
+
on:cut
|
|
54
|
+
on:paste
|
|
55
|
+
on:dblclick
|
|
56
|
+
on:dragend
|
|
57
|
+
on:dragenter
|
|
58
|
+
on:dragleave
|
|
59
|
+
on:dragover
|
|
60
|
+
on:dragstart
|
|
61
|
+
on:drop
|
|
62
|
+
on:focus
|
|
63
|
+
on:focusin
|
|
64
|
+
on:focusout
|
|
65
|
+
on:input
|
|
66
|
+
on:invalid
|
|
67
|
+
on:keydown
|
|
68
|
+
on:keypress
|
|
69
|
+
on:keyup
|
|
70
|
+
on:mousedown
|
|
71
|
+
on:mouseenter
|
|
72
|
+
on:mouseleave
|
|
73
|
+
on:mousemove
|
|
74
|
+
on:mouseover
|
|
75
|
+
on:mouseout
|
|
76
|
+
on:mouseup
|
|
77
|
+
on:select
|
|
78
|
+
on:submit
|
|
79
|
+
on:reset
|
|
80
|
+
on:wheel
|
|
81
|
+
{...$$restProps}
|
|
82
|
+
/>
|
|
83
|
+
</div>
|
|
84
84
|
|
|
85
85
|
<style>
|
|
86
86
|
.sterling-input {
|
|
87
|
+
box-sizing: border-box;
|
|
88
|
+
display: inline-block;
|
|
89
|
+
margin: 0;
|
|
90
|
+
padding: 0;
|
|
91
|
+
position: relative;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
input {
|
|
87
95
|
background-color: var(--stsv-Input__background-color);
|
|
88
96
|
border-color: var(--stsv-Input__border-color);
|
|
89
97
|
border-radius: var(--stsv-Input__border-radius);
|
|
@@ -97,13 +105,13 @@ export const setRangeText = (replacement, start, end, selectionMode) => {
|
|
|
97
105
|
transition: background-color 250ms, color 250ms, border-color 250ms;
|
|
98
106
|
}
|
|
99
107
|
|
|
100
|
-
.sterling-input:hover {
|
|
108
|
+
.sterling-input:hover input {
|
|
101
109
|
background-color: var(--stsv-Input__background-color--hover);
|
|
102
110
|
border-color: var(--stsv-Input__border-color--hover);
|
|
103
111
|
color: var(--stsv-Input__color--hover);
|
|
104
112
|
}
|
|
105
113
|
|
|
106
|
-
|
|
114
|
+
input:focus {
|
|
107
115
|
background-color: var(--stsv-Input__background-color--focus);
|
|
108
116
|
border-color: var(--stsv-Input__border-color--focus);
|
|
109
117
|
color: var(--stsv-Input__color--focus);
|
|
@@ -113,33 +121,43 @@ export const setRangeText = (replacement, start, end, selectionMode) => {
|
|
|
113
121
|
outline-width: var(--stsv-Common__outline-width);
|
|
114
122
|
}
|
|
115
123
|
|
|
116
|
-
.sterling-input
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
color: var(--stsv-Common__color--disabled);
|
|
120
|
-
cursor: not-allowed;
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
.sterling-input.composed,
|
|
124
|
-
.sterling-input.composed:hover,
|
|
125
|
-
.sterling-input.composed:focus,
|
|
126
|
-
.sterling-input.composed.disabled {
|
|
124
|
+
.sterling-input.composed input,
|
|
125
|
+
.sterling-input.composed:hover input,
|
|
126
|
+
.sterling-input.composed:focus input {
|
|
127
127
|
background: transparent;
|
|
128
128
|
border: none;
|
|
129
129
|
outline: none;
|
|
130
130
|
}
|
|
131
131
|
|
|
132
|
-
|
|
132
|
+
input::placeholder {
|
|
133
133
|
color: var(--stsv-Display__color--faint);
|
|
134
|
-
transition: background-color 250ms, color 250ms, border-color 250ms;
|
|
135
134
|
}
|
|
136
135
|
|
|
137
|
-
.sterling-input
|
|
138
|
-
|
|
136
|
+
.sterling-input.disabled * {
|
|
137
|
+
cursor: not-allowed;
|
|
138
|
+
outline: none;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
.sterling-input::after {
|
|
142
|
+
background: var(--stsv-Disabled__background);
|
|
143
|
+
bottom: 0;
|
|
144
|
+
content: '';
|
|
145
|
+
left: 0;
|
|
146
|
+
opacity: 0;
|
|
147
|
+
position: absolute;
|
|
148
|
+
right: 0;
|
|
149
|
+
top: 0;
|
|
150
|
+
pointer-events: none;
|
|
151
|
+
transition: opacity 250ms;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
.sterling-input.disabled::after {
|
|
155
|
+
opacity: 1;
|
|
139
156
|
}
|
|
140
157
|
|
|
141
158
|
@media (prefers-reduced-motion) {
|
|
142
|
-
.sterling-input
|
|
159
|
+
.sterling-input::after,
|
|
160
|
+
input {
|
|
143
161
|
transition: none;
|
|
144
162
|
}
|
|
145
163
|
}
|
package/List.svelte
CHANGED
|
@@ -231,7 +231,9 @@ A list of items where a single item can be selected.
|
|
|
231
231
|
on:paste
|
|
232
232
|
{...$$restProps}
|
|
233
233
|
>
|
|
234
|
-
<
|
|
234
|
+
<div class="container">
|
|
235
|
+
<slot {composed} {disabled} {horizontal} {selectedValue} />
|
|
236
|
+
</div>
|
|
235
237
|
</div>
|
|
236
238
|
|
|
237
239
|
<style>
|
|
@@ -243,13 +245,10 @@ A list of items where a single item can be selected.
|
|
|
243
245
|
border-width: var(--stsv-Common__border-width);
|
|
244
246
|
box-sizing: border-box;
|
|
245
247
|
color: var(--stsv-Common__color);
|
|
246
|
-
display: flex;
|
|
247
|
-
flex-direction: column;
|
|
248
|
-
flex-wrap: nowrap;
|
|
249
248
|
height: 100%;
|
|
250
|
-
margin: 0;
|
|
251
249
|
overflow-x: hidden;
|
|
252
|
-
overflow-y:
|
|
250
|
+
overflow-y: auto;
|
|
251
|
+
margin: 0;
|
|
253
252
|
outline: none;
|
|
254
253
|
padding: 0;
|
|
255
254
|
position: relative;
|
|
@@ -257,9 +256,8 @@ A list of items where a single item can be selected.
|
|
|
257
256
|
}
|
|
258
257
|
|
|
259
258
|
.sterling-list.horizontal {
|
|
260
|
-
flex-direction: row;
|
|
261
259
|
height: unset;
|
|
262
|
-
overflow-x:
|
|
260
|
+
overflow-x: auto;
|
|
263
261
|
overflow-y: hidden;
|
|
264
262
|
width: 100%;
|
|
265
263
|
}
|
|
@@ -278,13 +276,6 @@ A list of items where a single item can be selected.
|
|
|
278
276
|
outline-width: var(--stsv-Common__outline-width);
|
|
279
277
|
}
|
|
280
278
|
|
|
281
|
-
.sterling-list.disabled {
|
|
282
|
-
background-color: var(--stsv-Common__background-color--disabled);
|
|
283
|
-
border-color: var(--stsv--Common__border-color--disabled);
|
|
284
|
-
color: var(--stsv-Common__color--disabled);
|
|
285
|
-
cursor: not-allowed;
|
|
286
|
-
}
|
|
287
|
-
|
|
288
279
|
.sterling-list.composed,
|
|
289
280
|
.sterling-list.composed:hover,
|
|
290
281
|
.sterling-list.composed.using-keyboard:focus-within,
|
|
@@ -294,8 +285,47 @@ A list of items where a single item can be selected.
|
|
|
294
285
|
outline: none;
|
|
295
286
|
}
|
|
296
287
|
|
|
288
|
+
.sterling-list.disabled * {
|
|
289
|
+
cursor: not-allowed;
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
/* ----- container - a layout panel that grows with the items ----- */
|
|
293
|
+
|
|
294
|
+
.container {
|
|
295
|
+
display: flex;
|
|
296
|
+
position: relative;
|
|
297
|
+
flex-direction: column;
|
|
298
|
+
flex-wrap: nowrap;
|
|
299
|
+
width: fit-content;
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
.sterling-list.horizontal .container {
|
|
303
|
+
flex-direction: row;
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
.container::after {
|
|
307
|
+
background: var(--stsv-Disabled__background);
|
|
308
|
+
content: '';
|
|
309
|
+
bottom: 0;
|
|
310
|
+
left: 0;
|
|
311
|
+
opacity: 0;
|
|
312
|
+
position: absolute;
|
|
313
|
+
right: 0;
|
|
314
|
+
top: 0;
|
|
315
|
+
height: 100%;
|
|
316
|
+
pointer-events: none;
|
|
317
|
+
transition: opacity 250ms;
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
.sterling-list.disabled .container::after {
|
|
321
|
+
opacity: 1;
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
/* ----- media queries ----- */
|
|
325
|
+
|
|
297
326
|
@media (prefers-reduced-motion) {
|
|
298
|
-
.sterling-list
|
|
327
|
+
.sterling-list,
|
|
328
|
+
.container::after {
|
|
299
329
|
transition: none;
|
|
300
330
|
}
|
|
301
331
|
}
|
package/ListItem.svelte
CHANGED
|
@@ -1,15 +1,18 @@
|
|
|
1
1
|
<script>import { getContext } from "svelte";
|
|
2
2
|
import { LIST_CONTEXT_KEY } from "./List.constants";
|
|
3
|
+
import { readable } from "svelte/store";
|
|
3
4
|
export let disabled = false;
|
|
4
5
|
export let value;
|
|
5
6
|
const {
|
|
6
7
|
disabled: listDisabled,
|
|
7
8
|
selectedValue,
|
|
8
9
|
horizontal
|
|
9
|
-
} = getContext(LIST_CONTEXT_KEY)
|
|
10
|
+
} = getContext(LIST_CONTEXT_KEY) || {
|
|
11
|
+
disabled: readable(false),
|
|
12
|
+
selectedValue: void 0,
|
|
13
|
+
horizontal: false
|
|
14
|
+
};
|
|
10
15
|
let itemRef;
|
|
11
|
-
$:
|
|
12
|
-
_disabled = disabled || $listDisabled;
|
|
13
16
|
$:
|
|
14
17
|
selected = $selectedValue === value;
|
|
15
18
|
export const click = () => {
|
|
@@ -27,7 +30,8 @@ export const focus = (options) => {
|
|
|
27
30
|
aria-selected={selected}
|
|
28
31
|
bind:this={itemRef}
|
|
29
32
|
class="sterling-list-item"
|
|
30
|
-
class:disabled={
|
|
33
|
+
class:disabled={disabled || $listDisabled}
|
|
34
|
+
class:item-disabled={disabled && !$listDisabled}
|
|
31
35
|
class:selected
|
|
32
36
|
data-value={value}
|
|
33
37
|
role="listitem"
|
|
@@ -75,13 +79,14 @@ export const focus = (options) => {
|
|
|
75
79
|
cursor: pointer;
|
|
76
80
|
margin: 0;
|
|
77
81
|
padding: 0.5em;
|
|
82
|
+
position: relative;
|
|
78
83
|
outline: none;
|
|
79
84
|
text-overflow: ellipsis;
|
|
80
85
|
transition: background-color 250ms, color 250ms, border-color 250ms;
|
|
81
86
|
white-space: nowrap;
|
|
82
87
|
}
|
|
83
88
|
|
|
84
|
-
.sterling-list-item:not(.disabled):hover {
|
|
89
|
+
.sterling-list-item:not(.disabled):not(.selected):hover {
|
|
85
90
|
background-color: var(--stsv-Button__background-color--hover);
|
|
86
91
|
color: var(--stsv-Button__color--hover);
|
|
87
92
|
}
|
|
@@ -92,12 +97,30 @@ export const focus = (options) => {
|
|
|
92
97
|
}
|
|
93
98
|
|
|
94
99
|
.sterling-list-item.disabled {
|
|
95
|
-
color: var(--stsv-Common__color--disabled);
|
|
96
100
|
cursor: not-allowed;
|
|
101
|
+
outline: none;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
.sterling-list-item::after {
|
|
105
|
+
background: var(--stsv-Disabled__background);
|
|
106
|
+
bottom: 0;
|
|
107
|
+
content: '';
|
|
108
|
+
left: 0;
|
|
109
|
+
opacity: 0;
|
|
110
|
+
position: absolute;
|
|
111
|
+
right: 0;
|
|
112
|
+
top: 0;
|
|
113
|
+
pointer-events: none;
|
|
114
|
+
transition: opacity 250ms;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
.sterling-list-item.item-disabled::after {
|
|
118
|
+
opacity: 1;
|
|
97
119
|
}
|
|
98
120
|
|
|
99
121
|
@media (prefers-reduced-motion) {
|
|
100
|
-
.sterling-list-item
|
|
122
|
+
.sterling-list-item,
|
|
123
|
+
.sterling-list-item::after {
|
|
101
124
|
transition: none;
|
|
102
125
|
}
|
|
103
126
|
}
|