@geoffcox/sterling-svelte 0.0.8 → 0.0.9

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.
@@ -7,153 +7,160 @@ export let shape = "rounded";
7
7
  A styled HTML button element.
8
8
  -->
9
9
  <button
10
- class="sterling-button"
11
- class:square={shape === 'square'}
12
- class:circular={shape === 'circular'}
13
- class:outline={variant === 'outline'}
14
- class:ghost={variant === 'ghost'}
15
- on:blur
16
- on:click
17
- on:dblclick
18
- on:focus
19
- on:focusin
20
- on:focusout
21
- on:keydown
22
- on:keypress
23
- on:keyup
24
- on:mousedown
25
- on:mouseenter
26
- on:mouseleave
27
- on:mousemove
28
- on:mouseover
29
- on:mouseout
30
- on:mouseup
31
- on:pointercancel
32
- on:pointerdown
33
- on:pointerenter
34
- on:pointerleave
35
- on:pointermove
36
- on:pointerover
37
- on:pointerout
38
- on:pointerup
39
- on:wheel
40
- {...$$restProps}
10
+ class="sterling-button"
11
+ class:square={shape === 'square'}
12
+ class:circular={shape === 'circular'}
13
+ class:outline={variant === 'outline'}
14
+ class:ghost={variant === 'ghost'}
15
+ type="button"
16
+ on:blur
17
+ on:click
18
+ on:dblclick
19
+ on:focus
20
+ on:focusin
21
+ on:focusout
22
+ on:keydown
23
+ on:keypress
24
+ on:keyup
25
+ on:mousedown
26
+ on:mouseenter
27
+ on:mouseleave
28
+ on:mousemove
29
+ on:mouseover
30
+ on:mouseout
31
+ on:mouseup
32
+ on:pointercancel
33
+ on:pointerdown
34
+ on:pointerenter
35
+ on:pointerleave
36
+ on:pointermove
37
+ on:pointerover
38
+ on:pointerout
39
+ on:pointerup
40
+ on:wheel
41
+ {...$$restProps}
41
42
  >
42
- <slot />
43
+ <slot />
43
44
  </button>
44
45
 
45
46
  <style>
