@14ch/svelte-ui 0.0.52 → 0.0.53
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/dist/components/Button.svelte +46 -13
- package/dist/components/Button.svelte.d.ts +3 -1
- package/dist/components/Dialog.svelte +2 -2
- package/dist/components/Fab.svelte +30 -12
- package/dist/components/Fab.svelte.d.ts +3 -1
- package/dist/index.d.ts +1 -1
- package/dist/types/propOptions.d.ts +5 -0
- package/package.json +1 -1
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
TouchHandler,
|
|
12
12
|
PointerHandler
|
|
13
13
|
} from '../types/callbackHandlers';
|
|
14
|
-
import type { ButtonVariant, ButtonSize } from '../types/propOptions';
|
|
14
|
+
import type { ButtonVariant, ButtonSize, IconPosition } from '../types/propOptions';
|
|
15
15
|
import Icon from './Icon.svelte';
|
|
16
16
|
import LoadingSpinner from './LoadingSpinner.svelte';
|
|
17
17
|
import { getStyleFromNumber } from '../utils/style';
|
|
@@ -46,6 +46,8 @@
|
|
|
46
46
|
// アイコン関連
|
|
47
47
|
/** Material Symbols icon name. */
|
|
48
48
|
icon?: string;
|
|
49
|
+
/** Icon position relative to the label. @default 'left' */
|
|
50
|
+
iconPosition?: IconPosition;
|
|
49
51
|
iconFilled?: boolean;
|
|
50
52
|
iconWeight?: IconWeight;
|
|
51
53
|
iconGrade?: IconGrade;
|
|
@@ -121,6 +123,7 @@
|
|
|
121
123
|
|
|
122
124
|
// アイコン関連
|
|
123
125
|
icon = '',
|
|
126
|
+
iconPosition = 'left',
|
|
124
127
|
iconFilled = false,
|
|
125
128
|
iconWeight = 300,
|
|
126
129
|
iconGrade = 0,
|
|
@@ -368,19 +371,23 @@
|
|
|
368
371
|
data-testid="button"
|
|
369
372
|
{...restProps}
|
|
370
373
|
>
|
|
374
|
+
{#snippet iconContent()}
|
|
375
|
+
<Icon
|
|
376
|
+
filled={iconFilled}
|
|
377
|
+
weight={iconWeight}
|
|
378
|
+
grade={iconGrade}
|
|
379
|
+
opticalSize={iconOpticalSize}
|
|
380
|
+
variant={iconVariant}>{icon}</Icon
|
|
381
|
+
>
|
|
382
|
+
{/snippet}
|
|
383
|
+
|
|
371
384
|
{#if loading}
|
|
372
385
|
<div class="button__loading">
|
|
373
386
|
<LoadingSpinner size={18} strokeWidth={2} color="currentColor" />
|
|
374
387
|
</div>
|
|
375
|
-
{:else if icon}
|
|
376
|
-
<div class="button__icon">
|
|
377
|
-
|
|
378
|
-
filled={iconFilled}
|
|
379
|
-
weight={iconWeight}
|
|
380
|
-
grade={iconGrade}
|
|
381
|
-
opticalSize={iconOpticalSize}
|
|
382
|
-
variant={iconVariant}>{icon}</Icon
|
|
383
|
-
>
|
|
388
|
+
{:else if icon && iconPosition === 'left'}
|
|
389
|
+
<div class="button__icon button__icon--left">
|
|
390
|
+
{@render iconContent()}
|
|
384
391
|
</div>
|
|
385
392
|
{/if}
|
|
386
393
|
|
|
@@ -388,6 +395,12 @@
|
|
|
388
395
|
{@render children()}
|
|
389
396
|
</div>
|
|
390
397
|
|
|
398
|
+
{#if icon && iconPosition === 'right' && !loading}
|
|
399
|
+
<div class="button__icon button__icon--right">
|
|
400
|
+
{@render iconContent()}
|
|
401
|
+
</div>
|
|
402
|
+
{/if}
|
|
403
|
+
|
|
391
404
|
{#if popup && !loading}
|
|
392
405
|
<div class="button__popup-icon">
|
|
393
406
|
<Icon>arrow_drop_down</Icon>
|
|
@@ -519,12 +532,24 @@
|
|
|
519
532
|
}
|
|
520
533
|
|
|
521
534
|
.button__icon {
|
|
522
|
-
margin: -12px 0
|
|
535
|
+
margin: -12px 0;
|
|
523
536
|
display: flex;
|
|
524
537
|
align-items: center;
|
|
525
538
|
justify-content: center;
|
|
526
539
|
}
|
|
527
540
|
|
|
541
|
+
.button__icon--left {
|
|
542
|
+
margin-left: -4px;
|
|
543
|
+
}
|
|
544
|
+
|
|
545
|
+
.button__icon--right {
|
|
546
|
+
margin-right: -4px;
|
|
547
|
+
}
|
|
548
|
+
|
|
549
|
+
.button--align-left .button__icon--right {
|
|
550
|
+
margin-left: auto;
|
|
551
|
+
}
|
|
552
|
+
|
|
528
553
|
.button__label {
|
|
529
554
|
display: block;
|
|
530
555
|
width: auto;
|
|
@@ -562,10 +587,14 @@
|
|
|
562
587
|
}
|
|
563
588
|
|
|
564
589
|
/* Size-specific adjustments */
|
|
565
|
-
.button--small .button__icon {
|
|
590
|
+
.button--small .button__icon--left {
|
|
566
591
|
margin-left: -2px;
|
|
567
592
|
}
|
|
568
593
|
|
|
594
|
+
.button--small .button__icon--right {
|
|
595
|
+
margin-right: -2px;
|
|
596
|
+
}
|
|
597
|
+
|
|
569
598
|
.button--small .button__popup-icon {
|
|
570
599
|
margin-right: -2px;
|
|
571
600
|
}
|
|
@@ -575,10 +604,14 @@
|
|
|
575
604
|
margin-right: -2px;
|
|
576
605
|
}
|
|
577
606
|
|
|
578
|
-
.button--large .button__icon {
|
|
607
|
+
.button--large .button__icon--left {
|
|
579
608
|
margin-left: -6px;
|
|
580
609
|
}
|
|
581
610
|
|
|
611
|
+
.button--large .button__icon--right {
|
|
612
|
+
margin-right: -6px;
|
|
613
|
+
}
|
|
614
|
+
|
|
582
615
|
.button--large .button__popup-icon {
|
|
583
616
|
margin-right: -6px;
|
|
584
617
|
}
|
|
@@ -2,7 +2,7 @@ import type { Snippet } from 'svelte';
|
|
|
2
2
|
import type { HTMLButtonAttributes } from 'svelte/elements';
|
|
3
3
|
import type { IconVariant, IconWeight, IconGrade, IconOpticalSize } from '../types/icon';
|
|
4
4
|
import type { FocusHandler, KeyboardHandler, MouseHandler, TouchHandler, PointerHandler } from '../types/callbackHandlers';
|
|
5
|
-
import type { ButtonVariant, ButtonSize } from '../types/propOptions';
|
|
5
|
+
import type { ButtonVariant, ButtonSize, IconPosition } from '../types/propOptions';
|
|
6
6
|
export type ButtonProps = {
|
|
7
7
|
children: Snippet;
|
|
8
8
|
/** @default 'button' */
|
|
@@ -23,6 +23,8 @@ export type ButtonProps = {
|
|
|
23
23
|
popup?: boolean;
|
|
24
24
|
/** Material Symbols icon name. */
|
|
25
25
|
icon?: string;
|
|
26
|
+
/** Icon position relative to the label. @default 'left' */
|
|
27
|
+
iconPosition?: IconPosition;
|
|
26
28
|
iconFilled?: boolean;
|
|
27
29
|
iconWeight?: IconWeight;
|
|
28
30
|
iconGrade?: IconGrade;
|
|
@@ -238,7 +238,7 @@
|
|
|
238
238
|
|
|
239
239
|
.dialog--scrollable .dialog__header {
|
|
240
240
|
margin-bottom: 0;
|
|
241
|
-
border-bottom: solid
|
|
241
|
+
border-bottom: solid 1px var(--svelte-ui-border-color);
|
|
242
242
|
}
|
|
243
243
|
|
|
244
244
|
.dialog--scrollable .dialog__body {
|
|
@@ -248,5 +248,5 @@
|
|
|
248
248
|
}
|
|
249
249
|
|
|
250
250
|
.dialog--scrollable .dialog__footer {
|
|
251
|
-
border-top: solid
|
|
251
|
+
border-top: solid 1px var(--svelte-ui-border-color);
|
|
252
252
|
}</style>
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
TouchHandler,
|
|
12
12
|
PointerHandler
|
|
13
13
|
} from '../types/callbackHandlers';
|
|
14
|
-
import type { ButtonVariant, FabPosition } from '../types/propOptions';
|
|
14
|
+
import type { ButtonVariant, FabPosition, IconPosition } from '../types/propOptions';
|
|
15
15
|
import Icon from './Icon.svelte';
|
|
16
16
|
import LoadingSpinner from './LoadingSpinner.svelte';
|
|
17
17
|
import { getStyleFromNumber } from '../utils/style';
|
|
@@ -29,6 +29,8 @@
|
|
|
29
29
|
loading?: boolean;
|
|
30
30
|
/** Material Symbols icon name. */
|
|
31
31
|
icon?: string;
|
|
32
|
+
/** Icon position relative to the label. @default 'left' */
|
|
33
|
+
iconPosition?: IconPosition;
|
|
32
34
|
iconFilled?: boolean;
|
|
33
35
|
iconWeight?: IconWeight;
|
|
34
36
|
iconGrade?: IconGrade;
|
|
@@ -106,6 +108,7 @@
|
|
|
106
108
|
|
|
107
109
|
// アイコン関連
|
|
108
110
|
icon = '',
|
|
111
|
+
iconPosition = 'left',
|
|
109
112
|
iconFilled = false,
|
|
110
113
|
iconWeight = 300,
|
|
111
114
|
iconGrade = 0,
|
|
@@ -348,20 +351,24 @@
|
|
|
348
351
|
aria-busy={loading ? 'true' : undefined}
|
|
349
352
|
data-testid="fab"
|
|
350
353
|
>
|
|
354
|
+
{#snippet iconContent()}
|
|
355
|
+
<Icon
|
|
356
|
+
filled={iconFilled}
|
|
357
|
+
weight={iconWeight}
|
|
358
|
+
grade={iconGrade}
|
|
359
|
+
opticalSize={iconOpticalSize}
|
|
360
|
+
variant={iconVariant}
|
|
361
|
+
size={24}>{icon}</Icon
|
|
362
|
+
>
|
|
363
|
+
{/snippet}
|
|
364
|
+
|
|
351
365
|
{#if loading}
|
|
352
366
|
<div class="fab__loading">
|
|
353
367
|
<LoadingSpinner size={24} strokeWidth={2} color="currentColor" />
|
|
354
368
|
</div>
|
|
355
|
-
{:else if icon}
|
|
356
|
-
<div class="fab__icon">
|
|
357
|
-
|
|
358
|
-
filled={iconFilled}
|
|
359
|
-
weight={iconWeight}
|
|
360
|
-
grade={iconGrade}
|
|
361
|
-
opticalSize={iconOpticalSize}
|
|
362
|
-
variant={iconVariant}
|
|
363
|
-
size={24}>{icon}</Icon
|
|
364
|
-
>
|
|
369
|
+
{:else if icon && iconPosition === 'left'}
|
|
370
|
+
<div class="fab__icon fab__icon--left">
|
|
371
|
+
{@render iconContent()}
|
|
365
372
|
</div>
|
|
366
373
|
{/if}
|
|
367
374
|
|
|
@@ -370,6 +377,12 @@
|
|
|
370
377
|
{@render children()}
|
|
371
378
|
</div>
|
|
372
379
|
{/if}
|
|
380
|
+
|
|
381
|
+
{#if icon && iconPosition === 'right' && !loading}
|
|
382
|
+
<div class="fab__icon fab__icon--right">
|
|
383
|
+
{@render iconContent()}
|
|
384
|
+
</div>
|
|
385
|
+
{/if}
|
|
373
386
|
</button>
|
|
374
387
|
|
|
375
388
|
<style>.fab {
|
|
@@ -470,12 +483,17 @@
|
|
|
470
483
|
transition-duration: 0.01s;
|
|
471
484
|
}
|
|
472
485
|
.fab .fab__icon {
|
|
473
|
-
margin: 0 8px 0 -8px;
|
|
474
486
|
user-select: none;
|
|
475
487
|
display: flex;
|
|
476
488
|
align-items: center;
|
|
477
489
|
justify-content: center;
|
|
478
490
|
}
|
|
491
|
+
.fab .fab__icon--left {
|
|
492
|
+
margin: 0 8px 0 -8px;
|
|
493
|
+
}
|
|
494
|
+
.fab .fab__icon--right {
|
|
495
|
+
margin: 0 -8px 0 8px;
|
|
496
|
+
}
|
|
479
497
|
.fab .fab__loading {
|
|
480
498
|
position: absolute;
|
|
481
499
|
top: 50%;
|
|
@@ -2,7 +2,7 @@ import type { Snippet } from 'svelte';
|
|
|
2
2
|
import type { HTMLButtonAttributes } from 'svelte/elements';
|
|
3
3
|
import type { IconVariant, IconWeight, IconGrade, IconOpticalSize } from '../types/icon';
|
|
4
4
|
import type { FocusHandler, KeyboardHandler, MouseHandler, TouchHandler, PointerHandler } from '../types/callbackHandlers';
|
|
5
|
-
import type { ButtonVariant, FabPosition } from '../types/propOptions';
|
|
5
|
+
import type { ButtonVariant, FabPosition, IconPosition } from '../types/propOptions';
|
|
6
6
|
export type FabProps = {
|
|
7
7
|
children?: Snippet;
|
|
8
8
|
/** @default 'button' */
|
|
@@ -13,6 +13,8 @@ export type FabProps = {
|
|
|
13
13
|
loading?: boolean;
|
|
14
14
|
/** Material Symbols icon name. */
|
|
15
15
|
icon?: string;
|
|
16
|
+
/** Icon position relative to the label. @default 'left' */
|
|
17
|
+
iconPosition?: IconPosition;
|
|
16
18
|
iconFilled?: boolean;
|
|
17
19
|
iconWeight?: IconWeight;
|
|
18
20
|
iconGrade?: IconGrade;
|
package/dist/index.d.ts
CHANGED
|
@@ -85,7 +85,7 @@ export type { NavProps } from './components/Nav.svelte';
|
|
|
85
85
|
export type { NavItemProps, NavItemSelectedVariant } from './components/NavItem.svelte';
|
|
86
86
|
export type { TabProps } from './components/Tab.svelte';
|
|
87
87
|
export type { TextareaProps } from './components/Textarea.svelte';
|
|
88
|
-
export type { PopupPosition, SnackbarPosition, FabPosition, ButtonVariant, ButtonSize, ComponentSize, SnackbarType, SnackbarVariant, BadgeVariant, DatepickerMode, FocusStyle, NavVariant, ChildrenVariant, StepNavOrientation } from './types/propOptions';
|
|
88
|
+
export type { PopupPosition, SnackbarPosition, FabPosition, ButtonVariant, ButtonSize, IconPosition, ComponentSize, SnackbarType, SnackbarVariant, BadgeVariant, DatepickerMode, FocusStyle, NavVariant, ChildrenVariant, StepNavOrientation } from './types/propOptions';
|
|
89
89
|
export type { MenuItem } from './types/menuItem';
|
|
90
90
|
export type { StepItem } from './types/stepItem';
|
|
91
91
|
export type { SegmentedControlItem } from './types/segmentedControlItem';
|
|
@@ -22,6 +22,11 @@ export type FabPosition = 'left' | 'center' | 'right';
|
|
|
22
22
|
* Used by Button, IconButton, Fab components
|
|
23
23
|
*/
|
|
24
24
|
export type ButtonVariant = 'ghost' | 'filled' | 'outlined' | 'glass';
|
|
25
|
+
/**
|
|
26
|
+
* Icon position type (left/right)
|
|
27
|
+
* Used by Button, Fab components
|
|
28
|
+
*/
|
|
29
|
+
export type IconPosition = 'left' | 'right';
|
|
25
30
|
/**
|
|
26
31
|
* Common component size type
|
|
27
32
|
* Used by Button, Checkbox, CheckboxGroup, Radio, RadioGroup, SegmentedControl, Switch
|