@reshape-biotech/design-system 0.0.52 → 0.0.54
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/activity/Activity.svelte +15 -5
- package/dist/components/activity/Activity.svelte.d.ts +1 -1
- package/dist/components/checkbox/Checkbox.stories.svelte +30 -0
- package/dist/components/checkbox/Checkbox.stories.svelte.d.ts +19 -0
- package/dist/components/checkbox/Checkbox.svelte +24 -0
- package/dist/components/checkbox/Checkbox.svelte.d.ts +7 -0
- package/dist/components/checkbox/index.d.ts +1 -0
- package/dist/components/checkbox/index.js +1 -0
- package/dist/components/collapsible/components/collapsible-trigger.svelte +1 -1
- package/dist/components/combobox/components/combobox-add.svelte +2 -1
- package/dist/components/combobox/components/combobox-content.svelte +4 -0
- package/dist/components/combobox/types.d.ts +2 -0
- package/dist/components/icons/index.d.ts +1 -1
- package/dist/components/icons/index.js +2 -0
- package/dist/components/tag/Tag.stories.svelte +31 -0
- package/dist/components/tag/Tag.svelte +34 -3
- package/dist/components/tag/Tag.svelte.d.ts +1 -1
- package/dist/components/toggle-icon-button/ToggleIconButton.stories.svelte +173 -0
- package/dist/components/toggle-icon-button/ToggleIconButton.stories.svelte.d.ts +19 -0
- package/dist/components/toggle-icon-button/ToggleIconButton.svelte +117 -0
- package/dist/components/toggle-icon-button/ToggleIconButton.svelte.d.ts +15 -0
- package/dist/components/toggle-icon-button/index.d.ts +3 -0
- package/dist/components/toggle-icon-button/index.js +3 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +2 -0
- package/dist/tailwind-safelist.js +2 -0
- package/package.json +1 -1
|
@@ -2,7 +2,16 @@
|
|
|
2
2
|
import { Icon, type IconName } from '../icons';
|
|
3
3
|
import { DateTime } from 'luxon';
|
|
4
4
|
|
|
5
|
-
type ActivityIcon =
|
|
5
|
+
type ActivityIcon =
|
|
6
|
+
| 'add'
|
|
7
|
+
| 'capture'
|
|
8
|
+
| 'delete'
|
|
9
|
+
| 'edit'
|
|
10
|
+
| 'failed'
|
|
11
|
+
| 'pause'
|
|
12
|
+
| 'start'
|
|
13
|
+
| 'stop'
|
|
14
|
+
| 'success';
|
|
6
15
|
|
|
7
16
|
type Activity = {
|
|
8
17
|
activity_type?: string;
|
|
@@ -22,13 +31,14 @@
|
|
|
22
31
|
|
|
23
32
|
const ACTIVITY_ICONS: Record<ActivityIcon, IconName> = {
|
|
24
33
|
add: 'Plus',
|
|
34
|
+
capture: 'Aperture',
|
|
35
|
+
delete: 'Trash',
|
|
25
36
|
edit: 'Pencil',
|
|
26
|
-
|
|
27
|
-
start: 'Play',
|
|
37
|
+
failed: 'WarningCircle',
|
|
28
38
|
pause: 'Pause',
|
|
39
|
+
start: 'Play',
|
|
29
40
|
stop: 'Stop',
|
|
30
|
-
|
|
31
|
-
failed: 'WarningCircle'
|
|
41
|
+
success: 'CheckFat'
|
|
32
42
|
};
|
|
33
43
|
|
|
34
44
|
function formatDateTime(timestamp: string): string {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
type ActivityIcon = 'add' | '
|
|
1
|
+
type ActivityIcon = 'add' | 'capture' | 'delete' | 'edit' | 'failed' | 'pause' | 'start' | 'stop' | 'success';
|
|
2
2
|
type Activity = {
|
|
3
3
|
activity_type?: string;
|
|
4
4
|
icon: ActivityIcon;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
<script module lang="ts">
|
|
2
|
+
import Checkbox from './Checkbox.svelte';
|
|
3
|
+
import { defineMeta } from '@storybook/addon-svelte-csf';
|
|
4
|
+
|
|
5
|
+
const { Story } = defineMeta({
|
|
6
|
+
component: Checkbox,
|
|
7
|
+
title: 'Design System/Checkbox',
|
|
8
|
+
tags: ['autodocs']
|
|
9
|
+
});
|
|
10
|
+
|
|
11
|
+
let checked = $state<boolean>(false);
|
|
12
|
+
</script>
|
|
13
|
+
|
|
14
|
+
<Story name="Default">
|
|
15
|
+
<div class="p-4">
|
|
16
|
+
<Checkbox bind:checked />
|
|
17
|
+
</div>
|
|
18
|
+
</Story>
|
|
19
|
+
|
|
20
|
+
<Story name="Checked">
|
|
21
|
+
<div class="p-4">
|
|
22
|
+
<Checkbox checked={true} />
|
|
23
|
+
</div>
|
|
24
|
+
</Story>
|
|
25
|
+
|
|
26
|
+
<Story name="Unchecked">
|
|
27
|
+
<div class="p-4">
|
|
28
|
+
<Checkbox checked={false} />
|
|
29
|
+
</div>
|
|
30
|
+
</Story>
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import Checkbox from './Checkbox.svelte';
|
|
2
|
+
interface $$__sveltets_2_IsomorphicComponent<Props extends Record<string, any> = any, Events extends Record<string, any> = any, Slots extends Record<string, any> = any, Exports = {}, Bindings = string> {
|
|
3
|
+
new (options: import('svelte').ComponentConstructorOptions<Props>): import('svelte').SvelteComponent<Props, Events, Slots> & {
|
|
4
|
+
$$bindings?: Bindings;
|
|
5
|
+
} & Exports;
|
|
6
|
+
(internal: unknown, props: {
|
|
7
|
+
$$events?: Events;
|
|
8
|
+
$$slots?: Slots;
|
|
9
|
+
}): Exports & {
|
|
10
|
+
$set?: any;
|
|
11
|
+
$on?: any;
|
|
12
|
+
};
|
|
13
|
+
z_$$bindings?: Bindings;
|
|
14
|
+
}
|
|
15
|
+
declare const Checkbox: $$__sveltets_2_IsomorphicComponent<Record<string, never>, {
|
|
16
|
+
[evt: string]: CustomEvent<any>;
|
|
17
|
+
}, {}, {}, string>;
|
|
18
|
+
type Checkbox = InstanceType<typeof Checkbox>;
|
|
19
|
+
export default Checkbox;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { Checkbox } from 'bits-ui';
|
|
3
|
+
import { Icon } from '../icons';
|
|
4
|
+
|
|
5
|
+
type Props = {
|
|
6
|
+
checked: boolean;
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
let { checked = $bindable(false) }: Props = $props();
|
|
10
|
+
</script>
|
|
11
|
+
|
|
12
|
+
<Checkbox.Root bind:checked>
|
|
13
|
+
{#snippet children({ checked })}
|
|
14
|
+
<div
|
|
15
|
+
class={`flex items-center justify-center rounded border border-static ${checked ? 'bg-dark-accent-inverse-hover' : ''}`}
|
|
16
|
+
>
|
|
17
|
+
{#if checked}
|
|
18
|
+
<Icon iconName="Check" class="text-primary-inverse" />
|
|
19
|
+
{:else}
|
|
20
|
+
<div class="h-4 w-4"></div>
|
|
21
|
+
{/if}
|
|
22
|
+
</div>
|
|
23
|
+
{/snippet}
|
|
24
|
+
</Checkbox.Root>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as Checkbox } from './Checkbox.svelte';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as Checkbox } from './Checkbox.svelte';
|
|
@@ -9,12 +9,13 @@
|
|
|
9
9
|
</script>
|
|
10
10
|
|
|
11
11
|
<button {...props}>
|
|
12
|
-
<Icon iconName="Plus" />
|
|
12
|
+
<Icon iconName="Plus" class="text-icon-secondary" />
|
|
13
13
|
{@render children()}
|
|
14
14
|
</button>
|
|
15
15
|
|
|
16
16
|
<style>
|
|
17
17
|
button {
|
|
18
|
+
margin-left: 0.5rem;
|
|
18
19
|
display: flex;
|
|
19
20
|
height: 2.5rem;
|
|
20
21
|
flex-direction: row;
|
|
@@ -8,12 +8,15 @@
|
|
|
8
8
|
class: className,
|
|
9
9
|
showScroll = true,
|
|
10
10
|
portalled = true,
|
|
11
|
+
header,
|
|
12
|
+
footer,
|
|
11
13
|
...props
|
|
12
14
|
}: ComboboxContentProps = $props();
|
|
13
15
|
</script>
|
|
14
16
|
|
|
15
17
|
{#snippet content()}
|
|
16
18
|
<Combobox.Content {...props} class={className}>
|
|
19
|
+
{@render header?.()}
|
|
17
20
|
{#if showScroll}
|
|
18
21
|
<Combobox.ScrollUpButton class="flex justify-center">
|
|
19
22
|
<Icon iconName="CaretUp" />
|
|
@@ -27,6 +30,7 @@
|
|
|
27
30
|
{:else}
|
|
28
31
|
{@render children()}
|
|
29
32
|
{/if}
|
|
33
|
+
{@render footer?.()}
|
|
30
34
|
</Combobox.Content>
|
|
31
35
|
{/snippet}
|
|
32
36
|
|
|
@@ -2,7 +2,7 @@ import type { IconComponentProps } from 'phosphor-svelte';
|
|
|
2
2
|
import type { Component } from 'svelte';
|
|
3
3
|
import type { textColor } from './../../tokens';
|
|
4
4
|
export type PhosphorIconProps = Component<IconComponentProps, object, ''>;
|
|
5
|
-
export type IconName = 'ArrowFatLineRight' | 'ArrowRight' | 'ArrowUpRight' | 'Barcode' | 'Bell' | 'BookOpen' | 'BookOpenText' | 'BowlingBall' | 'Calendar' | 'CalendarBlank' | 'CameraSlash' | 'CaretDown' | 'CaretLeft' | 'CaretRight' | 'CaretUp' | 'CaretUpDown' | 'ChatTeardropDots' | 'Check' | 'CheckCircle' | 'CheckFat' | 'Circle' | 'CircleDashed' | 'CircleHalf' | 'CirclesFour' | 'CirclesThreePlus' | 'Clock' | 'ClockCountdown' | 'Copy' | 'Crop' | 'Cube' | 'Database' | 'DotsThree' | 'DotsThreeOutlineVertical' | 'DownloadSimple' | 'Drop' | 'EnvelopeSimple' | 'Eye' | 'Eyedropper' | 'FileCsv' | 'Flag' | 'Flask' | 'Folder' | 'FolderDashed' | 'FolderSimplePlus' | 'FunnelSimple' | 'Gear' | 'GlobeSimple' | 'GlobeSimpleX' | 'GridFour' | 'Hash' | 'House' | 'ImageSquare' | 'ImagesSquare' | 'Info' | 'Lock' | 'LineSegments' | 'List' | 'MagnifyingGlass' | 'MegaphoneSimple' | 'Moon' | 'Pause' | 'Pencil' | 'PencilSimple' | 'Percent' | 'Phone' | 'Plant' | 'Play' | 'Plus' | 'PlusMinus' | 'Question' | 'RadioButton' | 'SealQuestion' | 'SelectionAll' | 'Share' | 'SidebarSimple' | 'SkipBack' | 'SkipForward' | 'SortAscending' | 'Sparkle' | 'SpinnerGap' | 'SquaresFour' | 'Star' | 'Stop' | 'StopCircle' | 'Sun' | 'Table' | 'Tag' | 'TestTube' | 'Trash' | 'TrashSimple' | 'UserCircle' | 'UserPlus' | 'Video' | 'Warning' | 'WarningCircle' | 'WifiSlash' | 'X';
|
|
5
|
+
export type IconName = 'Aperture' | 'ArrowFatLineRight' | 'ArrowRight' | 'ArrowUpRight' | 'Barcode' | 'Bell' | 'BookOpen' | 'BookOpenText' | 'BowlingBall' | 'Calendar' | 'CalendarBlank' | 'CameraSlash' | 'CaretDown' | 'CaretLeft' | 'CaretRight' | 'CaretUp' | 'CaretUpDown' | 'ChatTeardropDots' | 'Check' | 'CheckCircle' | 'CheckFat' | 'Circle' | 'CircleDashed' | 'CircleHalf' | 'CirclesFour' | 'CirclesThreePlus' | 'Clock' | 'ClockCountdown' | 'Copy' | 'Crop' | 'Cube' | 'Database' | 'DotsThree' | 'DotsThreeOutlineVertical' | 'DownloadSimple' | 'Drop' | 'EnvelopeSimple' | 'Eye' | 'Eyedropper' | 'FileCsv' | 'Flag' | 'Flask' | 'Folder' | 'FolderDashed' | 'FolderSimplePlus' | 'FunnelSimple' | 'Gear' | 'GlobeSimple' | 'GlobeSimpleX' | 'GridFour' | 'Hash' | 'House' | 'ImageSquare' | 'ImagesSquare' | 'Info' | 'Lock' | 'LineSegments' | 'List' | 'MagnifyingGlass' | 'MegaphoneSimple' | 'Moon' | 'Pause' | 'Pencil' | 'PencilSimple' | 'Percent' | 'Phone' | 'Plant' | 'Play' | 'Plus' | 'PlusMinus' | 'Question' | 'RadioButton' | 'SealQuestion' | 'SelectionAll' | 'Share' | 'SidebarSimple' | 'SkipBack' | 'SkipForward' | 'SortAscending' | 'Sparkle' | 'SpinnerGap' | 'SquaresFour' | 'Star' | 'Stop' | 'StopCircle' | 'Sun' | 'Table' | 'Tag' | 'TestTube' | 'Trash' | 'TrashSimple' | 'UserCircle' | 'UserPlus' | 'Video' | 'Warning' | 'WarningCircle' | 'WifiSlash' | 'X';
|
|
6
6
|
export declare const iconMap: Record<IconName, PhosphorIconProps>;
|
|
7
7
|
export declare function renderIcon(iconName: keyof typeof iconMap): PhosphorIconProps;
|
|
8
8
|
export type IconColor = keyof typeof textColor;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import Aperture from 'phosphor-svelte/lib/Aperture';
|
|
1
2
|
import ArrowFatLineRight from 'phosphor-svelte/lib/ArrowFatLineRight';
|
|
2
3
|
import ArrowRight from 'phosphor-svelte/lib/ArrowRight';
|
|
3
4
|
import ArrowUpRight from 'phosphor-svelte/lib/ArrowUpRight';
|
|
@@ -96,6 +97,7 @@ import WarningCircle from 'phosphor-svelte/lib/WarningCircle';
|
|
|
96
97
|
import WifiSlash from 'phosphor-svelte/lib/WifiSlash';
|
|
97
98
|
import X from 'phosphor-svelte/lib/X';
|
|
98
99
|
export const iconMap = {
|
|
100
|
+
Aperture,
|
|
99
101
|
ArrowFatLineRight,
|
|
100
102
|
ArrowRight,
|
|
101
103
|
ArrowUpRight,
|
|
@@ -8,6 +8,21 @@
|
|
|
8
8
|
title: 'Design System/Tag',
|
|
9
9
|
tags: ['autodocs']
|
|
10
10
|
});
|
|
11
|
+
|
|
12
|
+
const variants = [
|
|
13
|
+
'default',
|
|
14
|
+
'transparent',
|
|
15
|
+
'default-inverse',
|
|
16
|
+
'orange',
|
|
17
|
+
'sky',
|
|
18
|
+
'pink',
|
|
19
|
+
'lime',
|
|
20
|
+
'lilac',
|
|
21
|
+
'pear',
|
|
22
|
+
'blue',
|
|
23
|
+
'accent',
|
|
24
|
+
'warning'
|
|
25
|
+
];
|
|
11
26
|
</script>
|
|
12
27
|
|
|
13
28
|
<Story name="Default">
|
|
@@ -49,3 +64,19 @@
|
|
|
49
64
|
<Tag variant="transparent" onclick={() => {}}>Transparent</Tag>
|
|
50
65
|
</div>
|
|
51
66
|
</Story>
|
|
67
|
+
|
|
68
|
+
<Story name="Variants">
|
|
69
|
+
{#each variants as variant}
|
|
70
|
+
<div class="w-fit">
|
|
71
|
+
<Tag variant={variant as any}>{variant}</Tag>
|
|
72
|
+
</div>
|
|
73
|
+
{/each}
|
|
74
|
+
</Story>
|
|
75
|
+
|
|
76
|
+
<Story name="Button variants">
|
|
77
|
+
{#each variants as variant}
|
|
78
|
+
<div class="w-fit">
|
|
79
|
+
<Tag variant={variant as any} onclick={() => {}}>Click me</Tag>
|
|
80
|
+
</div>
|
|
81
|
+
{/each}
|
|
82
|
+
</Story>
|
|
@@ -4,7 +4,20 @@
|
|
|
4
4
|
|
|
5
5
|
interface Props {
|
|
6
6
|
children: Snippet;
|
|
7
|
-
variant?:
|
|
7
|
+
variant?:
|
|
8
|
+
| 'default'
|
|
9
|
+
| 'outline'
|
|
10
|
+
| 'transparent'
|
|
11
|
+
| 'default-inverse'
|
|
12
|
+
| 'orange'
|
|
13
|
+
| 'sky'
|
|
14
|
+
| 'pink'
|
|
15
|
+
| 'lime'
|
|
16
|
+
| 'lilac'
|
|
17
|
+
| 'pear'
|
|
18
|
+
| 'blue'
|
|
19
|
+
| 'accent'
|
|
20
|
+
| 'warning';
|
|
8
21
|
size?: 'sm' | 'md';
|
|
9
22
|
tooltip?: string;
|
|
10
23
|
onclick?: (event: MouseEvent) => void;
|
|
@@ -30,14 +43,32 @@
|
|
|
30
43
|
default: 'bg-neutral text-primary',
|
|
31
44
|
outline: 'bg-transparent text-secondary border',
|
|
32
45
|
transparent: 'bg-transparent text-secondary',
|
|
33
|
-
'default-inverse': 'bg-base-inverse text-secondary-inverse'
|
|
46
|
+
'default-inverse': 'bg-base-inverse text-secondary-inverse',
|
|
47
|
+
orange: 'bg-orange text-orange',
|
|
48
|
+
sky: 'bg-sky text-sky',
|
|
49
|
+
pink: 'bg-pink text-pink',
|
|
50
|
+
lime: 'bg-lime text-lime',
|
|
51
|
+
lilac: 'bg-lilac text-lilac',
|
|
52
|
+
pear: 'bg-pear text-pear',
|
|
53
|
+
blue: 'bg-blue text-blue',
|
|
54
|
+
accent: 'bg-accent text-accent',
|
|
55
|
+
warning: 'bg-warning text-warning'
|
|
34
56
|
};
|
|
35
57
|
|
|
36
58
|
const buttonClassVariants = {
|
|
37
59
|
default: 'hover:bg-neutral-hover',
|
|
38
60
|
outline: 'hover:bg-neutral hover:text-primary',
|
|
39
61
|
transparent: 'hover:bg-neutral hover:text-primary',
|
|
40
|
-
'default-inverse': 'hover:bg-base-inverse hover:text-secondary-inverse'
|
|
62
|
+
'default-inverse': 'hover:bg-base-inverse hover:text-secondary-inverse',
|
|
63
|
+
orange: 'hover:bg-orange-hover hover:text-orange-hover',
|
|
64
|
+
sky: 'hover:bg-sky-hover hover:text-sky-hover',
|
|
65
|
+
pink: 'hover:bg-pink-hover hover:text-pink-hover',
|
|
66
|
+
lime: 'hover:bg-lime-hover hover:text-lime-hover',
|
|
67
|
+
lilac: 'hover:bg-lilac-hover hover:text-lilac-hover',
|
|
68
|
+
pear: 'hover:bg-pear-hover hover:text-pear-hover',
|
|
69
|
+
blue: 'hover:bg-blue-hover hover:text-blue-hover',
|
|
70
|
+
accent: 'hover:bg-accent-hover hover:text-accent-hover',
|
|
71
|
+
warning: 'hover:bg-warning-hover hover:text-warning-hover'
|
|
41
72
|
};
|
|
42
73
|
|
|
43
74
|
let variantClassName = $derived(variants[variant]);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { Snippet } from 'svelte';
|
|
2
2
|
interface Props {
|
|
3
3
|
children: Snippet;
|
|
4
|
-
variant?: 'default' | 'outline' | 'transparent' | 'default-inverse';
|
|
4
|
+
variant?: 'default' | 'outline' | 'transparent' | 'default-inverse' | 'orange' | 'sky' | 'pink' | 'lime' | 'lilac' | 'pear' | 'blue' | 'accent' | 'warning';
|
|
5
5
|
size?: 'sm' | 'md';
|
|
6
6
|
tooltip?: string;
|
|
7
7
|
onclick?: (event: MouseEvent) => void;
|
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
<script module lang="ts">
|
|
2
|
+
import { defineMeta } from '@storybook/addon-svelte-csf';
|
|
3
|
+
import ToggleIconButton from './ToggleIconButton.svelte';
|
|
4
|
+
import { Icon } from '../icons';
|
|
5
|
+
|
|
6
|
+
const { Story } = defineMeta({
|
|
7
|
+
component: ToggleIconButton,
|
|
8
|
+
title: 'Design System/ToggleIconButton',
|
|
9
|
+
tags: ['autodocs']
|
|
10
|
+
});
|
|
11
|
+
</script>
|
|
12
|
+
|
|
13
|
+
<Story name="States">
|
|
14
|
+
<div class="flex flex-col gap-4">
|
|
15
|
+
<div class="bg-neutral-dark flex gap-4 p-4">
|
|
16
|
+
<div class="flex flex-col items-center gap-2">
|
|
17
|
+
<p class="text-sm">Normal</p>
|
|
18
|
+
<ToggleIconButton variant="primary-inverse">
|
|
19
|
+
<Icon iconName="DownloadSimple" />
|
|
20
|
+
</ToggleIconButton>
|
|
21
|
+
</div>
|
|
22
|
+
<div class="flex flex-col items-center gap-2">
|
|
23
|
+
<p class="text-sm">Active</p>
|
|
24
|
+
<ToggleIconButton variant="primary-inverse" isActive={true}>
|
|
25
|
+
<Icon iconName="DownloadSimple" />
|
|
26
|
+
</ToggleIconButton>
|
|
27
|
+
</div>
|
|
28
|
+
</div>
|
|
29
|
+
</div>
|
|
30
|
+
</Story>
|
|
31
|
+
|
|
32
|
+
<Story name="Variants">
|
|
33
|
+
<div class="flex flex-col gap-4">
|
|
34
|
+
<div class="flex gap-8">
|
|
35
|
+
<div class="flex flex-col gap-2">
|
|
36
|
+
<p class="text-sm">Primary Inverse</p>
|
|
37
|
+
<div class="flex gap-4">
|
|
38
|
+
<ToggleIconButton variant="primary-inverse">
|
|
39
|
+
<Icon iconName="DownloadSimple" />
|
|
40
|
+
</ToggleIconButton>
|
|
41
|
+
<ToggleIconButton variant="primary-inverse" isActive={true}>
|
|
42
|
+
<Icon iconName="DownloadSimple" />
|
|
43
|
+
</ToggleIconButton>
|
|
44
|
+
</div>
|
|
45
|
+
</div>
|
|
46
|
+
</div>
|
|
47
|
+
<div class="flex gap-8">
|
|
48
|
+
<div class="flex flex-col gap-2">
|
|
49
|
+
<p class="text-sm">Secondary</p>
|
|
50
|
+
<div class="flex gap-4">
|
|
51
|
+
<ToggleIconButton variant="secondary">
|
|
52
|
+
<Icon iconName="DownloadSimple" />
|
|
53
|
+
</ToggleIconButton>
|
|
54
|
+
<ToggleIconButton variant="secondary" isActive={true}>
|
|
55
|
+
<Icon iconName="DownloadSimple" />
|
|
56
|
+
</ToggleIconButton>
|
|
57
|
+
</div>
|
|
58
|
+
</div>
|
|
59
|
+
</div>
|
|
60
|
+
</div>
|
|
61
|
+
</Story>
|
|
62
|
+
|
|
63
|
+
<Story name="Sizes">
|
|
64
|
+
<div class="flex gap-8">
|
|
65
|
+
<div class="flex flex-col items-center gap-2">
|
|
66
|
+
<p class="text-sm">XS</p>
|
|
67
|
+
<div class="flex gap-4">
|
|
68
|
+
<ToggleIconButton variant="primary-inverse" size="xs">
|
|
69
|
+
<Icon iconName="DownloadSimple" />
|
|
70
|
+
</ToggleIconButton>
|
|
71
|
+
<ToggleIconButton variant="primary-inverse" size="xs" isActive={true}>
|
|
72
|
+
<Icon iconName="DownloadSimple" />
|
|
73
|
+
</ToggleIconButton>
|
|
74
|
+
</div>
|
|
75
|
+
</div>
|
|
76
|
+
<div class="flex flex-col items-center gap-2">
|
|
77
|
+
<p class="text-sm">SM</p>
|
|
78
|
+
<div class="flex gap-4">
|
|
79
|
+
<ToggleIconButton variant="primary-inverse" size="sm">
|
|
80
|
+
<Icon iconName="DownloadSimple" />
|
|
81
|
+
</ToggleIconButton>
|
|
82
|
+
<ToggleIconButton variant="primary-inverse" size="sm" isActive={true}>
|
|
83
|
+
<Icon iconName="DownloadSimple" />
|
|
84
|
+
</ToggleIconButton>
|
|
85
|
+
</div>
|
|
86
|
+
</div>
|
|
87
|
+
<div class="flex flex-col items-center gap-2">
|
|
88
|
+
<p class="text-sm">MD</p>
|
|
89
|
+
<div class="flex gap-4">
|
|
90
|
+
<ToggleIconButton variant="primary-inverse" size="md">
|
|
91
|
+
<Icon iconName="DownloadSimple" />
|
|
92
|
+
</ToggleIconButton>
|
|
93
|
+
<ToggleIconButton variant="primary-inverse" size="md" isActive={true}>
|
|
94
|
+
<Icon iconName="DownloadSimple" />
|
|
95
|
+
</ToggleIconButton>
|
|
96
|
+
</div>
|
|
97
|
+
</div>
|
|
98
|
+
<div class="flex flex-col items-center gap-2">
|
|
99
|
+
<p class="text-sm">LG</p>
|
|
100
|
+
<div class="flex gap-4">
|
|
101
|
+
<ToggleIconButton variant="primary-inverse" size="lg">
|
|
102
|
+
<Icon iconName="DownloadSimple" />
|
|
103
|
+
</ToggleIconButton>
|
|
104
|
+
<ToggleIconButton variant="primary-inverse" size="lg" isActive={true}>
|
|
105
|
+
<Icon iconName="DownloadSimple" />
|
|
106
|
+
</ToggleIconButton>
|
|
107
|
+
</div>
|
|
108
|
+
</div>
|
|
109
|
+
</div>
|
|
110
|
+
</Story>
|
|
111
|
+
|
|
112
|
+
<Story name="Rounded vs Square">
|
|
113
|
+
<div class="flex gap-8">
|
|
114
|
+
<div class="flex flex-col items-center gap-2">
|
|
115
|
+
<p class="text-sm">Rounded</p>
|
|
116
|
+
<div class="flex gap-4">
|
|
117
|
+
<ToggleIconButton variant="primary-inverse" rounded>
|
|
118
|
+
<Icon iconName="DownloadSimple" />
|
|
119
|
+
</ToggleIconButton>
|
|
120
|
+
<ToggleIconButton variant="primary-inverse" rounded isActive={true}>
|
|
121
|
+
<Icon iconName="DownloadSimple" />
|
|
122
|
+
</ToggleIconButton>
|
|
123
|
+
</div>
|
|
124
|
+
</div>
|
|
125
|
+
<div class="flex flex-col items-center gap-2">
|
|
126
|
+
<p class="text-sm">Square</p>
|
|
127
|
+
<div class="flex gap-4">
|
|
128
|
+
<ToggleIconButton variant="primary-inverse" rounded={false}>
|
|
129
|
+
<Icon iconName="DownloadSimple" />
|
|
130
|
+
</ToggleIconButton>
|
|
131
|
+
<ToggleIconButton variant="primary-inverse" rounded={false} isActive={true}>
|
|
132
|
+
<Icon iconName="DownloadSimple" />
|
|
133
|
+
</ToggleIconButton>
|
|
134
|
+
</div>
|
|
135
|
+
</div>
|
|
136
|
+
</div>
|
|
137
|
+
</Story>
|
|
138
|
+
|
|
139
|
+
<Story name="Primary Inverse Example">
|
|
140
|
+
<div class="bg-neutral-dark p-8">
|
|
141
|
+
<div class="flex gap-8">
|
|
142
|
+
<div class="flex flex-col items-center gap-2">
|
|
143
|
+
<p class="text-neutral-light text-sm">Normal</p>
|
|
144
|
+
<ToggleIconButton variant="primary-inverse">
|
|
145
|
+
<Icon iconName="DownloadSimple" />
|
|
146
|
+
</ToggleIconButton>
|
|
147
|
+
</div>
|
|
148
|
+
<div class="flex flex-col items-center gap-2">
|
|
149
|
+
<p class="text-neutral-light text-sm">Active</p>
|
|
150
|
+
<ToggleIconButton variant="primary-inverse" isActive={true}>
|
|
151
|
+
<Icon iconName="DownloadSimple" />
|
|
152
|
+
</ToggleIconButton>
|
|
153
|
+
</div>
|
|
154
|
+
</div>
|
|
155
|
+
</div>
|
|
156
|
+
</Story>
|
|
157
|
+
|
|
158
|
+
<Story name="Disabled and Loading">
|
|
159
|
+
<div class="flex gap-8">
|
|
160
|
+
<div class="flex flex-col items-center gap-2">
|
|
161
|
+
<p class="text-sm">Disabled</p>
|
|
162
|
+
<ToggleIconButton disabled>
|
|
163
|
+
<Icon iconName="DownloadSimple" />
|
|
164
|
+
</ToggleIconButton>
|
|
165
|
+
</div>
|
|
166
|
+
<div class="flex flex-col items-center gap-2">
|
|
167
|
+
<p class="text-sm">Loading</p>
|
|
168
|
+
<ToggleIconButton loading>
|
|
169
|
+
<Icon iconName="DownloadSimple" />
|
|
170
|
+
</ToggleIconButton>
|
|
171
|
+
</div>
|
|
172
|
+
</div>
|
|
173
|
+
</Story>
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import ToggleIconButton from './ToggleIconButton.svelte';
|
|
2
|
+
interface $$__sveltets_2_IsomorphicComponent<Props extends Record<string, any> = any, Events extends Record<string, any> = any, Slots extends Record<string, any> = any, Exports = {}, Bindings = string> {
|
|
3
|
+
new (options: import('svelte').ComponentConstructorOptions<Props>): import('svelte').SvelteComponent<Props, Events, Slots> & {
|
|
4
|
+
$$bindings?: Bindings;
|
|
5
|
+
} & Exports;
|
|
6
|
+
(internal: unknown, props: {
|
|
7
|
+
$$events?: Events;
|
|
8
|
+
$$slots?: Slots;
|
|
9
|
+
}): Exports & {
|
|
10
|
+
$set?: any;
|
|
11
|
+
$on?: any;
|
|
12
|
+
};
|
|
13
|
+
z_$$bindings?: Bindings;
|
|
14
|
+
}
|
|
15
|
+
declare const ToggleIconButton: $$__sveltets_2_IsomorphicComponent<Record<string, never>, {
|
|
16
|
+
[evt: string]: CustomEvent<any>;
|
|
17
|
+
}, {}, {}, string>;
|
|
18
|
+
type ToggleIconButton = InstanceType<typeof ToggleIconButton>;
|
|
19
|
+
export default ToggleIconButton;
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import type { Snippet } from 'svelte';
|
|
3
|
+
import { Spinner } from '../spinner/';
|
|
4
|
+
import type { HTMLButtonAttributes } from 'svelte/elements';
|
|
5
|
+
type Variant = 'primary-inverse' | 'secondary';
|
|
6
|
+
interface Props {
|
|
7
|
+
variant?: Variant;
|
|
8
|
+
loading?: boolean;
|
|
9
|
+
size?: 'xs' | 'sm' | 'md' | 'lg';
|
|
10
|
+
children?: Snippet;
|
|
11
|
+
rounded?: boolean;
|
|
12
|
+
isActive?: boolean;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
type ToggleIconButtonProps = Props & HTMLButtonAttributes;
|
|
16
|
+
|
|
17
|
+
let {
|
|
18
|
+
variant = 'secondary',
|
|
19
|
+
type = 'button',
|
|
20
|
+
loading = false,
|
|
21
|
+
disabled = false,
|
|
22
|
+
size = 'sm',
|
|
23
|
+
children,
|
|
24
|
+
onclick,
|
|
25
|
+
rounded = false,
|
|
26
|
+
isActive = $bindable(false),
|
|
27
|
+
...rest
|
|
28
|
+
}: ToggleIconButtonProps = $props();
|
|
29
|
+
|
|
30
|
+
// Size class mappings
|
|
31
|
+
const sizeClasses = {
|
|
32
|
+
xs: 'h-6 w-6',
|
|
33
|
+
sm: 'h-8 w-8',
|
|
34
|
+
md: 'h-10 w-10',
|
|
35
|
+
lg: 'h-12 w-12'
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
// SVG size class mappings - used for styling the container that will affect child SVGs
|
|
39
|
+
const svgContainerClasses = {
|
|
40
|
+
xs: 'has-[svg]:children:h-4 has-[svg]:children:w-4',
|
|
41
|
+
sm: 'has-[svg]:children:h-4 has-[svg]:children:w-4',
|
|
42
|
+
md: 'has-[svg]:children:h-5 has-[svg]:children:w-5',
|
|
43
|
+
lg: 'has-[svg]:children:h-6 has-[svg]:children:w-6'
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
// Active state padding classes that scale with button size
|
|
47
|
+
const activePaddingClasses = {
|
|
48
|
+
xs: 'p-0.5',
|
|
49
|
+
sm: 'p-1',
|
|
50
|
+
md: 'p-1.5',
|
|
51
|
+
lg: 'p-2'
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
// Active state size classes for the inner container
|
|
55
|
+
const activeInnerSizeClasses = {
|
|
56
|
+
xs: 'h-4 w-4',
|
|
57
|
+
sm: 'h-6 w-6',
|
|
58
|
+
md: 'h-7 w-7',
|
|
59
|
+
lg: 'h-8 w-8'
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
// Variant class mappings
|
|
63
|
+
const variantClasses = {
|
|
64
|
+
'primary-inverse': 'bg-base-inverse text-icon-primary-inverse border border-interactive',
|
|
65
|
+
secondary: 'bg-neutral text-icon-primary hover:bg-neutral-hover'
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
// Active variant class mappings
|
|
69
|
+
const activeVariantClasses = {
|
|
70
|
+
'primary-inverse': 'bg-accent-inverse text-icon-primary-inverse',
|
|
71
|
+
secondary: 'bg-neutral-hover text-icon-primary'
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
let buttonSizeClass = $derived(sizeClasses[size]);
|
|
75
|
+
let buttonSvgContainerClass = $derived(svgContainerClasses[size]);
|
|
76
|
+
let buttonVariantClass = $derived(variantClasses[variant]);
|
|
77
|
+
let buttonActiveVariantClass = $derived(activeVariantClasses[variant]);
|
|
78
|
+
let activePaddingClass = $derived(activePaddingClasses[size]);
|
|
79
|
+
let activeInnerSizeClass = $derived(activeInnerSizeClasses[size]);
|
|
80
|
+
</script>
|
|
81
|
+
|
|
82
|
+
{#snippet content()}
|
|
83
|
+
{#if loading}
|
|
84
|
+
<Spinner />
|
|
85
|
+
{:else}
|
|
86
|
+
{@render children?.()}
|
|
87
|
+
{/if}
|
|
88
|
+
{/snippet}
|
|
89
|
+
|
|
90
|
+
<button
|
|
91
|
+
onclick={(e) => {
|
|
92
|
+
e.preventDefault();
|
|
93
|
+
if (disabled || loading) return;
|
|
94
|
+
onclick?.(e);
|
|
95
|
+
}}
|
|
96
|
+
{type}
|
|
97
|
+
{disabled}
|
|
98
|
+
{...rest}
|
|
99
|
+
class="flex cursor-pointer items-center justify-center duration-150 {buttonSizeClass} {buttonVariantClass} {buttonSvgContainerClass}"
|
|
100
|
+
class:rounded-full={rounded}
|
|
101
|
+
class:rounded-md={!rounded}
|
|
102
|
+
class:cursor-default={disabled}
|
|
103
|
+
class:disabled:bg-neutral={disabled}
|
|
104
|
+
class:disabled:text-tertiary={disabled}
|
|
105
|
+
>
|
|
106
|
+
{#if isActive}
|
|
107
|
+
<div
|
|
108
|
+
class="{buttonActiveVariantClass} flex items-center justify-center {activePaddingClass} {activeInnerSizeClass}"
|
|
109
|
+
class:rounded-full={rounded}
|
|
110
|
+
class:rounded-sm={!rounded}
|
|
111
|
+
>
|
|
112
|
+
{@render content()}
|
|
113
|
+
</div>
|
|
114
|
+
{:else}
|
|
115
|
+
{@render content?.()}
|
|
116
|
+
{/if}
|
|
117
|
+
</button>
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { Snippet } from 'svelte';
|
|
2
|
+
import type { HTMLButtonAttributes } from 'svelte/elements';
|
|
3
|
+
type Variant = 'primary-inverse' | 'secondary';
|
|
4
|
+
interface Props {
|
|
5
|
+
variant?: Variant;
|
|
6
|
+
loading?: boolean;
|
|
7
|
+
size?: 'xs' | 'sm' | 'md' | 'lg';
|
|
8
|
+
children?: Snippet;
|
|
9
|
+
rounded?: boolean;
|
|
10
|
+
isActive?: boolean;
|
|
11
|
+
}
|
|
12
|
+
type ToggleIconButtonProps = Props & HTMLButtonAttributes;
|
|
13
|
+
declare const ToggleIconButton: import("svelte").Component<ToggleIconButtonProps, {}, "isActive">;
|
|
14
|
+
type ToggleIconButton = ReturnType<typeof ToggleIconButton>;
|
|
15
|
+
export default ToggleIconButton;
|
package/dist/index.d.ts
CHANGED
|
@@ -32,7 +32,9 @@ export * from './components/status-badge/';
|
|
|
32
32
|
export * from './components/table/';
|
|
33
33
|
export * from './components/tabs/';
|
|
34
34
|
export * from './components/tag/';
|
|
35
|
+
export * from './components/toggle-icon-button/';
|
|
35
36
|
export * from './components/tooltip/';
|
|
36
37
|
export * from './components/toggle/';
|
|
38
|
+
export * from './components/checkbox/';
|
|
37
39
|
export { tokens } from './tokens';
|
|
38
40
|
import './app.css';
|
package/dist/index.js
CHANGED
|
@@ -33,8 +33,10 @@ export * from './components/status-badge/';
|
|
|
33
33
|
export * from './components/table/';
|
|
34
34
|
export * from './components/tabs/';
|
|
35
35
|
export * from './components/tag/';
|
|
36
|
+
export * from './components/toggle-icon-button/';
|
|
36
37
|
export * from './components/tooltip/';
|
|
37
38
|
export * from './components/toggle/';
|
|
39
|
+
export * from './components/checkbox/';
|
|
38
40
|
// Styles and Tokens
|
|
39
41
|
export { tokens } from './tokens';
|
|
40
42
|
import './app.css';
|
|
@@ -126,6 +126,7 @@ export const display = [
|
|
|
126
126
|
'justify-center',
|
|
127
127
|
'flex-row',
|
|
128
128
|
'flex-col',
|
|
129
|
+
'px-0.5',
|
|
129
130
|
'px-2',
|
|
130
131
|
'py-1'
|
|
131
132
|
];
|
|
@@ -163,6 +164,7 @@ export const flexLayout = [
|
|
|
163
164
|
'text-center',
|
|
164
165
|
'text-base',
|
|
165
166
|
'gap-1',
|
|
167
|
+
'gap-1.5',
|
|
166
168
|
'gap-2',
|
|
167
169
|
'gap-3',
|
|
168
170
|
'gap-4',
|