46
- button {
47
- background-color: var(--Button__background-color);
48
- border-color: var(--Button__border-color);
49
- border-radius: var(--Button__border-radius);
50
- border-style: var(--Button__border-style);
51
- border-width: var(--Button__border-width);
52
- box-sizing: border-box;
53
- color: var(--Button__color);
54
- cursor: pointer;
55
- display: inline-flex;
56
- flex-direction: row;
57
- font: inherit;
58
- align-content: center;
59
- align-items: center;
60
- justify-content: center;
61
- justify-items: center;
62
- column-gap: 0.25em;
63
- overflow: hidden;
64
- padding: 0.5em 1em;
65
- text-decoration: none;
66
- text-overflow: ellipsis;
67
- transition: background-color 250ms, color 250ms, border-color 250ms;
68
- white-space: nowrap;
69
- user-select: none;
70
- }
71
-
72
- button.vertical {
73
- flex-direction: column;
74
- row-gap: 0.15em;
75
- }
76
-
77
- button.circular {
78
- border-radius: 10000px;
79
- padding: 0.5em;
80
- }
81
-
82
- button.square {
83
- border-radius: 0;
84
- }
85
-
86
- button:hover {
87
- background-color: var(--Button__background-color--hover);
88
- border-color: var(--Button__border-color--hover);
89
- color: var(--Button__color--hover);
90
- }
91
-
92
- button:active {
93
- background-color: var(--Button__background-color--active);
94
- border-color: var(--Button__border-color--active);
95
- color: var(--Button__color--active);
96
- }
97
-
98
- button:focus-visible {
99
- border-color: var(--Button__border-color--focus);
100
- outline-color: var(--Common__outline-color);
101
- outline-offset: var(--Common__outline-offset);
102
- outline-style: var(--Common__outline-style);
103
- outline-width: var(--Common__outline-width);
104
- }
105
-
106
- button:disabled {
107
- background-color: var(--Button__background-color--disabled);
108
- border-color: var(--Button__border-color--disabled);
109
- color: var(--Button__color--disabled);
110
- cursor: not-allowed;
111
- }
112
-
113
- button.outline {
114
- background-color: transparent;
115
- }
116
-
117
- button.outline:hover {
118
- background-color: var(--Button__background-color--hover);
119
- }
120
-
121
- button.outline:active {
122
- background-color: var(--Button__background-color--active);
123
- }
124
-
125
- button.outline:disabled {
126
- background-color: transparent;
127
- }
128
-
129
- button.outline:disabled:hover {
130
- border-color: var(--Button__border-color--disabled);
131
- }
132
-
133
- button.ghost {
134
- background-color: transparent;
135
- border-color: transparent;
136
- }
137
-
138
- button.ghost:hover {
139
- background-color: var(--Button__background-color--hover);
140
- border-color: transparent;
141
- }
142
-
143
- button.ghost:active {
144
- background-color: var(--Button__background-color--active);
145
- border-color: transparent;
146
- }
147
-
148
- button.ghost:focus-visible {
149
- border-color: var(--Button__border-color--focus);
150
- }
151
-
152
- button.ghost:disabled {
153
- border-color: transparent;
154
- }
155
-
156
- button.ghost:disabled:hover {
157
- background-color: var(--Button__background-color--disabled);
158
- }
47
+ button {
48
+ align-content: center;
49
+ align-items: center;
50
+ background-color: var(--Button__background-color);
51
+ border-color: var(--Button__border-color);
52
+ border-radius: var(--Button__border-radius);
53
+ border-style: var(--Button__border-style);
54
+ border-width: var(--Button__border-width);
55
+ box-sizing: border-box;
56
+ color: var(--Button__color);
57
+ cursor: pointer;
58
+ display: inline-flex;
59
+ flex-direction: row;
60
+ font: inherit;
61
+ justify-content: center;
62
+ justify-items: center;
63
+ column-gap: 0.25em;
64
+ overflow: hidden;
65
+ padding: 0.5em 1em;
66
+ text-decoration: none;
67
+ text-overflow: ellipsis;
68
+ transition: background-color 250ms, color 250ms, border-color 250ms;
69
+ white-space: nowrap;
70
+ user-select: none;
71
+ }
72
+
73
+ button.vertical {
74
+ flex-direction: column;
75
+ row-gap: 0.15em;
76
+ }
77
+
78
+ button.circular {
79
+ border-radius: 10000px;
80
+ padding: 0.5em;
81
+ }
82
+
83
+ button.square {
84
+ border-radius: 0;
85
+ }
86
+
87
+ button:hover {
88
+ background-color: var(--Button__background-color--hover);
89
+ border-color: var(--Button__border-color--hover);
90
+ color: var(--Button__color--hover);
91
+ }
92
+
93
+ button:active {
94
+ background-color: var(--Button__background-color--active);
95
+ border-color: var(--Button__border-color--active);
96
+ color: var(--Button__color--active);
97
+ }
98
+
99
+ button:focus-visible {
100
+ border-color: var(--Button__border-color--focus);
101
+ outline-color: var(--Common__outline-color);
102
+ outline-offset: var(--Common__outline-offset);
103
+ outline-style: var(--Common__outline-style);
104
+ outline-width: var(--Common__outline-width);
105
+ }
106
+
107
+ button:disabled {
108
+ background-color: var(--Button__background-color--disabled);
109
+ border-color: var(--Button__border-color--disabled);
110
+ color: var(--Button__color--disabled);
111
+ cursor: not-allowed;
112
+ }
113
+
114
+ button.outline {
115
+ background-color: transparent;
116
+ }
117
+
118
+ button.outline:hover {
119
+ background-color: var(--Button__background-color--hover);
120
+ }
121
+
122
+ button.outline:active {
123
+ background-color: var(--Button__background-color--active);
124
+ }
125
+
126
+ button.outline:disabled {
127
+ background-color: transparent;
128
+ }
129
+
130
+ button.outline:disabled:hover {
131
+ border-color: var(--Button__border-color--disabled);
132
+ }
133
+
134
+ button.ghost {
135
+ background-color: transparent;
136
+ border-color: transparent;
137
+ }
138
+
139
+ button.ghost:hover {
140
+ background-color: var(--Button__background-color--hover);
141
+ border-color: transparent;
142
+ }
143
+
144
+ button.ghost:active {
145
+ background-color: var(--Button__background-color--active);
146
+ border-color: transparent;
147
+ }
148
+
149
+ button.ghost:focus-visible {
150
+ border-color: var(--Button__border-color--focus);
151
+ }
152
+
153
+ button.ghost:disabled {
154
+ border-color: transparent;
155
+ }
156
+
157
+ button.ghost:disabled:hover {
158
+ background-color: var(--Button__background-color--disabled);
159
+ }
160
+
161
+ @media (prefers-reduced-motion) {
162
+ button {
163
+ transition: none;
164
+ }
165
+ }
159
166
  </style>
@@ -94,6 +94,7 @@ $:
94
94
  border-style: var(--Common__border-style);
95
95
  border-color: var(--Common__border-color);
96
96
  border-radius: var(--Common__border-radius);
