@conalog/ds-svelte 0.0.0-stage → 1.0.0-alpha.1
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/LICENSE +21 -0
- package/README.md +6 -2
- package/SUPPORT.json +366 -0
- package/dist/ActionButton.svelte +11 -0
- package/dist/Badge.svelte +49 -0
- package/dist/Button.svelte +107 -0
- package/dist/Card.svelte +76 -0
- package/dist/Checkbox.svelte +60 -0
- package/dist/Chip.svelte +133 -0
- package/dist/CircularSpinner.svelte +30 -0
- package/dist/Divider.svelte +29 -0
- package/dist/DsTheme.svelte +14 -0
- package/dist/IconButton.svelte +7 -0
- package/dist/Menu.svelte +277 -0
- package/dist/Modal.svelte +86 -0
- package/dist/Navigation.svelte +87 -0
- package/dist/PageHeader.svelte +81 -0
- package/dist/ScopePicker.svelte +271 -0
- package/dist/SearchField.svelte +7 -0
- package/dist/SegmentedControl.svelte +154 -0
- package/dist/StatusBanner.svelte +48 -0
- package/dist/Table.svelte +180 -0
- package/dist/Tabs.svelte +121 -0
- package/dist/TextField.svelte +122 -0
- package/dist/Tooltip.svelte +147 -0
- package/dist/button-options.mjs +1 -0
- package/dist/button.css +514 -0
- package/dist/display.css +47 -0
- package/dist/draft-overlay.mjs +67 -0
- package/dist/draft.css +248 -0
- package/dist/icon-provenance.json +62 -0
- package/dist/icons/check/filled.d.mts +3 -0
- package/dist/icons/check/filled.mjs +1 -0
- package/dist/icons/check/filled.svelte +10 -0
- package/dist/icons/check.d.mts +1 -0
- package/dist/icons/check.mjs +1 -0
- package/dist/icons/headset/filled.d.mts +3 -0
- package/dist/icons/headset/filled.mjs +1 -0
- package/dist/icons/headset/filled.svelte +10 -0
- package/dist/icons/headset.d.mts +1 -0
- package/dist/icons/headset.mjs +1 -0
- package/dist/icons/notification-bell/filled.d.mts +3 -0
- package/dist/icons/notification-bell/filled.mjs +1 -0
- package/dist/icons/notification-bell/filled.svelte +10 -0
- package/dist/icons/notification-bell-off/filled.d.mts +3 -0
- package/dist/icons/notification-bell-off/filled.mjs +1 -0
- package/dist/icons/notification-bell-off/filled.svelte +10 -0
- package/dist/icons/notification-bell-off.d.mts +1 -0
- package/dist/icons/notification-bell-off.mjs +1 -0
- package/dist/icons/notification-bell.d.mts +1 -0
- package/dist/icons/notification-bell.mjs +1 -0
- package/dist/icons/plant/filled.d.mts +3 -0
- package/dist/icons/plant/filled.mjs +1 -0
- package/dist/icons/plant/filled.svelte +13 -0
- package/dist/icons/plant.d.mts +1 -0
- package/dist/icons/plant.mjs +1 -0
- package/dist/icons/search/outlined.d.mts +3 -0
- package/dist/icons/search/outlined.mjs +1 -0
- package/dist/icons/search/outlined.svelte +10 -0
- package/dist/icons/search.d.mts +1 -0
- package/dist/icons/search.mjs +1 -0
- package/dist/icons.d.mts +6 -0
- package/dist/icons.mjs +6 -0
- package/dist/index.d.ts +269 -0
- package/dist/index.mjs +21 -0
- package/dist/licenses/check/filled.txt +202 -0
- package/dist/licenses/headset/filled.txt +21 -0
- package/dist/licenses/notification-bell/filled.txt +21 -0
- package/dist/licenses/notification-bell-off/filled.txt +21 -0
- package/dist/licenses/plant/filled.txt +24 -0
- package/dist/licenses/search/outlined.txt +21 -0
- package/package.json +58 -4
- package/release-source.json +5 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Conalog
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,7 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Svelte 디자인 시스템
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
`@conalog/ds-svelte`는 `DsTheme`과 등록된 SVG 아이콘을 제공한다. 패키지의 [지원 정보](SUPPORT.json)에서 등록 범위를 확인한다.
|
|
4
|
+
|
|
5
|
+
`DsTheme`의 `theme`에 등록된 이름을 전달하면 하위 영역이 해당 테마의 CSS 변수를 상속한다. 아이콘은 `@conalog/ds-svelte/icons`에서 `PlantFilled`처럼 이름으로 가져오거나, `import * as Icon from '@conalog/ds-svelte/icons'`로 가져와 `<Icon.PlantFilled />`로 표시한다. 개별 경로는 `icons/<name>`와 `icons/<name>/<style>`이다. 단색은 글자색을 따르며 `label`을 생략하면 장식으로 표시한다.
|
|
6
|
+
|
|
7
|
+
소스 저장소에서 `npm run packages:build`로 패키지를 생성한다. Svelte 검증은 패키지의 `test`와 `test:consumer` 스크립트로 실행한다.
|
package/SUPPORT.json
ADDED
|
@@ -0,0 +1,366 @@
|
|
|
1
|
+
{
|
|
2
|
+
"package": "@conalog/ds-svelte",
|
|
3
|
+
"coreVersion": "1.0.0-alpha.1",
|
|
4
|
+
"packageVersion": "1.0.0-alpha.1",
|
|
5
|
+
"fixtureOnly": true,
|
|
6
|
+
"platforms": [
|
|
7
|
+
"web"
|
|
8
|
+
],
|
|
9
|
+
"components": [
|
|
10
|
+
{
|
|
11
|
+
"id": "component.button.action",
|
|
12
|
+
"availability": "experimental",
|
|
13
|
+
"options": {
|
|
14
|
+
"color": [
|
|
15
|
+
"primary",
|
|
16
|
+
"neutral",
|
|
17
|
+
"critical"
|
|
18
|
+
],
|
|
19
|
+
"variant": [
|
|
20
|
+
"solid",
|
|
21
|
+
"weak",
|
|
22
|
+
"outline",
|
|
23
|
+
"clear",
|
|
24
|
+
"quiet"
|
|
25
|
+
],
|
|
26
|
+
"size": [
|
|
27
|
+
"xs",
|
|
28
|
+
"sm",
|
|
29
|
+
"md",
|
|
30
|
+
"lg"
|
|
31
|
+
]
|
|
32
|
+
},
|
|
33
|
+
"variantColors": {
|
|
34
|
+
"quiet": [
|
|
35
|
+
"neutral"
|
|
36
|
+
]
|
|
37
|
+
},
|
|
38
|
+
"platforms": [
|
|
39
|
+
"web"
|
|
40
|
+
],
|
|
41
|
+
"media": [
|
|
42
|
+
"screen"
|
|
43
|
+
]
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
"id": "component.button.icon",
|
|
47
|
+
"availability": "experimental",
|
|
48
|
+
"options": {
|
|
49
|
+
"color": [
|
|
50
|
+
"primary",
|
|
51
|
+
"neutral",
|
|
52
|
+
"critical"
|
|
53
|
+
],
|
|
54
|
+
"variant": [
|
|
55
|
+
"weak",
|
|
56
|
+
"outline",
|
|
57
|
+
"clear",
|
|
58
|
+
"quiet"
|
|
59
|
+
],
|
|
60
|
+
"size": [
|
|
61
|
+
"xs",
|
|
62
|
+
"sm",
|
|
63
|
+
"md",
|
|
64
|
+
"lg"
|
|
65
|
+
]
|
|
66
|
+
},
|
|
67
|
+
"variantColors": {
|
|
68
|
+
"quiet": [
|
|
69
|
+
"neutral"
|
|
70
|
+
]
|
|
71
|
+
},
|
|
72
|
+
"platforms": [
|
|
73
|
+
"web"
|
|
74
|
+
],
|
|
75
|
+
"media": [
|
|
76
|
+
"screen"
|
|
77
|
+
]
|
|
78
|
+
},
|
|
79
|
+
{
|
|
80
|
+
"id": "component.badge",
|
|
81
|
+
"availability": "experimental",
|
|
82
|
+
"options": {
|
|
83
|
+
"size": [
|
|
84
|
+
"sm",
|
|
85
|
+
"md"
|
|
86
|
+
],
|
|
87
|
+
"role": [
|
|
88
|
+
"neutral",
|
|
89
|
+
"primary",
|
|
90
|
+
"critical",
|
|
91
|
+
"warning",
|
|
92
|
+
"positive"
|
|
93
|
+
],
|
|
94
|
+
"variant": [
|
|
95
|
+
"weak",
|
|
96
|
+
"solid",
|
|
97
|
+
"outline"
|
|
98
|
+
]
|
|
99
|
+
},
|
|
100
|
+
"platforms": [
|
|
101
|
+
"web"
|
|
102
|
+
],
|
|
103
|
+
"media": [
|
|
104
|
+
"screen"
|
|
105
|
+
]
|
|
106
|
+
},
|
|
107
|
+
{
|
|
108
|
+
"id": "component.card",
|
|
109
|
+
"availability": "experimental",
|
|
110
|
+
"options": {
|
|
111
|
+
"layout": [
|
|
112
|
+
"block",
|
|
113
|
+
"list",
|
|
114
|
+
"canvas"
|
|
115
|
+
]
|
|
116
|
+
},
|
|
117
|
+
"platforms": [
|
|
118
|
+
"web"
|
|
119
|
+
],
|
|
120
|
+
"media": [
|
|
121
|
+
"screen"
|
|
122
|
+
]
|
|
123
|
+
},
|
|
124
|
+
{
|
|
125
|
+
"id": "component.checkbox",
|
|
126
|
+
"availability": "experimental",
|
|
127
|
+
"options": {},
|
|
128
|
+
"platforms": [
|
|
129
|
+
"web"
|
|
130
|
+
],
|
|
131
|
+
"media": [
|
|
132
|
+
"screen"
|
|
133
|
+
]
|
|
134
|
+
},
|
|
135
|
+
{
|
|
136
|
+
"id": "component.circular-spinner",
|
|
137
|
+
"availability": "experimental",
|
|
138
|
+
"options": {},
|
|
139
|
+
"platforms": [
|
|
140
|
+
"web"
|
|
141
|
+
],
|
|
142
|
+
"media": [
|
|
143
|
+
"screen"
|
|
144
|
+
]
|
|
145
|
+
},
|
|
146
|
+
{
|
|
147
|
+
"id": "component.page-header",
|
|
148
|
+
"availability": "experimental",
|
|
149
|
+
"options": {},
|
|
150
|
+
"platforms": [
|
|
151
|
+
"web"
|
|
152
|
+
],
|
|
153
|
+
"media": [
|
|
154
|
+
"screen"
|
|
155
|
+
]
|
|
156
|
+
},
|
|
157
|
+
{
|
|
158
|
+
"id": "component.status-banner",
|
|
159
|
+
"availability": "experimental",
|
|
160
|
+
"options": {
|
|
161
|
+
"tone": [
|
|
162
|
+
"neutral",
|
|
163
|
+
"accent"
|
|
164
|
+
]
|
|
165
|
+
},
|
|
166
|
+
"platforms": [
|
|
167
|
+
"web"
|
|
168
|
+
],
|
|
169
|
+
"media": [
|
|
170
|
+
"screen"
|
|
171
|
+
]
|
|
172
|
+
},
|
|
173
|
+
{
|
|
174
|
+
"id": "component.tab",
|
|
175
|
+
"availability": "experimental",
|
|
176
|
+
"options": {
|
|
177
|
+
"size": [
|
|
178
|
+
"sm",
|
|
179
|
+
"md"
|
|
180
|
+
]
|
|
181
|
+
},
|
|
182
|
+
"platforms": [
|
|
183
|
+
"web"
|
|
184
|
+
],
|
|
185
|
+
"media": [
|
|
186
|
+
"screen"
|
|
187
|
+
]
|
|
188
|
+
},
|
|
189
|
+
{
|
|
190
|
+
"id": "component.text-field",
|
|
191
|
+
"availability": "experimental",
|
|
192
|
+
"options": {
|
|
193
|
+
"size": [
|
|
194
|
+
"sm",
|
|
195
|
+
"md"
|
|
196
|
+
]
|
|
197
|
+
},
|
|
198
|
+
"platforms": [
|
|
199
|
+
"web"
|
|
200
|
+
],
|
|
201
|
+
"media": [
|
|
202
|
+
"screen"
|
|
203
|
+
]
|
|
204
|
+
},
|
|
205
|
+
{
|
|
206
|
+
"id": "component.divider",
|
|
207
|
+
"availability": "experimental",
|
|
208
|
+
"options": {
|
|
209
|
+
"orientation": [
|
|
210
|
+
"horizontal",
|
|
211
|
+
"vertical"
|
|
212
|
+
],
|
|
213
|
+
"tone": [
|
|
214
|
+
"neutral",
|
|
215
|
+
"weak"
|
|
216
|
+
],
|
|
217
|
+
"inset": [
|
|
218
|
+
"none",
|
|
219
|
+
"spacing.card-edge",
|
|
220
|
+
"spacing-x.global-gutter"
|
|
221
|
+
]
|
|
222
|
+
},
|
|
223
|
+
"provisional": true,
|
|
224
|
+
"platforms": [
|
|
225
|
+
"web"
|
|
226
|
+
],
|
|
227
|
+
"media": [
|
|
228
|
+
"screen"
|
|
229
|
+
]
|
|
230
|
+
},
|
|
231
|
+
{
|
|
232
|
+
"id": "component.chip",
|
|
233
|
+
"availability": "experimental",
|
|
234
|
+
"options": {
|
|
235
|
+
"kind": [
|
|
236
|
+
"toggle",
|
|
237
|
+
"dropdown"
|
|
238
|
+
]
|
|
239
|
+
},
|
|
240
|
+
"provisional": true,
|
|
241
|
+
"platforms": [
|
|
242
|
+
"web"
|
|
243
|
+
],
|
|
244
|
+
"media": [
|
|
245
|
+
"screen"
|
|
246
|
+
]
|
|
247
|
+
},
|
|
248
|
+
{
|
|
249
|
+
"id": "component.menu",
|
|
250
|
+
"availability": "experimental",
|
|
251
|
+
"options": {
|
|
252
|
+
"size": [
|
|
253
|
+
"sm",
|
|
254
|
+
"md"
|
|
255
|
+
]
|
|
256
|
+
},
|
|
257
|
+
"provisional": true,
|
|
258
|
+
"platforms": [
|
|
259
|
+
"web"
|
|
260
|
+
],
|
|
261
|
+
"media": [
|
|
262
|
+
"screen"
|
|
263
|
+
]
|
|
264
|
+
},
|
|
265
|
+
{
|
|
266
|
+
"id": "component.modal",
|
|
267
|
+
"availability": "experimental",
|
|
268
|
+
"options": {},
|
|
269
|
+
"provisional": true,
|
|
270
|
+
"platforms": [
|
|
271
|
+
"web"
|
|
272
|
+
],
|
|
273
|
+
"media": [
|
|
274
|
+
"screen"
|
|
275
|
+
]
|
|
276
|
+
},
|
|
277
|
+
{
|
|
278
|
+
"id": "component.navigation",
|
|
279
|
+
"availability": "experimental",
|
|
280
|
+
"options": {},
|
|
281
|
+
"provisional": true,
|
|
282
|
+
"platforms": [
|
|
283
|
+
"web"
|
|
284
|
+
],
|
|
285
|
+
"media": [
|
|
286
|
+
"screen"
|
|
287
|
+
]
|
|
288
|
+
},
|
|
289
|
+
{
|
|
290
|
+
"id": "component.scope-picker",
|
|
291
|
+
"availability": "experimental",
|
|
292
|
+
"options": {
|
|
293
|
+
"kind": [
|
|
294
|
+
"organization",
|
|
295
|
+
"plant"
|
|
296
|
+
]
|
|
297
|
+
},
|
|
298
|
+
"provisional": true,
|
|
299
|
+
"platforms": [
|
|
300
|
+
"web"
|
|
301
|
+
],
|
|
302
|
+
"media": [
|
|
303
|
+
"screen"
|
|
304
|
+
]
|
|
305
|
+
},
|
|
306
|
+
{
|
|
307
|
+
"id": "component.segmented-control",
|
|
308
|
+
"availability": "experimental",
|
|
309
|
+
"options": {
|
|
310
|
+
"size": [
|
|
311
|
+
"sm",
|
|
312
|
+
"md",
|
|
313
|
+
"lg"
|
|
314
|
+
]
|
|
315
|
+
},
|
|
316
|
+
"provisional": true,
|
|
317
|
+
"platforms": [
|
|
318
|
+
"web"
|
|
319
|
+
],
|
|
320
|
+
"media": [
|
|
321
|
+
"screen"
|
|
322
|
+
]
|
|
323
|
+
},
|
|
324
|
+
{
|
|
325
|
+
"id": "component.table",
|
|
326
|
+
"availability": "experimental",
|
|
327
|
+
"options": {
|
|
328
|
+
"mode": [
|
|
329
|
+
"data",
|
|
330
|
+
"property",
|
|
331
|
+
"entry"
|
|
332
|
+
]
|
|
333
|
+
},
|
|
334
|
+
"provisional": true,
|
|
335
|
+
"platforms": [
|
|
336
|
+
"web"
|
|
337
|
+
],
|
|
338
|
+
"media": [
|
|
339
|
+
"screen"
|
|
340
|
+
]
|
|
341
|
+
},
|
|
342
|
+
{
|
|
343
|
+
"id": "component.tooltip",
|
|
344
|
+
"availability": "experimental",
|
|
345
|
+
"options": {},
|
|
346
|
+
"provisional": true,
|
|
347
|
+
"platforms": [
|
|
348
|
+
"web"
|
|
349
|
+
],
|
|
350
|
+
"media": [
|
|
351
|
+
"screen"
|
|
352
|
+
]
|
|
353
|
+
}
|
|
354
|
+
],
|
|
355
|
+
"themes": [
|
|
356
|
+
"light"
|
|
357
|
+
],
|
|
358
|
+
"icons": {
|
|
359
|
+
"source": "dist/icon-provenance.json",
|
|
360
|
+
"exports": "icons (named exports), icons/<name>[/<style>]"
|
|
361
|
+
},
|
|
362
|
+
"evidence": [
|
|
363
|
+
"npm test -w @conalog/ds-svelte",
|
|
364
|
+
"npm run test:consumer -w @conalog/ds-svelte"
|
|
365
|
+
]
|
|
366
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
<script>
|
|
2
|
+
import Button from './Button.svelte';
|
|
3
|
+
|
|
4
|
+
let {
|
|
5
|
+
label, icon, iconPosition = 'prefix', color, variant = 'solid', size = 'md',
|
|
6
|
+
presentation = 'enabled', type = 'button', onclick,
|
|
7
|
+
} = $props();
|
|
8
|
+
</script>
|
|
9
|
+
|
|
10
|
+
<Button kind="action-button" {label} {icon} {iconPosition} color={color ?? (variant === 'quiet' ? 'neutral' : 'primary')}
|
|
11
|
+
{variant} {size} {presentation} {type} {onclick} />
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
<script>
|
|
2
|
+
import './display.css';
|
|
3
|
+
|
|
4
|
+
let { label, role = 'neutral', variant = 'weak', size = 'md', icon: Icon } = $props();
|
|
5
|
+
|
|
6
|
+
let kind = $derived.by(() => {
|
|
7
|
+
if (typeof label !== 'string' || !label.trim()) throw new TypeError('Badge label is required');
|
|
8
|
+
if (!['neutral', 'primary', 'critical', 'warning', 'positive'].includes(role) ||
|
|
9
|
+
!['weak', 'solid', 'outline'].includes(variant) || !['sm', 'md'].includes(size)) {
|
|
10
|
+
throw new RangeError('Unsupported Badge options');
|
|
11
|
+
}
|
|
12
|
+
return ['badge', role, size, variant].join('-');
|
|
13
|
+
});
|
|
14
|
+
</script>
|
|
15
|
+
|
|
16
|
+
<span class="badge" data-ds-component="badge" data-ds-size={size} data-ds-display={kind}>
|
|
17
|
+
{#if Icon}<span class="icon" aria-hidden="true"><Icon /></span>{/if}
|
|
18
|
+
<span>{label}</span>
|
|
19
|
+
</span>
|
|
20
|
+
|
|
21
|
+
<style>
|
|
22
|
+
.badge {
|
|
23
|
+
display: inline-flex;
|
|
24
|
+
box-sizing: border-box;
|
|
25
|
+
align-items: center;
|
|
26
|
+
gap: var(--ds-display-container-column-gap);
|
|
27
|
+
min-height: var(--ds-display-container-min-height);
|
|
28
|
+
padding-inline: var(--ds-display-container-padding-inline);
|
|
29
|
+
border-radius: var(--ds-display-container-border-radius);
|
|
30
|
+
background: var(--ds-display-container-background-color);
|
|
31
|
+
box-shadow: inset 0 0 0 var(--ds-display-container-border-width, 0px) var(--ds-display-container-border-color, transparent);
|
|
32
|
+
color: var(--ds-display-label-color);
|
|
33
|
+
font-family: var(--ds-display-label-font-family);
|
|
34
|
+
font-size: var(--ds-display-label-font-size);
|
|
35
|
+
font-weight: var(--ds-display-label-font-weight);
|
|
36
|
+
letter-spacing: var(--ds-display-label-letter-spacing);
|
|
37
|
+
line-height: var(--ds-display-label-line-height);
|
|
38
|
+
overflow-wrap: anywhere;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
.icon {
|
|
42
|
+
display: inline-flex;
|
|
43
|
+
flex: none;
|
|
44
|
+
width: var(--ds-display-icon-width);
|
|
45
|
+
height: var(--ds-display-icon-height);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
.icon :global(svg) { width: 100%; height: 100%; }
|
|
49
|
+
</style>
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
<script>
|
|
2
|
+
import { buttonOptions } from './button-options.mjs';
|
|
3
|
+
import './button.css';
|
|
4
|
+
|
|
5
|
+
let {
|
|
6
|
+
kind, label, icon: Icon, iconPosition = 'prefix', color, variant, size,
|
|
7
|
+
presentation = 'enabled', type = 'button', onclick,
|
|
8
|
+
} = $props();
|
|
9
|
+
|
|
10
|
+
const states = ['enabled', 'disabled', 'loading'];
|
|
11
|
+
let key = $derived.by(() => {
|
|
12
|
+
const options = buttonOptions[kind];
|
|
13
|
+
if (!options || !options.color.includes(color) || !options.variant.includes(variant) || !options.size.includes(size)) {
|
|
14
|
+
throw new RangeError('Unsupported ' + kind + ' options: ' + [color, variant, size].join('/'));
|
|
15
|
+
}
|
|
16
|
+
const colors = options.variantColors?.[variant];
|
|
17
|
+
if (colors && !colors.includes(color)) throw new RangeError('Unsupported ' + kind + ' color for ' + variant + ': ' + color);
|
|
18
|
+
if (typeof label !== 'string' || !label.trim()) throw new TypeError('Button label is required');
|
|
19
|
+
if (kind === 'icon-button' && !Icon) throw new TypeError('Icon Button requires an icon');
|
|
20
|
+
if (!states.includes(presentation)) throw new RangeError('Invalid Button presentation');
|
|
21
|
+
if (iconPosition !== 'prefix' && iconPosition !== 'suffix') throw new RangeError('Invalid Button icon position');
|
|
22
|
+
if (!['button', 'submit', 'reset'].includes(type)) throw new RangeError('Invalid HTML Button type');
|
|
23
|
+
return [kind, color, variant, size].join('-');
|
|
24
|
+
});
|
|
25
|
+
let loading = $derived(presentation === 'loading');
|
|
26
|
+
|
|
27
|
+
function activate(event) {
|
|
28
|
+
if (presentation !== 'enabled') {
|
|
29
|
+
event.preventDefault();
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
onclick?.(event);
|
|
33
|
+
}
|
|
34
|
+
</script>
|
|
35
|
+
|
|
36
|
+
{#snippet glyph()}
|
|
37
|
+
{#if Icon}<span class="icon" data-ds-icon aria-hidden="true"><Icon /></span>{/if}
|
|
38
|
+
{/snippet}
|
|
39
|
+
|
|
40
|
+
<button
|
|
41
|
+
{type}
|
|
42
|
+
data-ds-button-kind={key}
|
|
43
|
+
data-ds-button={kind}
|
|
44
|
+
data-ds-size={size}
|
|
45
|
+
data-ds-has-icon={Icon ? 'true' : 'false'}
|
|
46
|
+
data-ds-presentation={presentation}
|
|
47
|
+
aria-label={label}
|
|
48
|
+
aria-busy={loading || undefined}
|
|
49
|
+
aria-disabled={loading || undefined}
|
|
50
|
+
disabled={presentation === 'disabled'}
|
|
51
|
+
tabindex={loading ? -1 : undefined}
|
|
52
|
+
onclick={activate}
|
|
53
|
+
onpointerdown={(event) => { if (loading) event.preventDefault(); }}
|
|
54
|
+
>
|
|
55
|
+
<span class={['content', { loading }]} aria-hidden="true">
|
|
56
|
+
{#if iconPosition === 'prefix'}{@render glyph()}{/if}
|
|
57
|
+
{#if kind === 'action-button'}<span class="label" data-ds-label>{label}</span>{/if}
|
|
58
|
+
{#if iconPosition === 'suffix'}{@render glyph()}{/if}
|
|
59
|
+
</span>
|
|
60
|
+
{#if loading}
|
|
61
|
+
<svg class="spinner" viewBox="0 0 16 16" aria-hidden="true">
|
|
62
|
+
<circle cx="3" cy="8" r="1.5" />
|
|
63
|
+
<circle cx="8" cy="8" r="1.5" />
|
|
64
|
+
<circle cx="13" cy="8" r="1.5" />
|
|
65
|
+
</svg>
|
|
66
|
+
{/if}
|
|
67
|
+
</button>
|
|
68
|
+
|
|
69
|
+
<style>
|
|
70
|
+
button {
|
|
71
|
+
position: relative;
|
|
72
|
+
display: inline-grid;
|
|
73
|
+
box-sizing: border-box;
|
|
74
|
+
place-items: center;
|
|
75
|
+
padding: 0;
|
|
76
|
+
outline: none;
|
|
77
|
+
cursor: pointer;
|
|
78
|
+
vertical-align: middle;
|
|
79
|
+
}
|
|
80
|
+
button:disabled, button[aria-disabled='true'] { cursor: default; }
|
|
81
|
+
.content { display: inline-flex; align-items: center; justify-content: center; gap: inherit; }
|
|
82
|
+
.content.loading { visibility: hidden; }
|
|
83
|
+
.label {
|
|
84
|
+
color: var(--ds-label-color);
|
|
85
|
+
font-family: var(--ds-label-font-family);
|
|
86
|
+
font-size: var(--ds-label-font-size);
|
|
87
|
+
font-weight: var(--ds-label-font-weight);
|
|
88
|
+
letter-spacing: var(--ds-label-letter-spacing);
|
|
89
|
+
line-height: var(--ds-label-line-height);
|
|
90
|
+
}
|
|
91
|
+
.icon, .spinner {
|
|
92
|
+
display: inline-flex;
|
|
93
|
+
flex: none;
|
|
94
|
+
width: var(--ds-icon-width);
|
|
95
|
+
height: var(--ds-icon-height);
|
|
96
|
+
color: var(--ds-icon-color);
|
|
97
|
+
}
|
|
98
|
+
.icon :global(svg) { width: 100%; height: 100%; }
|
|
99
|
+
[data-ds-button='action-button'] .icon { transform: translateY(-1px); }
|
|
100
|
+
.spinner { position: absolute; color: var(--ds-spinner-color); fill: currentColor; }
|
|
101
|
+
@media (prefers-reduced-motion: no-preference) {
|
|
102
|
+
.spinner circle { animation: fade 1s ease-in-out infinite; }
|
|
103
|
+
.spinner circle:nth-child(2) { animation-delay: 120ms; }
|
|
104
|
+
.spinner circle:nth-child(3) { animation-delay: 240ms; }
|
|
105
|
+
}
|
|
106
|
+
@keyframes fade { 0%, 80%, 100% { opacity: .35; } 40% { opacity: 1; } }
|
|
107
|
+
</style>
|
package/dist/Card.svelte
ADDED
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
<script>
|
|
2
|
+
import './display.css';
|
|
3
|
+
|
|
4
|
+
let { heading, description, actions, layout = 'block', children } = $props();
|
|
5
|
+
let scope = $derived.by(() => {
|
|
6
|
+
if (!['block', 'list', 'canvas'].includes(layout)) throw new RangeError('Invalid Card layout');
|
|
7
|
+
if (heading !== undefined && (typeof heading !== 'string' || !heading.trim())) {
|
|
8
|
+
throw new TypeError('Card heading must contain text');
|
|
9
|
+
}
|
|
10
|
+
if ((description !== undefined || actions) && heading === undefined) throw new TypeError('Card header content requires a heading');
|
|
11
|
+
return 'card-' + layout;
|
|
12
|
+
});
|
|
13
|
+
</script>
|
|
14
|
+
|
|
15
|
+
<section data-ds-component="card" data-ds-display={scope}>
|
|
16
|
+
{#if heading !== undefined}
|
|
17
|
+
<header>
|
|
18
|
+
<div class="heading">
|
|
19
|
+
<h2>{heading}</h2>
|
|
20
|
+
{#if description}<p>{description}</p>{/if}
|
|
21
|
+
</div>
|
|
22
|
+
{#if actions}<div class="actions">{@render actions()}</div>{/if}
|
|
23
|
+
</header>
|
|
24
|
+
{/if}
|
|
25
|
+
<div class="body">{@render children()}</div>
|
|
26
|
+
</section>
|
|
27
|
+
|
|
28
|
+
<style>
|
|
29
|
+
section {
|
|
30
|
+
position: relative;
|
|
31
|
+
overflow: hidden;
|
|
32
|
+
background: var(--ds-display-container-background-color);
|
|
33
|
+
border-radius: var(--ds-display-container-border-radius);
|
|
34
|
+
}
|
|
35
|
+
section::after {
|
|
36
|
+
position: absolute;
|
|
37
|
+
inset: 0;
|
|
38
|
+
border-radius: inherit;
|
|
39
|
+
box-shadow: inset 0 0 0 var(--ds-display-container-border-width) var(--ds-display-container-border-color);
|
|
40
|
+
content: '';
|
|
41
|
+
pointer-events: none;
|
|
42
|
+
}
|
|
43
|
+
header {
|
|
44
|
+
display: flex;
|
|
45
|
+
flex-wrap: wrap;
|
|
46
|
+
justify-content: space-between;
|
|
47
|
+
align-items: start;
|
|
48
|
+
gap: var(--ds-display-header-column-gap);
|
|
49
|
+
padding-inline: var(--ds-display-header-padding-inline);
|
|
50
|
+
padding-block-start: var(--ds-display-header-padding-block-start);
|
|
51
|
+
padding-block-end: var(--ds-display-header-padding-block-end);
|
|
52
|
+
}
|
|
53
|
+
.heading { display: grid; min-inline-size: 0; gap: var(--ds-display-header-column-gap); }
|
|
54
|
+
.actions { display: flex; flex-wrap: wrap; justify-content: end; margin-inline-start: auto; gap: var(--ds-display-header-column-gap); }
|
|
55
|
+
h2, p { margin: 0; overflow-wrap: anywhere; }
|
|
56
|
+
h2 {
|
|
57
|
+
color: var(--ds-display-title-color);
|
|
58
|
+
font-family: var(--ds-display-title-font-family);
|
|
59
|
+
font-size: var(--ds-display-title-font-size);
|
|
60
|
+
font-weight: var(--ds-display-title-font-weight);
|
|
61
|
+
letter-spacing: var(--ds-display-title-letter-spacing);
|
|
62
|
+
line-height: var(--ds-display-title-line-height);
|
|
63
|
+
}
|
|
64
|
+
p {
|
|
65
|
+
color: var(--ds-display-description-color);
|
|
66
|
+
font-family: var(--ds-display-description-font-family);
|
|
67
|
+
font-size: var(--ds-display-description-font-size);
|
|
68
|
+
font-weight: var(--ds-display-description-font-weight);
|
|
69
|
+
letter-spacing: var(--ds-display-description-letter-spacing);
|
|
70
|
+
line-height: var(--ds-display-description-line-height);
|
|
71
|
+
}
|
|
72
|
+
.body {
|
|
73
|
+
padding-inline: var(--ds-display-body-padding-inline);
|
|
74
|
+
padding-block-end: var(--ds-display-body-padding-block-end);
|
|
75
|
+
}
|
|
76
|
+
</style>
|