@geoffcox/sterling-svelte 0.0.7 → 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>
@@ -1,5 +1,5 @@
1
1
  import { SvelteComponentTyped } from "svelte";
2
- import type { ButtonShape, ButtonVariant } from './types';
2
+ import type { ButtonShape, ButtonVariant } from './Button.types';
3
3
  declare const __propDef: {
4
4
  props: {
5
5
  [x: string]: any;
File without changes
File without changes
@@ -0,0 +1,182 @@
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
+ transition: background-color 250ms, color 250ms, border-color 250ms;
98
+ }
99
+
100
+ .container {
101
+ display: flex;
102
+ justify-content: flex-start;
103
+ width: 100%;
104
+ height: 100%;
105
+ min-width: 100px;
106
+ }
107
+
108
+ .indicator {
109
+ background-color: var(--Display__color);
110
+ box-sizing: border-box;
111
+ height: 100%;
112
+ min-height: 1px;
113
+ transition: background-color 250ms, color 250ms, border-color 250ms;
114
+ }
115
+
116
+ /* ----- Vertical ----- */
117
+
118
+ .sterling-progress.vertical {
119
+ align-items: center;
120
+ align-content: center;
121
+ }
122
+
123
+ .sterling-progress.vertical .progress-bar {
124
+ height: unset;
125
+ width: 1em;
126
+ }
127
+
128
+ .sterling-progress.vertical .container {
129
+ flex-direction: column;
130
+ justify-content: flex-end;
131
+ min-width: unset;
132
+ min-height: 100px;
133
+ }
134
+
135
+ .sterling-progress.vertical .indicator {
136
+ height: unset;
137
+ min-height: unset;
138
+ min-width: 1px;
139
+ width: 100%;
140
+ }
141
+
142
+ /* ----- Colorful ----- */
143
+
144
+ .indicator.progress {
145
+ background-color: var(--Display__color--progress);
146
+ }
147
+
148
+ .indicator.success {
149
+ background-color: var(--Display__color--success);
150
+ }
151
+
152
+ .indicator.warning {
153
+ background-color: var(--Display__color--warning);
154
+ }
155
+
156
+ .indicator.error {
157
+ background-color: var(--Display__color--error);
158
+ }
159
+
160
+ /* ----- Disabled ----- */
161
+
162
+ .label-content.disabled {
163
+ color: var(--Display__color--disabled);
164
+ }
165
+
166
+ .sterling-progress.disabled .progress-bar {
167
+ background: var(--Common__background-color--disabled);
168
+ border-color: var(--Common__border-color--disabled);
169
+ }
170
+
171
+ .sterling-progress.disabled .indicator {
172
+ background-color: var(--Display__color--disabled);
173
+ }
174
+
175
+ @media (prefers-reduced-motion) {
176
+ .progress-bar,
177
+ .indicator,
178
+ .label-content {
179
+ transition: none;
180
+ }
181
+ }
182
+ </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,12 +6,16 @@ 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';
10
11
  export { clickOutside } from './clickOutside';
11
12
  import Button from './buttons/Button.svelte';
13
+ import Checkbox from './inputs/Checkbox.svelte';
14
+ import Dialog from './surfaces/Dialog.svelte';
12
15
  import Input from './inputs/Input.svelte';
13
16
  import List from './lists/List.svelte';
14
- import Checkbox from './inputs/Checkbox.svelte';
17
+ import Progress from './display/Progress.svelte';
15
18
  import Radio from './inputs/Radio.svelte';
16
19
  import Select from './inputs/Select.svelte';
17
- export { Button, Checkbox, Input, List, Radio, Select };
20
+ import Slider from './inputs/Slider.svelte';
21
+ export { Button, Checkbox, Dialog, Input, List, Progress, Radio, Select, Slider };
package/index.js CHANGED
@@ -6,12 +6,16 @@ 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';
10
11
  export { clickOutside } from './clickOutside';
11
12
  import Button from './buttons/Button.svelte';
13
+ import Checkbox from './inputs/Checkbox.svelte';
14
+ import Dialog from './surfaces/Dialog.svelte';
12
15
  import Input from './inputs/Input.svelte';
13
16
  import List from './lists/List.svelte';
14
- import Checkbox from './inputs/Checkbox.svelte';
17
+ import Progress from './display/Progress.svelte';
15
18
  import Radio from './inputs/Radio.svelte';
16
19
  import Select from './inputs/Select.svelte';
17
- export { Button, Checkbox, Input, List, Radio, Select };
20
+ import Slider from './inputs/Slider.svelte';
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>