97
+ transition: background-color 250ms, color 250ms, border-color 250ms;
97
98
  }
98
99
 
99
100
  .container {
@@ -109,6 +110,7 @@ $:
109
110
  box-sizing: border-box;
110
111
  height: 100%;
111
112
  min-height: 1px;
113
+ transition: background-color 250ms, color 250ms, border-color 250ms;
112
114
  }
113
115
 
114
116
  /* ----- Vertical ----- */
@@ -169,4 +171,12 @@ $:
169
171
  .sterling-progress.disabled .indicator {
170
172
  background-color: var(--Display__color--disabled);
171
173
  }
174
+
175
+ @media (prefers-reduced-motion) {
176
+ .progress-bar,
177
+ .indicator,
178
+ .label-content {
179
+ transition: none;
180
+ }
181
+ }
172
182
  </style>
package/index.d.ts CHANGED
@@ -11,10 +11,11 @@ export { type ProgressColorful } from './display/Progress.types';
11
11
  export { clickOutside } from './clickOutside';
12
12
  import Button from './buttons/Button.svelte';
13
13
  import Checkbox from './inputs/Checkbox.svelte';
14
+ import Dialog from './surfaces/Dialog.svelte';
14
15
  import Input from './inputs/Input.svelte';
15
16
  import List from './lists/List.svelte';
16
17
  import Progress from './display/Progress.svelte';
17
18
  import Radio from './inputs/Radio.svelte';
18
19
  import Select from './inputs/Select.svelte';
19
20
  import Slider from './inputs/Slider.svelte';
20
- export { Button, Checkbox, Input, List, Progress, Radio, Select, Slider };
21
+ export { Button, Checkbox, Dialog, Input, List, Progress, Radio, Select, Slider };
package/index.js CHANGED
@@ -11,10 +11,11 @@ export {} from './display/Progress.types';
11
11
  export { clickOutside } from './clickOutside';
12
12
  import Button from './buttons/Button.svelte';
13
13
  import Checkbox from './inputs/Checkbox.svelte';
14
+ import Dialog from './surfaces/Dialog.svelte';
14
15
  import Input from './inputs/Input.svelte';
15
16
  import List from './lists/List.svelte';
16
17
  import Progress from './display/Progress.svelte';
17
18
  import Radio from './inputs/Radio.svelte';
18
19
  import Select from './inputs/Select.svelte';
19
20
  import Slider from './inputs/Slider.svelte';
20
- export { Button, Checkbox, Input, List, Progress, Radio, Select, Slider };
21
+ export { Button, Checkbox, Dialog, Input, List, Progress, Radio, Select, Slider };
@@ -148,4 +148,12 @@ export let disabled = false;
148
148
  .label-content.disabled {
149
149
  color: var(--Input__color--disabled);
150
150
  }
151
+
152
+ @media (prefers-reduced-motion) {
153
+ .indicator,
154
+ input:checked + .indicator::after,
155
+ .label-content {
156
+ transition: none;
157
+ }
158
+ }
151
159
  </style>
@@ -138,7 +138,6 @@ export let disabled = false;
138
138
 
139
139
  .sterling-input {
140
140
  padding: 0.5em 0.5em;
141
- transition: background-color 250ms, color 250ms, border-color 250ms;
142
141
  }
143
142
 
144
143
  .sterling-input.labeled,
@@ -158,4 +157,13 @@ export let disabled = false;
158
157
  .sterling-input:disabled::placeholder {
159
158
  color: var(--Display__color--disabled);
160
159
  }
160
+
161
+ @media (prefers-reduced-motion) {
162
+ .sterling-input-label,
163
+ .sterling-input,
164
+ .label-content,
165
+ .sterling-input::placeholder {
166
+ transition: none;
167
+ }
168
+ }
161
169
  </style>
