@14ch/svelte-ui 0.0.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/README.md +359 -0
- package/dist/assets/styles/README.md +144 -0
- package/dist/assets/styles/core.scss +61 -0
- package/dist/assets/styles/import.scss +11 -0
- package/dist/assets/styles/optional/fonts.scss +23 -0
- package/dist/assets/styles/optional/reset.scss +230 -0
- package/dist/assets/styles/variables.scss +805 -0
- package/dist/components/Button.svelte +574 -0
- package/dist/components/Button.svelte.d.ts +56 -0
- package/dist/components/COMPONENT_DESIGN_GUIDELINES.md +127 -0
- package/dist/components/Checkbox.svelte +523 -0
- package/dist/components/Checkbox.svelte.d.ts +42 -0
- package/dist/components/CheckboxGroup.svelte +82 -0
- package/dist/components/CheckboxGroup.svelte.d.ts +13 -0
- package/dist/components/ColorPicker.svelte +496 -0
- package/dist/components/ColorPicker.svelte.d.ts +45 -0
- package/dist/components/Combobox.svelte +576 -0
- package/dist/components/Combobox.svelte.d.ts +52 -0
- package/dist/components/ConfirmDialog.svelte +116 -0
- package/dist/components/ConfirmDialog.svelte.d.ts +20 -0
- package/dist/components/Datepicker.svelte +578 -0
- package/dist/components/Datepicker.svelte.d.ts +72 -0
- package/dist/components/DatepickerCalendar.svelte +925 -0
- package/dist/components/DatepickerCalendar.svelte.d.ts +31 -0
- package/dist/components/Dialog.svelte +245 -0
- package/dist/components/Dialog.svelte.d.ts +38 -0
- package/dist/components/Drawer.svelte +383 -0
- package/dist/components/Drawer.svelte.d.ts +39 -0
- package/dist/components/Fab.svelte +486 -0
- package/dist/components/Fab.svelte.d.ts +51 -0
- package/dist/components/FileUploader.svelte +456 -0
- package/dist/components/FileUploader.svelte.d.ts +36 -0
- package/dist/components/Icon.svelte +167 -0
- package/dist/components/Icon.svelte.d.ts +21 -0
- package/dist/components/IconButton.svelte +557 -0
- package/dist/components/IconButton.svelte.d.ts +60 -0
- package/dist/components/ImageUploader.svelte +516 -0
- package/dist/components/ImageUploader.svelte.d.ts +37 -0
- package/dist/components/ImageUploaderPreview.svelte +157 -0
- package/dist/components/ImageUploaderPreview.svelte.d.ts +13 -0
- package/dist/components/Input.svelte +885 -0
- package/dist/components/Input.svelte.d.ts +75 -0
- package/dist/components/LoadingSpinner.svelte +116 -0
- package/dist/components/LoadingSpinner.svelte.d.ts +10 -0
- package/dist/components/Modal.svelte +313 -0
- package/dist/components/Modal.svelte.d.ts +34 -0
- package/dist/components/Pagination.svelte +276 -0
- package/dist/components/Pagination.svelte.d.ts +14 -0
- package/dist/components/Popup.svelte +676 -0
- package/dist/components/Popup.svelte.d.ts +40 -0
- package/dist/components/PopupMenu.svelte +421 -0
- package/dist/components/PopupMenu.svelte.d.ts +24 -0
- package/dist/components/PopupMenuButton.svelte +365 -0
- package/dist/components/PopupMenuButton.svelte.d.ts +42 -0
- package/dist/components/Radio.svelte +548 -0
- package/dist/components/Radio.svelte.d.ts +42 -0
- package/dist/components/RadioGroup.svelte +74 -0
- package/dist/components/RadioGroup.svelte.d.ts +14 -0
- package/dist/components/Select.svelte +479 -0
- package/dist/components/Select.svelte.d.ts +47 -0
- package/dist/components/Slider.svelte +473 -0
- package/dist/components/Slider.svelte.d.ts +46 -0
- package/dist/components/Snackbar.svelte +124 -0
- package/dist/components/Snackbar.svelte.d.ts +9 -0
- package/dist/components/SnackbarItem.svelte +423 -0
- package/dist/components/SnackbarItem.svelte.d.ts +21 -0
- package/dist/components/Switch.svelte +454 -0
- package/dist/components/Switch.svelte.d.ts +40 -0
- package/dist/components/Tab.svelte +193 -0
- package/dist/components/Tab.svelte.d.ts +14 -0
- package/dist/components/TabItem.svelte +140 -0
- package/dist/components/TabItem.svelte.d.ts +17 -0
- package/dist/components/Textarea.svelte +702 -0
- package/dist/components/Textarea.svelte.d.ts +64 -0
- package/dist/components/skeleton/Skeleton.svelte +235 -0
- package/dist/components/skeleton/Skeleton.svelte.d.ts +13 -0
- package/dist/components/skeleton/SkeletonAvatar.svelte +97 -0
- package/dist/components/skeleton/SkeletonAvatar.svelte.d.ts +8 -0
- package/dist/components/skeleton/SkeletonBox.svelte +105 -0
- package/dist/components/skeleton/SkeletonBox.svelte.d.ts +12 -0
- package/dist/components/skeleton/SkeletonButton.svelte +71 -0
- package/dist/components/skeleton/SkeletonButton.svelte.d.ts +8 -0
- package/dist/components/skeleton/SkeletonHeading.svelte +49 -0
- package/dist/components/skeleton/SkeletonHeading.svelte.d.ts +8 -0
- package/dist/components/skeleton/SkeletonMedia.svelte +115 -0
- package/dist/components/skeleton/SkeletonMedia.svelte.d.ts +9 -0
- package/dist/components/skeleton/SkeletonText.svelte +75 -0
- package/dist/components/skeleton/SkeletonText.svelte.d.ts +8 -0
- package/dist/index.d.ts +42 -0
- package/dist/index.js +43 -0
- package/dist/types/icon.d.ts +4 -0
- package/dist/types/icon.js +2 -0
- package/dist/types/menuItem.d.ts +8 -0
- package/dist/types/menuItem.js +1 -0
- package/dist/types/options.d.ts +6 -0
- package/dist/types/options.js +4 -0
- package/dist/types/skeleton.d.ts +77 -0
- package/dist/types/skeleton.js +19 -0
- package/dist/utils/accessibility.d.ts +48 -0
- package/dist/utils/accessibility.js +87 -0
- package/dist/utils/formatText.d.ts +4 -0
- package/dist/utils/formatText.js +44 -0
- package/dist/utils/mobile.d.ts +9 -0
- package/dist/utils/mobile.js +47 -0
- package/dist/utils/snackbar.svelte.d.ts +51 -0
- package/dist/utils/snackbar.svelte.js +107 -0
- package/dist/utils/style.d.ts +17 -0
- package/dist/utils/style.js +22 -0
- package/package.json +102 -0
|
@@ -0,0 +1,574 @@
|
|
|
1
|
+
<!-- Button.svelte -->
|
|
2
|
+
|
|
3
|
+
<script lang="ts">
|
|
4
|
+
import type { Snippet } from 'svelte';
|
|
5
|
+
import type { HTMLButtonAttributes } from 'svelte/elements';
|
|
6
|
+
import type { IconVariant, IconWeight, IconGrade, IconOpticalSize } from '../types/icon';
|
|
7
|
+
import Icon from './Icon.svelte';
|
|
8
|
+
import LoadingSpinner from './LoadingSpinner.svelte';
|
|
9
|
+
import { getStyleFromNumber } from '../utils/style';
|
|
10
|
+
|
|
11
|
+
// =========================================================================
|
|
12
|
+
// Props, States & Constants
|
|
13
|
+
// =========================================================================
|
|
14
|
+
let {
|
|
15
|
+
// Snippet
|
|
16
|
+
children,
|
|
17
|
+
|
|
18
|
+
// HTML属性系
|
|
19
|
+
buttonAttributes,
|
|
20
|
+
type = 'button',
|
|
21
|
+
tabindex = null,
|
|
22
|
+
|
|
23
|
+
// スタイル/レイアウト
|
|
24
|
+
customStyle,
|
|
25
|
+
variant = 'ghost',
|
|
26
|
+
size = 'medium',
|
|
27
|
+
color,
|
|
28
|
+
fullWidth = false,
|
|
29
|
+
minWidth = 0,
|
|
30
|
+
rounded = false,
|
|
31
|
+
popup = false,
|
|
32
|
+
|
|
33
|
+
// アイコン関連
|
|
34
|
+
icon = '',
|
|
35
|
+
iconFilled = false,
|
|
36
|
+
iconWeight = 300,
|
|
37
|
+
iconGrade = 0,
|
|
38
|
+
iconOpticalSize = null,
|
|
39
|
+
iconVariant = 'outlined',
|
|
40
|
+
|
|
41
|
+
// 状態/動作
|
|
42
|
+
disabled = false,
|
|
43
|
+
loading = false,
|
|
44
|
+
reducedMotion = false,
|
|
45
|
+
|
|
46
|
+
// ARIA/アクセシビリティ
|
|
47
|
+
ariaLabel,
|
|
48
|
+
ariaDescribedby,
|
|
49
|
+
ariaExpanded,
|
|
50
|
+
|
|
51
|
+
// フォーカスイベント
|
|
52
|
+
onfocus = () => {}, // No params for type inference
|
|
53
|
+
onblur = () => {}, // No params for type inference
|
|
54
|
+
|
|
55
|
+
// キーボードイベント
|
|
56
|
+
onkeydown = () => {}, // No params for type inference
|
|
57
|
+
onkeyup = () => {}, // No params for type inference
|
|
58
|
+
|
|
59
|
+
// マウスイベント
|
|
60
|
+
onclick,
|
|
61
|
+
onmousedown = () => {}, // No params for type inference
|
|
62
|
+
onmouseup = () => {}, // No params for type inference
|
|
63
|
+
onmouseenter = () => {}, // No params for type inference
|
|
64
|
+
onmouseleave = () => {}, // No params for type inference
|
|
65
|
+
onmouseover = () => {}, // No params for type inference
|
|
66
|
+
onmouseout = () => {}, // No params for type inference
|
|
67
|
+
oncontextmenu = () => {}, // No params for type inference
|
|
68
|
+
onauxclick = () => {}, // No params for type inference
|
|
69
|
+
|
|
70
|
+
// タッチイベント
|
|
71
|
+
ontouchstart = () => {}, // No params for type inference
|
|
72
|
+
ontouchend = () => {}, // No params for type inference
|
|
73
|
+
ontouchmove = () => {}, // No params for type inference
|
|
74
|
+
ontouchcancel = () => {}, // No params for type inference
|
|
75
|
+
|
|
76
|
+
// ポインターイベント
|
|
77
|
+
onpointerdown = () => {}, // No params for type inference
|
|
78
|
+
onpointerup = () => {}, // No params for type inference
|
|
79
|
+
onpointerenter = () => {}, // No params for type inference
|
|
80
|
+
onpointerleave = () => {}, // No params for type inference
|
|
81
|
+
onpointermove = () => {}, // No params for type inference
|
|
82
|
+
onpointercancel = () => {}, // No params for type inference
|
|
83
|
+
|
|
84
|
+
// その他
|
|
85
|
+
...restProps
|
|
86
|
+
}: {
|
|
87
|
+
// Snippet
|
|
88
|
+
children: Snippet;
|
|
89
|
+
|
|
90
|
+
// HTML属性系
|
|
91
|
+
buttonAttributes?: HTMLButtonAttributes | undefined;
|
|
92
|
+
type?: HTMLButtonAttributes['type'];
|
|
93
|
+
tabindex?: number | null;
|
|
94
|
+
|
|
95
|
+
// スタイル/レイアウト
|
|
96
|
+
customStyle?: HTMLButtonAttributes['style'];
|
|
97
|
+
variant?: 'ghost' | 'filled' | 'outlined' | 'glass';
|
|
98
|
+
size?: 'small' | 'medium' | 'large';
|
|
99
|
+
color?: string;
|
|
100
|
+
fullWidth?: boolean;
|
|
101
|
+
minWidth?: string | number;
|
|
102
|
+
rounded?: boolean;
|
|
103
|
+
popup?: boolean;
|
|
104
|
+
|
|
105
|
+
// アイコン関連
|
|
106
|
+
icon?: string;
|
|
107
|
+
iconFilled?: boolean;
|
|
108
|
+
iconWeight?: IconWeight;
|
|
109
|
+
iconGrade?: IconGrade;
|
|
110
|
+
iconOpticalSize?: IconOpticalSize;
|
|
111
|
+
iconVariant?: IconVariant;
|
|
112
|
+
|
|
113
|
+
// 状態/動作
|
|
114
|
+
disabled?: boolean;
|
|
115
|
+
loading?: boolean;
|
|
116
|
+
reducedMotion?: boolean;
|
|
117
|
+
|
|
118
|
+
// ARIA/アクセシビリティ
|
|
119
|
+
ariaLabel?: string;
|
|
120
|
+
ariaDescribedby?: string;
|
|
121
|
+
ariaExpanded?: boolean;
|
|
122
|
+
|
|
123
|
+
// フォーカスイベント
|
|
124
|
+
onfocus?: Function; // No params for type inference
|
|
125
|
+
onblur?: Function; // No params for type inference
|
|
126
|
+
|
|
127
|
+
// キーボードイベント
|
|
128
|
+
onkeydown?: Function; // No params for type inference
|
|
129
|
+
onkeyup?: Function; // No params for type inference
|
|
130
|
+
|
|
131
|
+
// マウスイベント
|
|
132
|
+
onclick?: Function; // No params for type inference
|
|
133
|
+
onmousedown?: Function; // No params for type inference
|
|
134
|
+
onmouseup?: Function; // No params for type inference
|
|
135
|
+
onmouseenter?: Function; // No params for type inference
|
|
136
|
+
onmouseleave?: Function; // No params for type inference
|
|
137
|
+
onmouseover?: Function; // No params for type inference
|
|
138
|
+
onmouseout?: Function; // No params for type inference
|
|
139
|
+
oncontextmenu?: Function; // No params for type inference
|
|
140
|
+
onauxclick?: Function; // No params for type inference
|
|
141
|
+
|
|
142
|
+
// タッチイベント
|
|
143
|
+
ontouchstart?: Function; // No params for type inference
|
|
144
|
+
ontouchend?: Function; // No params for type inference
|
|
145
|
+
ontouchmove?: Function; // No params for type inference
|
|
146
|
+
ontouchcancel?: Function; // No params for type inference
|
|
147
|
+
|
|
148
|
+
// ポインターイベント
|
|
149
|
+
onpointerdown?: Function; // No params for type inference
|
|
150
|
+
onpointerup?: Function; // No params for type inference
|
|
151
|
+
onpointerenter?: Function; // No params for type inference
|
|
152
|
+
onpointerleave?: Function; // No params for type inference
|
|
153
|
+
onpointermove?: Function; // No params for type inference
|
|
154
|
+
onpointercancel?: Function; // No params for type inference
|
|
155
|
+
|
|
156
|
+
// その他
|
|
157
|
+
[key: string]: any;
|
|
158
|
+
} = $props();
|
|
159
|
+
|
|
160
|
+
const backgroundColors = $derived({
|
|
161
|
+
filled: color ?? 'var(--svelte-ui-button-bg-filled)',
|
|
162
|
+
outlined: 'transparent',
|
|
163
|
+
ghost: 'transparent',
|
|
164
|
+
glass: 'var(--svelte-ui-button-bg-glass)'
|
|
165
|
+
});
|
|
166
|
+
|
|
167
|
+
const textColors = $derived({
|
|
168
|
+
filled: 'var(--svelte-ui-button-text-filled)',
|
|
169
|
+
outlined: color ?? 'var(--svelte-ui-button-text-outlined)',
|
|
170
|
+
ghost: color ?? 'var(--svelte-ui-button-text-ghost)',
|
|
171
|
+
glass: color ?? 'var(--svelte-ui-button-text-glass)'
|
|
172
|
+
});
|
|
173
|
+
|
|
174
|
+
// =========================================================================
|
|
175
|
+
// Methods
|
|
176
|
+
// =========================================================================
|
|
177
|
+
const handleClick = (event: MouseEvent) => {
|
|
178
|
+
if (isDisabled) return;
|
|
179
|
+
if (onclick) onclick(event);
|
|
180
|
+
};
|
|
181
|
+
|
|
182
|
+
const handleAuxClick = (event: MouseEvent) => {
|
|
183
|
+
if (isDisabled) return;
|
|
184
|
+
onauxclick(event);
|
|
185
|
+
};
|
|
186
|
+
|
|
187
|
+
const handleFocus = (event: FocusEvent) => {
|
|
188
|
+
onfocus(event);
|
|
189
|
+
};
|
|
190
|
+
|
|
191
|
+
const handleBlur = (event: FocusEvent) => {
|
|
192
|
+
onblur(event);
|
|
193
|
+
};
|
|
194
|
+
|
|
195
|
+
const handleKeydown = (event: KeyboardEvent) => {
|
|
196
|
+
onkeydown(event);
|
|
197
|
+
};
|
|
198
|
+
|
|
199
|
+
const handleKeyup = (event: KeyboardEvent) => {
|
|
200
|
+
onkeyup(event);
|
|
201
|
+
};
|
|
202
|
+
|
|
203
|
+
// マウスイベント
|
|
204
|
+
const handleMouseDown = (event: MouseEvent) => {
|
|
205
|
+
if (isDisabled) return;
|
|
206
|
+
onmousedown(event);
|
|
207
|
+
};
|
|
208
|
+
|
|
209
|
+
const handleMouseUp = (event: MouseEvent) => {
|
|
210
|
+
if (isDisabled) return;
|
|
211
|
+
onmouseup(event);
|
|
212
|
+
};
|
|
213
|
+
|
|
214
|
+
const handleMouseEnter = (event: MouseEvent) => {
|
|
215
|
+
if (isDisabled) return;
|
|
216
|
+
onmouseenter(event);
|
|
217
|
+
};
|
|
218
|
+
|
|
219
|
+
const handleMouseLeave = (event: MouseEvent) => {
|
|
220
|
+
if (isDisabled) return;
|
|
221
|
+
onmouseleave(event);
|
|
222
|
+
};
|
|
223
|
+
|
|
224
|
+
const handleMouseOver = (event: MouseEvent) => {
|
|
225
|
+
if (isDisabled) return;
|
|
226
|
+
onmouseover(event);
|
|
227
|
+
};
|
|
228
|
+
|
|
229
|
+
const handleMouseOut = (event: MouseEvent) => {
|
|
230
|
+
if (isDisabled) return;
|
|
231
|
+
onmouseout(event);
|
|
232
|
+
};
|
|
233
|
+
|
|
234
|
+
const handleContextMenu = (event: MouseEvent) => {
|
|
235
|
+
if (isDisabled) return;
|
|
236
|
+
oncontextmenu(event);
|
|
237
|
+
};
|
|
238
|
+
|
|
239
|
+
// タッチイベント
|
|
240
|
+
const handleTouchStart = (event: TouchEvent) => {
|
|
241
|
+
if (isDisabled) return;
|
|
242
|
+
ontouchstart(event);
|
|
243
|
+
};
|
|
244
|
+
|
|
245
|
+
const handleTouchEnd = (event: TouchEvent) => {
|
|
246
|
+
if (isDisabled) return;
|
|
247
|
+
ontouchend(event);
|
|
248
|
+
};
|
|
249
|
+
|
|
250
|
+
const handleTouchMove = (event: TouchEvent) => {
|
|
251
|
+
if (isDisabled) return;
|
|
252
|
+
ontouchmove(event);
|
|
253
|
+
};
|
|
254
|
+
|
|
255
|
+
const handleTouchCancel = (event: TouchEvent) => {
|
|
256
|
+
if (isDisabled) return;
|
|
257
|
+
ontouchcancel(event);
|
|
258
|
+
};
|
|
259
|
+
|
|
260
|
+
// ポインターイベント
|
|
261
|
+
const handlePointerDown = (event: PointerEvent) => {
|
|
262
|
+
if (isDisabled) return;
|
|
263
|
+
onpointerdown(event);
|
|
264
|
+
};
|
|
265
|
+
|
|
266
|
+
const handlePointerUp = (event: PointerEvent) => {
|
|
267
|
+
if (isDisabled) return;
|
|
268
|
+
onpointerup(event);
|
|
269
|
+
};
|
|
270
|
+
|
|
271
|
+
const handlePointerEnter = (event: PointerEvent) => {
|
|
272
|
+
if (isDisabled) return;
|
|
273
|
+
onpointerenter(event);
|
|
274
|
+
};
|
|
275
|
+
|
|
276
|
+
const handlePointerLeave = (event: PointerEvent) => {
|
|
277
|
+
if (isDisabled) return;
|
|
278
|
+
onpointerleave(event);
|
|
279
|
+
};
|
|
280
|
+
|
|
281
|
+
const handlePointerMove = (event: PointerEvent) => {
|
|
282
|
+
if (isDisabled) return;
|
|
283
|
+
onpointermove(event);
|
|
284
|
+
};
|
|
285
|
+
|
|
286
|
+
const handlePointerCancel = (event: PointerEvent) => {
|
|
287
|
+
if (isDisabled) return;
|
|
288
|
+
onpointercancel(event);
|
|
289
|
+
};
|
|
290
|
+
|
|
291
|
+
// =========================================================================
|
|
292
|
+
// $derived
|
|
293
|
+
// =========================================================================
|
|
294
|
+
const isDisabled = $derived(disabled || loading);
|
|
295
|
+
|
|
296
|
+
const buttonClasses = $derived(
|
|
297
|
+
[
|
|
298
|
+
'button',
|
|
299
|
+
`button--${variant}`,
|
|
300
|
+
`button--${size}`,
|
|
301
|
+
popup && 'button--popup',
|
|
302
|
+
rounded && 'button--rounded',
|
|
303
|
+
fullWidth && 'button--full-width',
|
|
304
|
+
loading && 'button--loading',
|
|
305
|
+
reducedMotion && 'button--no-motion'
|
|
306
|
+
]
|
|
307
|
+
.filter(Boolean)
|
|
308
|
+
.join(' ')
|
|
309
|
+
);
|
|
310
|
+
|
|
311
|
+
const minWidthStyle = $derived(getStyleFromNumber(minWidth));
|
|
312
|
+
</script>
|
|
313
|
+
|
|
314
|
+
<button
|
|
315
|
+
{type}
|
|
316
|
+
disabled={isDisabled}
|
|
317
|
+
class={buttonClasses}
|
|
318
|
+
style="color: {textColors[variant]}; background-color: {backgroundColors[variant]};
|
|
319
|
+
min-width: {minWidthStyle};
|
|
320
|
+
{customStyle ?? ''};"
|
|
321
|
+
onclick={handleClick}
|
|
322
|
+
onauxclick={handleAuxClick}
|
|
323
|
+
onfocus={handleFocus}
|
|
324
|
+
onblur={handleBlur}
|
|
325
|
+
onkeydown={handleKeydown}
|
|
326
|
+
onkeyup={handleKeyup}
|
|
327
|
+
onmousedown={handleMouseDown}
|
|
328
|
+
onmouseup={handleMouseUp}
|
|
329
|
+
onmouseenter={handleMouseEnter}
|
|
330
|
+
onmouseleave={handleMouseLeave}
|
|
331
|
+
onmouseover={handleMouseOver}
|
|
332
|
+
onmouseout={handleMouseOut}
|
|
333
|
+
oncontextmenu={handleContextMenu}
|
|
334
|
+
ontouchstart={handleTouchStart}
|
|
335
|
+
ontouchend={handleTouchEnd}
|
|
336
|
+
ontouchmove={handleTouchMove}
|
|
337
|
+
ontouchcancel={handleTouchCancel}
|
|
338
|
+
onpointerdown={handlePointerDown}
|
|
339
|
+
onpointerup={handlePointerUp}
|
|
340
|
+
onpointerenter={handlePointerEnter}
|
|
341
|
+
onpointerleave={handlePointerLeave}
|
|
342
|
+
onpointermove={handlePointerMove}
|
|
343
|
+
onpointercancel={handlePointerCancel}
|
|
344
|
+
{tabindex}
|
|
345
|
+
aria-label={ariaLabel}
|
|
346
|
+
aria-describedby={ariaDescribedby}
|
|
347
|
+
aria-expanded={ariaExpanded}
|
|
348
|
+
aria-busy={loading ? 'true' : undefined}
|
|
349
|
+
data-testid="button"
|
|
350
|
+
{...buttonAttributes}
|
|
351
|
+
{...restProps}
|
|
352
|
+
>
|
|
353
|
+
{#if loading}
|
|
354
|
+
<div class="button__loading">
|
|
355
|
+
<LoadingSpinner size={18} strokeWidth={2} color="currentColor" />
|
|
356
|
+
</div>
|
|
357
|
+
{:else if icon}
|
|
358
|
+
<div class="button__icon">
|
|
359
|
+
<Icon
|
|
360
|
+
filled={iconFilled}
|
|
361
|
+
weight={iconWeight}
|
|
362
|
+
grade={iconGrade}
|
|
363
|
+
opticalSize={iconOpticalSize}
|
|
364
|
+
variant={iconVariant}>{icon}</Icon
|
|
365
|
+
>
|
|
366
|
+
</div>
|
|
367
|
+
{/if}
|
|
368
|
+
|
|
369
|
+
<div class="button__label" class:button__label--hidden={loading}>
|
|
370
|
+
{@render children()}
|
|
371
|
+
</div>
|
|
372
|
+
|
|
373
|
+
{#if popup && !loading}
|
|
374
|
+
<div class="button__popup-icon">
|
|
375
|
+
<Icon>arrow_drop_down</Icon>
|
|
376
|
+
</div>
|
|
377
|
+
{/if}
|
|
378
|
+
</button>
|
|
379
|
+
|
|
380
|
+
<style>
|
|
381
|
+
.button {
|
|
382
|
+
display: flex;
|
|
383
|
+
justify-content: center;
|
|
384
|
+
align-items: center;
|
|
385
|
+
gap: 4px;
|
|
386
|
+
position: relative;
|
|
387
|
+
max-width: 100%;
|
|
388
|
+
background-color: transparent;
|
|
389
|
+
border: none;
|
|
390
|
+
border-radius: var(--svelte-ui-button-border-radius);
|
|
391
|
+
font-size: inherit;
|
|
392
|
+
font-family: inherit;
|
|
393
|
+
line-height: normal;
|
|
394
|
+
overflow: hidden;
|
|
395
|
+
cursor: pointer;
|
|
396
|
+
transition-property: background-color, box-shadow, color, opacity, transform;
|
|
397
|
+
transition-duration: var(--svelte-ui-transition-duration);
|
|
398
|
+
}
|
|
399
|
+
|
|
400
|
+
/* Size variants */
|
|
401
|
+
.button--small {
|
|
402
|
+
min-height: var(--svelte-ui-button-height-sm);
|
|
403
|
+
padding: var(--svelte-ui-button-padding-sm);
|
|
404
|
+
font-size: var(--svelte-ui-button-font-size-sm);
|
|
405
|
+
}
|
|
406
|
+
|
|
407
|
+
.button--medium {
|
|
408
|
+
min-height: var(--svelte-ui-button-height);
|
|
409
|
+
padding: var(--svelte-ui-button-padding);
|
|
410
|
+
font-size: var(--svelte-ui-button-font-size);
|
|
411
|
+
}
|
|
412
|
+
|
|
413
|
+
.button--large {
|
|
414
|
+
min-height: var(--svelte-ui-button-height-lg);
|
|
415
|
+
padding: var(--svelte-ui-button-padding-lg);
|
|
416
|
+
font-size: var(--svelte-ui-button-font-size-lg);
|
|
417
|
+
}
|
|
418
|
+
|
|
419
|
+
/* Mobile touch targets */
|
|
420
|
+
@media (hover: none) and (pointer: coarse) {
|
|
421
|
+
.button--small {
|
|
422
|
+
min-height: var(--svelte-ui-touch-target-sm);
|
|
423
|
+
}
|
|
424
|
+
.button--medium {
|
|
425
|
+
min-height: var(--svelte-ui-touch-target);
|
|
426
|
+
}
|
|
427
|
+
.button--large {
|
|
428
|
+
min-height: var(--svelte-ui-touch-target-lg);
|
|
429
|
+
}
|
|
430
|
+
}
|
|
431
|
+
|
|
432
|
+
/* Variant styles */
|
|
433
|
+
.button--outlined {
|
|
434
|
+
box-shadow: inset 0 0 0 var(--svelte-ui-border-width) currentColor;
|
|
435
|
+
}
|
|
436
|
+
|
|
437
|
+
.button--glass {
|
|
438
|
+
backdrop-filter: var(--svelte-ui-glass-blur);
|
|
439
|
+
-webkit-backdrop-filter: var(--svelte-ui-glass-blur);
|
|
440
|
+
}
|
|
441
|
+
|
|
442
|
+
/* State modifiers */
|
|
443
|
+
.button--full-width {
|
|
444
|
+
width: 100%;
|
|
445
|
+
}
|
|
446
|
+
|
|
447
|
+
.button--rounded {
|
|
448
|
+
border-radius: var(--svelte-ui-button-border-radius-rounded);
|
|
449
|
+
}
|
|
450
|
+
|
|
451
|
+
/* Hover effects */
|
|
452
|
+
.button:before {
|
|
453
|
+
content: '';
|
|
454
|
+
display: block;
|
|
455
|
+
position: absolute;
|
|
456
|
+
top: 0;
|
|
457
|
+
left: 0;
|
|
458
|
+
width: 100%;
|
|
459
|
+
height: 100%;
|
|
460
|
+
background-color: var(--svelte-ui-button-hover-overlay);
|
|
461
|
+
opacity: 0;
|
|
462
|
+
transition-property: opacity;
|
|
463
|
+
transition-duration: var(--svelte-ui-transition-duration);
|
|
464
|
+
z-index: 0;
|
|
465
|
+
}
|
|
466
|
+
|
|
467
|
+
@media (hover: hover) {
|
|
468
|
+
.button:hover:before {
|
|
469
|
+
opacity: 1;
|
|
470
|
+
}
|
|
471
|
+
}
|
|
472
|
+
|
|
473
|
+
/* Focus styles */
|
|
474
|
+
.button:focus-visible {
|
|
475
|
+
outline: 2px solid var(--svelte-ui-button-focus-color);
|
|
476
|
+
outline-offset: 2px;
|
|
477
|
+
}
|
|
478
|
+
|
|
479
|
+
/* Disabled state */
|
|
480
|
+
.button:disabled {
|
|
481
|
+
opacity: var(--svelte-ui-button-disabled-opacity);
|
|
482
|
+
cursor: not-allowed;
|
|
483
|
+
pointer-events: none;
|
|
484
|
+
}
|
|
485
|
+
|
|
486
|
+
/* Loading state */
|
|
487
|
+
.button--loading {
|
|
488
|
+
cursor: wait;
|
|
489
|
+
}
|
|
490
|
+
|
|
491
|
+
/* Content sections */
|
|
492
|
+
.button > * {
|
|
493
|
+
z-index: 1;
|
|
494
|
+
}
|
|
495
|
+
|
|
496
|
+
.button__icon {
|
|
497
|
+
margin-left: -4px;
|
|
498
|
+
display: flex;
|
|
499
|
+
align-items: center;
|
|
500
|
+
justify-content: center;
|
|
501
|
+
}
|
|
502
|
+
|
|
503
|
+
.button__label {
|
|
504
|
+
width: 100%;
|
|
505
|
+
display: flex;
|
|
506
|
+
align-items: center;
|
|
507
|
+
justify-content: center;
|
|
508
|
+
transition-property: opacity;
|
|
509
|
+
transition-duration: var(--svelte-ui-transition-duration);
|
|
510
|
+
}
|
|
511
|
+
|
|
512
|
+
.button__label--hidden {
|
|
513
|
+
opacity: 0;
|
|
514
|
+
}
|
|
515
|
+
|
|
516
|
+
.button__popup-icon {
|
|
517
|
+
margin-right: -4px;
|
|
518
|
+
display: flex;
|
|
519
|
+
align-items: center;
|
|
520
|
+
justify-content: center;
|
|
521
|
+
}
|
|
522
|
+
|
|
523
|
+
.button__loading {
|
|
524
|
+
position: absolute;
|
|
525
|
+
top: 50%;
|
|
526
|
+
left: 50%;
|
|
527
|
+
transform: translate(-50%, -50%);
|
|
528
|
+
display: flex;
|
|
529
|
+
align-items: center;
|
|
530
|
+
justify-content: center;
|
|
531
|
+
}
|
|
532
|
+
|
|
533
|
+
/* Size-specific adjustments */
|
|
534
|
+
.button--small .button__icon {
|
|
535
|
+
margin-left: -2px;
|
|
536
|
+
}
|
|
537
|
+
|
|
538
|
+
.button--small .button__popup-icon {
|
|
539
|
+
margin-right: -2px;
|
|
540
|
+
}
|
|
541
|
+
|
|
542
|
+
.button--large .button__icon {
|
|
543
|
+
margin-left: -6px;
|
|
544
|
+
}
|
|
545
|
+
|
|
546
|
+
.button--large .button__popup-icon {
|
|
547
|
+
margin-right: -6px;
|
|
548
|
+
}
|
|
549
|
+
|
|
550
|
+
/* Reduced motion */
|
|
551
|
+
.button--no-motion,
|
|
552
|
+
.button--no-motion:before,
|
|
553
|
+
.button--no-motion .button__label {
|
|
554
|
+
transition-duration: 0.01s;
|
|
555
|
+
}
|
|
556
|
+
|
|
557
|
+
/* Prefers reduced motion */
|
|
558
|
+
@media (prefers-reduced-motion: reduce) {
|
|
559
|
+
.button,
|
|
560
|
+
.button:before,
|
|
561
|
+
.button__label {
|
|
562
|
+
transition-duration: 0.01s;
|
|
563
|
+
}
|
|
564
|
+
}
|
|
565
|
+
|
|
566
|
+
/* Print styles */
|
|
567
|
+
@media print {
|
|
568
|
+
.button {
|
|
569
|
+
border: var(--svelte-ui-border-width) solid #000;
|
|
570
|
+
background: transparent !important;
|
|
571
|
+
color: #000 !important;
|
|
572
|
+
}
|
|
573
|
+
}
|
|
574
|
+
</style>
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import type { Snippet } from 'svelte';
|
|
2
|
+
import type { HTMLButtonAttributes } from 'svelte/elements';
|
|
3
|
+
import type { IconVariant, IconWeight, IconGrade, IconOpticalSize } from '../types/icon';
|
|
4
|
+
type $$ComponentProps = {
|
|
5
|
+
children: Snippet;
|
|
6
|
+
buttonAttributes?: HTMLButtonAttributes | undefined;
|
|
7
|
+
type?: HTMLButtonAttributes['type'];
|
|
8
|
+
tabindex?: number | null;
|
|
9
|
+
customStyle?: HTMLButtonAttributes['style'];
|
|
10
|
+
variant?: 'ghost' | 'filled' | 'outlined' | 'glass';
|
|
11
|
+
size?: 'small' | 'medium' | 'large';
|
|
12
|
+
color?: string;
|
|
13
|
+
fullWidth?: boolean;
|
|
14
|
+
minWidth?: string | number;
|
|
15
|
+
rounded?: boolean;
|
|
16
|
+
popup?: boolean;
|
|
17
|
+
icon?: string;
|
|
18
|
+
iconFilled?: boolean;
|
|
19
|
+
iconWeight?: IconWeight;
|
|
20
|
+
iconGrade?: IconGrade;
|
|
21
|
+
iconOpticalSize?: IconOpticalSize;
|
|
22
|
+
iconVariant?: IconVariant;
|
|
23
|
+
disabled?: boolean;
|
|
24
|
+
loading?: boolean;
|
|
25
|
+
reducedMotion?: boolean;
|
|
26
|
+
ariaLabel?: string;
|
|
27
|
+
ariaDescribedby?: string;
|
|
28
|
+
ariaExpanded?: boolean;
|
|
29
|
+
onfocus?: Function;
|
|
30
|
+
onblur?: Function;
|
|
31
|
+
onkeydown?: Function;
|
|
32
|
+
onkeyup?: Function;
|
|
33
|
+
onclick?: Function;
|
|
34
|
+
onmousedown?: Function;
|
|
35
|
+
onmouseup?: Function;
|
|
36
|
+
onmouseenter?: Function;
|
|
37
|
+
onmouseleave?: Function;
|
|
38
|
+
onmouseover?: Function;
|
|
39
|
+
onmouseout?: Function;
|
|
40
|
+
oncontextmenu?: Function;
|
|
41
|
+
onauxclick?: Function;
|
|
42
|
+
ontouchstart?: Function;
|
|
43
|
+
ontouchend?: Function;
|
|
44
|
+
ontouchmove?: Function;
|
|
45
|
+
ontouchcancel?: Function;
|
|
46
|
+
onpointerdown?: Function;
|
|
47
|
+
onpointerup?: Function;
|
|
48
|
+
onpointerenter?: Function;
|
|
49
|
+
onpointerleave?: Function;
|
|
50
|
+
onpointermove?: Function;
|
|
51
|
+
onpointercancel?: Function;
|
|
52
|
+
[key: string]: any;
|
|
53
|
+
};
|
|
54
|
+
declare const Button: import("svelte").Component<$$ComponentProps, {}, "">;
|
|
55
|
+
type Button = ReturnType<typeof Button>;
|
|
56
|
+
export default Button;
|