@@ -162,4 +162,12 @@ $: {
162
162
  .label-content.disabled {
163
163
  color: var(--Input__color--disabled);
164
164
  }
165
+
166
+ @media (prefers-reduced-motion) {
167
+ .indicator,
168
+ .indicator::after,
169
+ .label-content {
170
+ transition: none;
171
+ }
172
+ }
165
173
  </style>
@@ -36,7 +36,6 @@ $: {
36
36
  raiseItemSelected(selectedIndex);
37
37
  }
38
38
  $: {
39
- console.log("raise pendingSelectedIndex changed");
40
39
  raiseItemSelectPending(pendingSelectedIndex);
41
40
  }
42
41
  $: {
@@ -240,15 +239,6 @@ A single item that can be selected from a popup list of items.
240
239
  </div>
241
240
 
242
241
  <style>
243
- /*
244
- sterling-select
245
- sterling-select-label
246
- label-content
247
- input
248
- value
249
- button
250
- (popup)
251
- */
252
242
  .sterling-select {
253
243
  background-color: var(--Input__background-color);
254
244
  border-color: var(--Input__border-color);
@@ -363,4 +353,11 @@ A single item that can be selected from a popup list of items.
363
353
  .popup-content {
364
354
  max-height: 15em;
365
355
  }
356
+
357
+ @media (prefers-reduced-motion) {
358
+ .sterling-select,
359
+ .label-content {
360
+ transition: none;
361
+ }
362
+ }
366
363
  </style>
@@ -122,239 +122,246 @@ const onKeyDown = (event) => {
122
122
  Slider lets the user chose a value within a min/max range by dragging a thumb button.
123
123
  -->
124
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>
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
163
  {:else}
164
- <div
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}
179
- >
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>
190
- </div>
164
+ <div
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}
179
+ >
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>
190
+ </div>
191
191
  {/if}
192
192
 
193
193
  <style>
194
- .sterling-slider-label {
195
- display: grid;
196
- grid-template-columns: 1fr;
197
- grid-template-rows: auto 1fr;
198
- }
194
+ .sterling-slider-label {
195
+ display: grid;
196
+ grid-template-columns: 1fr;
197
+ grid-template-rows: auto 1fr;
198
+ }
199
199
 
200
- .sterling-slider-label.vertical {
201
- justify-items: center;
202
- height: 100%;
203
- }
200
+ .sterling-slider-label.vertical {
201
+ justify-items: center;
202
+ height: 100%;
203
+ }
204
204
 
205
- .label-content {
206
- font-size: 0.7em;
207
- color: var(--Display__color--subtle);
208
- transition: background-color 250ms, color 250ms, border-color 250ms;
209
- }
205
+ .label-content {
206
+ font-size: 0.7em;
207
+ color: var(--Display__color--subtle);
208
+ transition: background-color 250ms, color 250ms, border-color 250ms;
209
+ }
210
210
 
211
- .label-content.disabled {
212
- color: var(--Display__color--disabled);
213
- }
211
+ .label-content.disabled {
212
+ color: var(--Display__color--disabled);
213
+ }
214
214
 
215
- .sterling-slider {
216
- box-sizing: border-box;
217
- outline: none;
218
- padding: 0;
219
- overflow: visible;
220
- display: grid;
221
- height: 100%;
222
- }
215
+ .sterling-slider {
216
+ box-sizing: border-box;
217
+ outline: none;
218
+ padding: 0;
219
+ overflow: visible;
220
+ display: grid;
221
+ height: 100%;
222
+ }
223
223
 
224
- .sterling-slider.labeled {
225
- height: unset;
226
- }
224
+ .sterling-slider.labeled {
225
+ height: unset;
226
+ }
227
227
 
228
- .container {
229
- position: relative;
230
- }
228
+ .container {
229
+ position: relative;
230
+ }
231
231
 
232
- .track {
233
- position: absolute;
234
- background: var(--Display__background-color);
235
- }
232
+ .track {
233
+ position: absolute;
234
+ background: var(--Display__background-color);
235
+ }
236
236
 
237
- .fill {
238
- background: var(--Display__color);
239
- position: absolute;
240
- }
237
+ .fill {
238
+ background: var(--Display__color);
239
+ position: absolute;
240
+ }
241
241
 
242
- .thumb {
243
- background-color: var(--Button__background-color);
244
- border-color: var(--Button__border-color);
245
- border-radius: 10000px;
246
- border-style: var(--Button__border-style);
247
- border-width: var(--Button__border-width);
248
- box-sizing: border-box;
249
- color: var(--Button__color);
250
- cursor: pointer;
251
- display: block;
252
- font: inherit;
253
- height: 1.5em;
254
- overflow: hidden;
255
- padding: 0;
256
- text-decoration: none;
257
- transition: background-color 250ms, color 250ms, border-color 250ms;
258
- white-space: nowrap;
259
- position: absolute;
260
- width: 1.5em;
261
- }
242
+ .thumb {
243
+ background-color: var(--Button__background-color);
244
+ border-color: var(--Button__border-color);
245
+ border-radius: 10000px;
246
+ border-style: var(--Button__border-style);
247
+ border-width: var(--Button__border-width);
248
+ box-sizing: border-box;
249
+ color: var(--Button__color);
250
+ cursor: pointer;
251
+ display: block;
252
+ font: inherit;
253
+ height: 1.5em;
254
+ overflow: hidden;
255
+ padding: 0;
256
+ text-decoration: none;
257
+ transition: background-color 250ms, color 250ms, border-color 250ms;
258
+ white-space: nowrap;
259
+ position: absolute;
260
+ width: 1.5em;
261
+ }
262
262
 
263
- /* ----- horizontal ----- */
263
+ /* ----- horizontal ----- */
264
264
 
265
- .sterling-slider.horizontal {
266
- height: 2em;
267
- }
265
+ .sterling-slider.horizontal {
266
+ height: 2em;
267
+ }
268
268
 
269
- .sterling-slider.horizontal .container {
270
- margin: 0 0.75em;
271
- }
269
+ .sterling-slider.horizontal .container {
270
+ margin: 0 0.75em;
271
+ }
272
272
 
273
- .sterling-slider.horizontal .track {
274
- left: 0;
275
- right: 0;
276
- top: 50%;
277
- height: 3px;
278
- transform: translate(0, -50%);
279
- }
273
+ .sterling-slider.horizontal .track {
274
+ left: 0;
275
+ right: 0;
276
+ top: 50%;
277
+ height: 3px;
278
+ transform: translate(0, -50%);
279
+ }
280
280
 
281
- .sterling-slider.horizontal .fill {
282
- height: 3px;
283
- top: 50%;
284
- transform: translate(0, -50%);
285
- }
281
+ .sterling-slider.horizontal .fill {
282
+ height: 3px;
283
+ top: 50%;
284
+ transform: translate(0, -50%);
285
+ }
286
286
 
287
- .sterling-slider.horizontal .thumb {
288
- top: 50%;
289
- transform: translate(-50%, -50%);
290
- }
287
+ .sterling-slider.horizontal .thumb {
288
+ top: 50%;
289
+ transform: translate(-50%, -50%);
290
+ }
291
291
 
292
- /* ----- vertical ----- */
292
+ /* ----- vertical ----- */
293
293
 
294
- .sterling-slider.vertical {
295
- width: 2em;
296
- }
297
- .sterling-slider.vertical .container {
298
- margin: 0.75em 0;
299
- }
294
+ .sterling-slider.vertical {
295
+ width: 2em;
296
+ }
297
+ .sterling-slider.vertical .container {
298
+ margin: 0.75em 0;
299
+ }
300
300
 
301
- .sterling-slider.vertical .track {
302
- bottom: 0;
303
- left: 50%;
304
- top: 0;
305
- transform: translate(-50%, 0);
306
- width: 3px;
307
- }
301
+ .sterling-slider.vertical .track {
302
+ bottom: 0;
303
+ left: 50%;
304
+ top: 0;
305
+ transform: translate(-50%, 0);
306
+ width: 3px;
307
+ }
308
308
 
309
- .sterling-slider.vertical .fill {
310
- bottom: 0;
311
- left: 50%;
312
- transform: translate(-50%, 0);
313
- width: 3px;
314
- }
309
+ .sterling-slider.vertical .fill {
310
+ bottom: 0;
311
+ left: 50%;
312
+ transform: translate(-50%, 0);
313
+ width: 3px;
314
+ }
315
315
 
316
- .sterling-slider.vertical .thumb {
317
- left: 50%;
318
- transform: translate(-50%, 50%);
319
- }
316
+ .sterling-slider.vertical .thumb {
317
+ left: 50%;
318
+ transform: translate(-50%, 50%);
319
+ }
320
+
321
+ /* ----- hover ----- */
320
322
 
321
- /* ----- hover ----- */
323
+ .thumb:hover {
324
+ background-color: var(--Button__background-color--hover);
325
+ border-color: var(--Button__border-color--hover);
326
+ color: var(--Button__color--hover);
327
+ }
322
328
 
323
- .thumb:hover {
324
- background-color: var(--Button__background-color--hover);
325
- border-color: var(--Button__border-color--hover);
326
- color: var(--Button__color--hover);
327
- }
329
+ /* ----- active ----- */
328
330
 
329
- /* ----- active ----- */
331
+ .thumb:active {
332
+ background-color: var(--Button__background-color--active);
333
+ border-color: var(--Button__border-color--active);
334
+ color: var(--Button__color--active);
335
+ }
330
336
 
331
- .thumb:active {
332
- background-color: var(--Button__background-color--active);
333
- border-color: var(--Button__border-color--active);
334
- color: var(--Button__color--active);
335
- }
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 ----- */
336
345
 
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 ----- */
346
+ .sterling-slider.disabled .track {
347
+ background: var(--Common__background-color--disabled);
348
+ }
345
349
 
346
- .sterling-slider.disabled .track {
347
- background: var(--Common__background-color--disabled);
348
- }
350
+ .sterling-slider.disabled .fill {
351
+ background: var(--Common__color--disabled);
352
+ }
349
353
 
350
- .sterling-slider.disabled .fill {
351
- background: var(--Common__color--disabled);
352
- }
354
+ .sterling-slider.disabled .thumb {
355
+ background-color: var(--Common__background-color--disabled);
356
+ border-color: var(--Common__border-color--disabled);
357
+ color: var(--Common__color--disabled);
358
+ cursor: not-allowed;
359
+ }
353
360
 
354
- .sterling-slider.disabled .thumb {
355
- background-color: var(--Common__background-color--disabled);
356
- border-color: var(--Common__border-color--disabled);
357
- color: var(--Common__color--disabled);
358
- cursor: not-allowed;
359
- }
361
+ @media (prefers-reduced-motion) {
362
+ .thumb,
363
+ .label-content {
364
+ transition: none;
365
+ }
366
+ }
360
367
  </style>
package/lists/List.svelte CHANGED
@@ -318,4 +318,13 @@ A list of items where a single item can be selected.
318
318
  .list-item.disabled {
319
319
  color: var(--Input__color--disabled);
320
320
  }
321
+
322
+ @media (prefers-reduced-motion) {
323
+ .sterling-list-label,
324
+ .sterling-list,
325
+ .list-item,
326
+ .label-content {
327
+ transition: none;
328
+ }
329
+ }
321
330
  </style>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@geoffcox/sterling-svelte",
3
- "version": "0.0.8",
3
+ "version": "0.0.9",
4
4
  "devDependencies": {
5
5
  "@fontsource/fira-mono": "^4.5.10",
6
6
  "@fontsource/overpass": "^4.5.10",
@@ -45,6 +45,8 @@
45
45
  "./inputs/Select.svelte": "./inputs/Select.svelte",
46
46
  "./inputs/Slider.svelte": "./inputs/Slider.svelte",
47
47
  "./lists/List.svelte": "./lists/List.svelte",
48
+ "./surfaces/CloseX.svelte": "./surfaces/CloseX.svelte",
49
+ "./surfaces/Dialog.svelte": "./surfaces/Dialog.svelte",
48
50
  "./theme/applyDarkTheme": "./theme/applyDarkTheme.js",
49
51
  "./theme/applyLightTheme": "./theme/applyLightTheme.js",
50
52
  "./theme/applyTheme": "./theme/applyTheme.js",
@@ -0,0 +1,5 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" fill="currentColor" viewBox="0 0 16 16" {...$$restProps}>
2
+ <path
3
+ d="M4.646 4.646a.5.5 0 0 1 .708 0L8 7.293l2.646-2.647a.5.5 0 0 1 .708.708L8.707 8l2.647 2.646a.5.5 0 0 1-.708.708L8 8.707l-2.646 2.647a.5.5 0 0 1-.708-.708L7.293 8 4.646 5.354a.5.5 0 0 1 0-.708z"
4
+ />
5
+ </svg>
@@ -0,0 +1,23 @@
1
+ /** @typedef {typeof __propDef.props} CloseXProps */
2
+ /** @typedef {typeof __propDef.events} CloseXEvents */
3
+ /** @typedef {typeof __propDef.slots} CloseXSlots */
4
+ export default class CloseX extends SvelteComponentTyped<{
5
+ [x: string]: never;
6
+ }, {
7
+ [evt: string]: CustomEvent<any>;
8
+ }, {}> {
9
+ }
10
+ export type CloseXProps = typeof __propDef.props;
11
+ export type CloseXEvents = typeof __propDef.events;
12
+ export type CloseXSlots = typeof __propDef.slots;
13
+ import { SvelteComponentTyped } from "svelte";
14
+ declare const __propDef: {
15
+ props: {
16
+ [x: string]: never;
17
+ };
18
+ events: {
19
+ [evt: string]: CustomEvent<any>;
20
+ };
21
+ slots: {};
22
+ };
23
+ export {};
@@ -0,0 +1,241 @@
1
+ <script>import { createEventDispatcher, onMount, tick } from "svelte";
2
+ import Button from "../buttons/Button.svelte";
3
+ import CloseX from "./CloseX.svelte";
4
+ const dialogFadeDuration = 250;
5
+ export let open = false;
6
+ export let returnValue = "";
7
+ export let backdropCloses = false;
8
+ let dialogRef;
9
+ let contentRef;
10
+ let formRef;
11
+ let closing = false;
12
+ const dispatch = createEventDispatcher();
13
+ const onDocumentClick = (event) => {
14
+ const targetNode = event?.target;
15
+ if (targetNode && !contentRef.contains(targetNode) && backdropCloses) {
16
+ open = false;
17
+ }
18
+ };
19
+ const showDialog = () => {
20
+ if (dialogRef?.open === false) {
21
+ document.addEventListener("click", onDocumentClick, true);
22
+ dialogRef.showModal();
23
+ }
24
+ open = true;
25
+ };
26
+ const closeDialog = (returnValue2 = "") => {
27
+ if (dialogRef?.open === true) {
28
+ document.removeEventListener("click", onDocumentClick);
29
+ closing = true;
30
+ tick();
31
+ setTimeout(() => {
32
+ dialogRef.close(returnValue2);
33
+ open = false;
34
+ closing = false;
35
+ }, dialogFadeDuration);
36
+ } else {
37
+ open = false;
38
+ }
39
+ };
40
+ const updateDialog = (open2) => {
41
+ if (open2) {
42
+ showDialog();
43
+ } else {
44
+ closeDialog();
45
+ }
46
+ };
47
+ const onCancel = (event) => {
48
+ event.preventDefault();
49
+ event.stopPropagation();
50
+ closeDialog();
51
+ return false;
52
+ };
53
+ const onSubmit = (event) => {
54
+ console.log(event);
55
+ const anyEvent = event;
56
+ if (anyEvent?.submitter.type === "submit") {
57
+ if (dialogRef.open) {
58
+ closeDialog(anyEvent?.submitter.value ?? "");
59
+ setTimeout(() => {
60
+ formRef.requestSubmit(anyEvent?.submitter);
61
+ }, dialogFadeDuration);
62
+ event.preventDefault();
63
+ return false;
64
+ }
65
+ } else {
66
+ console.log("cancelling");
67
+ event.preventDefault();
68
+ return false;
69
+ }
70
+ };
71
+ const onClose = (event) => {
72
+ returnValue = dialogRef.returnValue;
73
+ };
74
+ $: {
75
+ updateDialog(open);
76
+ }
77
+ onMount(() => {
78
+ updateDialog(open);
79
+ dialogRef.addEventListener("cancel", onCancel);
80
+ dialogRef.addEventListener("close", onClose);
81
+ return () => {
82
+ dialogRef?.removeEventListener("cancel", onCancel);
83
+ dialogRef?.removeEventListener("close", onClose);
84
+ };
85
+ });
86
+ </script>
87
+
88
+ <!-- @component
89
+ A styled &lt;dialog&gt; element
90
+
91
+ - Slots for typical dialog content.
92
+ - Props and events to make using &lt;dialog&gt; easier
93
+ -->
94
+ <dialog
95
+ class="dialog"
96
+ class:open
97
+ class:closing
98
+ bind:this={dialogRef}
99
+ on:close
100
+ on:cancel
101
+ {...$$restProps}
102
+ >
103
+ <form method="dialog" bind:this={formRef} on:submit={onSubmit}>
104
+ <div class="content" bind:this={contentRef}>
105
+ <slot name="content">
106
+ <div class="header">
107
+ <slot name="header">
108
+ <div class="title">
109
+ <slot name="title" />
110
+ </div>
111
+ <div class="close">
112
+ <Button variant="ghost" shape="circular" on:click={() => closeDialog()}>
113
+ <div class="close-x">
114
+ <CloseX />
115
+ </div>
116
+ </Button>
117
+ </div>
118
+ </slot>
119
+ </div>
120
+ <div class="body">
121
+ <slot name="body" />
122
+ </div>
123
+ <div class="separator" />
124
+ <div class="footer">
125
+ <slot name="footer" />
126
+ </div>
127
+ </slot>
128
+ </div>
129
+ </form>
130
+ </dialog>
131
+
132
+ <style>
133
+ .dialog {
134
+ padding: 0;
135
+ border: none;
136
+ background: none;
137
+ }
138
+
139
+ .dialog::backdrop {
140
+ backdrop-filter: blur(2px);
141
+ background: rgba(0, 0, 0, 0.3);
142
+ transition: opacity 250ms;
143
+ opacity: 0;
144
+ }
145
+
146
+ .dialog.open::backdrop {
147
+ opacity: 1;
148
+ }
149
+
150
+ .dialog.closing::backdrop {
151
+ opacity: 0;
152
+ }
153
+
154
+ .header {
155
+ background-color: var(--Display__background-color);
156
+ }
157
+
158
+ .content {
159
+ background-color: var(--Common__background-color);
160
+ border-color: var(--Common__border-color);
161
+ border-radius: var(--Common__border-radius);
162
+ border-style: var(--Common__border-style);
163
+ border-width: var(--Common__border-width);
164
+ box-sizing: border-box;
165
+ color: var(--Common__color);
166
+ display: grid;
167
+ grid-template-columns: 1fr;
168
+ grid-template-rows: auto 1fr auto auto;
169
+ justify-content: stretch;
170
+ justify-items: stretch;
171
+ align-items: stretch;
172
+ transition: opacity 250ms;
173
+ opacity: 0;
174
+ }
175
+
176
+ .dialog.open .content {
177
+ opacity: 1;
178
+ }
179
+
180
+ .dialog.closing .content {
181
+ opacity: 0;
182
+ }
183
+
184
+ .header {
185
+ display: grid;
186
+ grid-template-columns: 1fr auto;
187
+ grid-template-rows: 1fr;
188
+ justify-items: stretch;
189
+ align-items: center;
190
+ padding: 0.25em 0.5em;
191
+ }
192
+
193
+ .title {
194
+ font-size: 1.4em;
195
+ }
196
+
197
+ .close {
198
+ justify-self: flex-end;
199
+ }
200
+
201
+ .close :global(button) {
202
+ width: 1.75em;
203
+ height: 1.75em;
204
+ padding: 0;
205
+ }
206
+
207
+ .close-x {
208
+ width: 1.5em;
209
+ height: 1.5em;
210
+ display: grid;
211
+ grid-template-columns: 1fr;
212
+ grid-template-rows: 1fr;
213
+ place-content: center;
214
+ align-content: center;
215
+ }
216
+
217
+ .body {
218
+ padding: 1em;
219
+ }
220
+
221
+ .separator {
222
+ background-color: var(--Display__background-color);
223
+ height: var(--Common__border-width);
224
+ margin: 0 0.25em;
225
+ }
226
+
227
+ .footer {
228
+ display: flex;
229
+ justify-content: flex-end;
230
+ justify-items: flex-end;
231
+ padding: 0.5em 1em;
232
+ gap: 5px;
233
+ }
234
+
235
+ @media (prefers-reduced-motion) {
236
+ .dialog::backdrop,
237
+ .content {
238
+ transition: none;
239
+ }
240
+ }
241
+ </style>
@@ -0,0 +1,34 @@
1
+ import { SvelteComponentTyped } from "svelte";
2
+ declare const __propDef: {
3
+ props: {
4
+ [x: string]: any;
5
+ open?: boolean | undefined;
6
+ returnValue?: string | undefined;
7
+ backdropCloses?: boolean | undefined;
8
+ };
9
+ events: {
10
+ close: Event;
11
+ cancel: Event;
12
+ } & {
13
+ [evt: string]: CustomEvent<any>;
14
+ };
15
+ slots: {
16
+ content: {};
17
+ header: {};
18
+ title: {};
19
+ body: {};
20
+ footer: {};
21
+ };
22
+ };
23
+ export type DialogProps = typeof __propDef.props;
24
+ export type DialogEvents = typeof __propDef.events;
25
+ export type DialogSlots = typeof __propDef.slots;
26
+ /**
27
+ * A styled &lt;dialog&gt; element
28
+ *
29
+ * - Slots for typical dialog content.
30
+ * - Props and events to make using &lt;dialog&gt; easier
31
+ */
32
+ export default class Dialog extends SvelteComponentTyped<DialogProps, DialogEvents, DialogSlots> {
33
+ }
34
+ export {};
package/theme/colors.js CHANGED
@@ -1,6 +1,8 @@
1
1
  export const neutrals = {
2
2
  neutral0: 'hsl(0, 0%, 0%)',
3
+ neutral10: 'hsl(0, 0%, 12%)',
3
4
  neutral15: 'hsl(0, 0%, 15%)',
5
+ neutral20: 'hsl(0, 0%, 20%)',
4
6
  neutral30: 'hsl(0, 0%, 30%)',
5
7
  neutral45: 'hsl(0, 0%, 45%)',
6
8
  neutral60: 'hsl(0, 0%, 60%)',
@@ -25,11 +25,11 @@ export const darkTheme = {
25
25
  '--Common__border-color--disabled': neutrals.neutral92,
26
26
  '--Common__color--disabled': neutrals.neutral92,
27
27
  // ----- Layer ---- //
28
- '--Layer__background-color--1': neutrals.neutral30,
28
+ '--Layer__background-color--1': neutrals.neutral20,
29
29
  '--Layer__color--1': neutrals.neutral100,
30
- '--Layer__background-color--2': neutrals.neutral45,
30
+ '--Layer__background-color--2': neutrals.neutral10,
31
31
  '--Layer__color--2': neutrals.neutral100,
32
- '--Layer__background-color--3': neutrals.neutral60,
32
+ '--Layer__background-color--3': neutrals.neutral45,
33
33
  '--Layer__color--3': neutrals.neutral100,
34
34
  // ----- Button ----- //
35
35
  '--Button__background-color': neutrals.neutral45,