@reshape-biotech/design-system 0.0.23 → 0.0.25
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 +30 -38
- package/dist/app.css +4 -4
- package/dist/components/avatar/index.d.ts +1 -0
- package/dist/components/avatar/index.js +1 -0
- package/dist/components/banner/Banner.stories.svelte +129 -0
- package/dist/components/banner/Banner.svelte +59 -0
- package/dist/components/banner/Banner.svelte.d.ts +11 -0
- package/dist/components/banner/index.d.ts +1 -0
- package/dist/components/banner/index.js +1 -0
- package/dist/components/button/Button.stories.svelte +37 -0
- package/dist/components/button/Button.svelte +85 -0
- package/dist/components/button/Button.svelte.d.ts +17 -0
- package/dist/components/button/index.d.ts +1 -0
- package/dist/components/button/index.js +1 -0
- package/dist/components/datepicker/DatePicker.svelte +283 -0
- package/dist/components/datepicker/DatePicker.svelte.d.ts +8 -0
- package/dist/components/datepicker/index.d.ts +1 -0
- package/dist/components/datepicker/index.js +1 -0
- package/dist/components/divider/Divider.stories.svelte +14 -0
- package/dist/components/divider/Divider.svelte +9 -0
- package/dist/components/divider/Divider.svelte.d.ts +6 -0
- package/dist/components/divider/index.d.ts +1 -0
- package/dist/components/divider/index.js +1 -0
- package/dist/components/drawer/Drawer.stories.svelte +99 -0
- package/dist/components/drawer/Drawer.svelte +45 -0
- package/dist/components/drawer/Drawer.svelte.d.ts +12 -0
- package/dist/components/drawer/DrawerLabel.svelte +13 -0
- package/dist/components/drawer/DrawerLabel.svelte.d.ts +9 -0
- package/dist/components/drawer/index.d.ts +1 -0
- package/dist/components/drawer/index.js +1 -0
- package/dist/components/dropdown/Dropdown.stories.svelte +214 -0
- package/dist/components/dropdown/Dropdown.svelte +69 -0
- package/dist/components/dropdown/Dropdown.svelte.d.ts +14 -0
- package/dist/components/dropdown/components/DropdownContent.svelte +29 -0
- package/dist/components/dropdown/components/DropdownContent.svelte.d.ts +10 -0
- package/dist/components/dropdown/components/DropdownMenu.svelte +23 -0
- package/dist/components/dropdown/components/DropdownMenu.svelte.d.ts +8 -0
- package/dist/components/dropdown/components/DropdownTrigger.svelte +44 -0
- package/dist/components/dropdown/components/DropdownTrigger.svelte.d.ts +12 -0
- package/dist/components/dropdown/index.d.ts +1 -0
- package/dist/components/dropdown/index.js +1 -0
- package/dist/components/icon-button/IconButton.stories.svelte +52 -0
- package/dist/components/icon-button/IconButton.svelte +72 -0
- package/dist/components/icon-button/IconButton.svelte.d.ts +14 -0
- package/dist/components/icon-button/index.d.ts +1 -0
- package/dist/components/icon-button/index.js +1 -0
- package/dist/components/image/Image.svelte +56 -0
- package/dist/components/image/Image.svelte.d.ts +7 -0
- package/dist/components/image/index.d.ts +1 -0
- package/dist/components/image/index.js +1 -0
- package/dist/components/input/Input.stories.svelte +81 -0
- package/dist/components/input/Input.svelte +131 -0
- package/dist/components/input/Input.svelte.d.ts +20 -0
- package/dist/components/input/index.d.ts +1 -0
- package/dist/components/input/index.js +1 -0
- package/dist/components/list/List.stories.svelte +97 -0
- package/dist/components/list/List.svelte +75 -0
- package/dist/components/list/List.svelte.d.ts +24 -0
- package/dist/components/list/index.d.ts +1 -0
- package/dist/components/list/index.js +1 -0
- package/dist/components/markdown/Markdown.stories.svelte +41 -0
- package/dist/components/markdown/Markdown.svelte +12 -0
- package/dist/components/markdown/Markdown.svelte.d.ts +6 -0
- package/dist/components/markdown/index.d.ts +1 -0
- package/dist/components/markdown/index.js +1 -0
- package/dist/components/modal/Modal.stories.svelte +41 -0
- package/dist/components/modal/Modal.svelte +56 -0
- package/dist/components/modal/Modal.svelte.d.ts +16 -0
- package/dist/components/modal/index.d.ts +1 -0
- package/dist/components/modal/index.js +1 -0
- package/dist/components/notification-popup/NotificationPopup.stories.svelte +27 -0
- package/dist/components/notification-popup/NotificationPopup.svelte +31 -0
- package/dist/components/notification-popup/NotificationPopup.svelte.d.ts +11 -0
- package/dist/components/notification-popup/index.d.ts +1 -0
- package/dist/components/notification-popup/index.js +1 -0
- package/dist/components/pill/Pill.svelte +39 -0
- package/dist/components/pill/Pill.svelte.d.ts +10 -0
- package/dist/components/pill/index.d.ts +1 -0
- package/dist/components/pill/index.js +1 -0
- package/dist/components/progress-circle/ProgressCircle.svelte +79 -0
- package/dist/components/progress-circle/ProgressCircle.svelte.d.ts +7 -0
- package/dist/components/progress-circle/index.d.ts +1 -0
- package/dist/components/progress-circle/index.js +1 -0
- package/dist/components/segmented-control-buttons/ControlButton.svelte +59 -0
- package/dist/components/segmented-control-buttons/ControlButton.svelte.d.ts +14 -0
- package/dist/components/segmented-control-buttons/SegmentedControlButtons.stories.svelte +45 -0
- package/dist/components/segmented-control-buttons/SegmentedControlButtons.svelte +21 -0
- package/dist/components/segmented-control-buttons/SegmentedControlButtons.svelte.d.ts +10 -0
- package/dist/components/segmented-control-buttons/index.d.ts +2 -0
- package/dist/components/segmented-control-buttons/index.js +2 -0
- package/dist/components/select/Select.stories.svelte +113 -0
- package/dist/components/select/Select.svelte +137 -0
- package/dist/components/select/Select.svelte.d.ts +60 -0
- package/dist/components/select/index.d.ts +7 -0
- package/dist/components/select/index.js +1 -0
- package/dist/components/skeleton-loader/SkeletonLoader.stories.svelte +71 -0
- package/dist/components/skeleton-loader/SkeletonLoader.svelte +17 -0
- package/dist/components/skeleton-loader/SkeletonLoader.svelte.d.ts +9 -0
- package/dist/components/skeleton-loader/StatcardSkeleton.svelte +17 -0
- package/dist/components/skeleton-loader/StatcardSkeleton.svelte.d.ts +18 -0
- package/dist/components/skeleton-loader/components/Skeleton.svelte +14 -0
- package/dist/components/skeleton-loader/components/Skeleton.svelte.d.ts +8 -0
- package/dist/components/skeleton-loader/components/SkeletonImage.svelte +14 -0
- package/dist/components/{tooltip/Tooltip.stories.svelte.d.ts → skeleton-loader/components/SkeletonImage.svelte.d.ts} +3 -4
- package/dist/components/skeleton-loader/index.d.ts +3 -0
- package/dist/components/skeleton-loader/index.js +3 -0
- package/dist/components/slider/Slider.stories.svelte +37 -0
- package/dist/components/slider/Slider.svelte +117 -0
- package/dist/components/slider/Slider.svelte.d.ts +29 -0
- package/dist/components/slider/index.d.ts +1 -0
- package/dist/components/slider/index.js +1 -0
- package/dist/components/spinner/Spinner.svelte +27 -0
- package/dist/components/spinner/Spinner.svelte.d.ts +6 -0
- package/dist/components/spinner/index.d.ts +1 -0
- package/dist/components/spinner/index.js +1 -0
- package/dist/components/stat-card/StatCard.stories.svelte +32 -0
- package/dist/components/stat-card/StatCard.svelte +52 -0
- package/dist/components/stat-card/StatCard.svelte.d.ts +10 -0
- package/dist/components/stat-card/index.d.ts +1 -0
- package/dist/components/stat-card/index.js +1 -0
- package/dist/components/status-badge/StatusBadge.stories.svelte +401 -0
- package/dist/components/status-badge/StatusBadge.svelte +147 -0
- package/dist/components/status-badge/StatusBadge.svelte.d.ts +12 -0
- package/dist/components/status-badge/index.d.ts +1 -0
- package/dist/components/status-badge/index.js +1 -0
- package/dist/components/table/Table.stories.svelte +86 -0
- package/dist/components/table/Table.svelte +33 -0
- package/dist/components/table/Table.svelte.d.ts +8 -0
- package/dist/components/table/components/Td.svelte +14 -0
- package/dist/components/table/components/Td.svelte.d.ts +8 -0
- package/dist/components/table/components/Th.svelte +15 -0
- package/dist/components/table/components/Th.svelte.d.ts +9 -0
- package/dist/components/table/components/Tr.svelte +31 -0
- package/dist/components/table/components/Tr.svelte.d.ts +8 -0
- package/dist/components/table/index.d.ts +1 -0
- package/dist/components/table/index.js +1 -0
- package/dist/components/tabs/Tabs.stories.svelte +30 -0
- package/dist/components/tabs/Tabs.svelte +15 -0
- package/dist/components/tabs/Tabs.svelte.d.ts +8 -0
- package/dist/components/tabs/components/Content.svelte +15 -0
- package/dist/components/tabs/components/Content.svelte.d.ts +9 -0
- package/dist/components/tabs/components/Tab.svelte +21 -0
- package/dist/components/tabs/components/Tab.svelte.d.ts +10 -0
- package/dist/components/tabs/components/Tabs.svelte +14 -0
- package/dist/components/tabs/components/Tabs.svelte.d.ts +8 -0
- package/dist/components/tabs/index.d.ts +1 -0
- package/dist/components/tabs/index.js +1 -0
- package/dist/components/tag/Tag.stories.svelte +50 -0
- package/dist/components/tag/Tag.svelte +104 -0
- package/dist/components/tag/Tag.svelte.d.ts +11 -0
- package/dist/components/tag/index.d.ts +1 -0
- package/dist/components/tag/index.js +1 -0
- package/dist/components/toast/Toast.svelte +66 -0
- package/dist/components/toast/Toast.svelte.d.ts +5 -0
- package/dist/components/toast/index.d.ts +1 -0
- package/dist/components/toast/index.js +1 -0
- package/dist/components/tooltip/index.d.ts +1 -0
- package/dist/components/tooltip/index.js +1 -0
- package/dist/fonts/MDSystem-Medium.woff +0 -0
- package/dist/fonts/MDSystem-Medium.woff2 +0 -0
- package/dist/fonts/MDSystem-Regular.woff +0 -0
- package/dist/fonts/MDSystem-Regular.woff2 +0 -0
- package/dist/fonts/MDSystem-Semibold.woff +0 -0
- package/dist/fonts/MDSystem-Semibold.woff2 +0 -0
- package/dist/fonts/MDSystemMono-Regular.woff +0 -0
- package/dist/fonts/MDSystemMono-Regular.woff2 +0 -0
- package/dist/fonts/index.d.ts +6 -0
- package/dist/fonts/index.js +10 -0
- package/dist/index.d.ts +29 -3
- package/dist/index.js +31 -4
- package/dist/tailwind.preset.d.ts +1 -0
- package/dist/tokens.d.ts +314 -36
- package/dist/tokens.js +235 -248
- package/dist/types/fonts.d.ts +4 -0
- package/package.json +9 -15
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { X } from 'phosphor-svelte';
|
|
3
|
+
import IconButton from '../icon-button/';
|
|
4
|
+
import { fade, fly } from 'svelte/transition';
|
|
5
|
+
import type { Snippet } from 'svelte';
|
|
6
|
+
|
|
7
|
+
interface Props {
|
|
8
|
+
onClose: () => void;
|
|
9
|
+
title: string;
|
|
10
|
+
visible: boolean;
|
|
11
|
+
id?: string | undefined;
|
|
12
|
+
children?: Snippet;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
let { onClose, title, visible, id = undefined, children }: Props = $props();
|
|
16
|
+
</script>
|
|
17
|
+
|
|
18
|
+
{#if visible}
|
|
19
|
+
<div
|
|
20
|
+
{id}
|
|
21
|
+
class="flex w-[184px] justify-between rounded-lg bg-surface p-3 shadow-2xl"
|
|
22
|
+
in:fly={{ y: 100, duration: 1000 }}
|
|
23
|
+
out:fade
|
|
24
|
+
>
|
|
25
|
+
<div class="flex flex-col gap-2">
|
|
26
|
+
<h6 class="flex h-6 items-center">{title}</h6>
|
|
27
|
+
{@render children?.()}
|
|
28
|
+
</div>
|
|
29
|
+
<IconButton size="xs" onclick={onClose}><X /></IconButton>
|
|
30
|
+
</div>
|
|
31
|
+
{/if}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { Snippet } from 'svelte';
|
|
2
|
+
interface Props {
|
|
3
|
+
onClose: () => void;
|
|
4
|
+
title: string;
|
|
5
|
+
visible: boolean;
|
|
6
|
+
id?: string | undefined;
|
|
7
|
+
children?: Snippet;
|
|
8
|
+
}
|
|
9
|
+
declare const NotificationPopup: import("svelte").Component<Props, {}, "">;
|
|
10
|
+
type NotificationPopup = ReturnType<typeof NotificationPopup>;
|
|
11
|
+
export default NotificationPopup;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as NotificationPopup } from './NotificationPopup.svelte';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as NotificationPopup } from './NotificationPopup.svelte';
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { X } from 'phosphor-svelte';
|
|
3
|
+
|
|
4
|
+
interface Props {
|
|
5
|
+
class?: string;
|
|
6
|
+
text: string;
|
|
7
|
+
type?: 'button' | 'submit';
|
|
8
|
+
testID?: string;
|
|
9
|
+
onclick?: () => void;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
let { class: className = '', text, type = 'button', testID = '', onclick }: Props = $props();
|
|
13
|
+
</script>
|
|
14
|
+
|
|
15
|
+
<button class="{className} " {onclick} {type} data-testid={testID}>
|
|
16
|
+
{text}
|
|
17
|
+
<X class="opacity-50" weight="bold" />
|
|
18
|
+
</button>
|
|
19
|
+
|
|
20
|
+
<style>
|
|
21
|
+
button {
|
|
22
|
+
gap: 0.5rem;
|
|
23
|
+
border-radius: 9999px;
|
|
24
|
+
background-color: #5750ee1A;
|
|
25
|
+
padding-left: 1rem;
|
|
26
|
+
padding-right: 1rem;
|
|
27
|
+
padding-top: 0px;
|
|
28
|
+
padding-bottom: 0px;
|
|
29
|
+
font-size: 0.875rem;
|
|
30
|
+
line-height: 1.25rem;
|
|
31
|
+
--tw-text-opacity: 1;
|
|
32
|
+
color: rgb(71 65 193 / var(--tw-text-opacity, 1));
|
|
33
|
+
display: flex;
|
|
34
|
+
white-space: nowrap;
|
|
35
|
+
height: 32px;
|
|
36
|
+
|
|
37
|
+
align-items: center
|
|
38
|
+
}
|
|
39
|
+
</style>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from './Pill.svelte';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from './Pill.svelte';
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
// Make sure progress is between 0 and 100 and round down to the nearest 10 if over 90
|
|
3
|
+
$effect(() => {
|
|
4
|
+
progress =
|
|
5
|
+
progress > 90
|
|
6
|
+
? Math.floor(Math.min(100, progress) / 10) * 10
|
|
7
|
+
: Math.min(100, Math.max(0, progress));
|
|
8
|
+
});
|
|
9
|
+
|
|
10
|
+
type Props = {
|
|
11
|
+
progress: number;
|
|
12
|
+
size?: 'md' | 'sm';
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
let { progress = $bindable(), size = 'md' }: Props = $props();
|
|
16
|
+
|
|
17
|
+
const viewBox = size === 'md' ? '0 0 20 20' : '0 0 16 16';
|
|
18
|
+
const center = size === 'md' ? 10 : 8;
|
|
19
|
+
const radius = size === 'md' ? 7 : 6;
|
|
20
|
+
|
|
21
|
+
// Create the circle path
|
|
22
|
+
const path = `M ${center} ${center - radius}
|
|
23
|
+
A ${radius} ${radius} 0 1 1 ${center - 0.01} ${center - radius}`;
|
|
24
|
+
</script>
|
|
25
|
+
|
|
26
|
+
<div class="progress-wrapper" class:sm={size === 'sm'} class:md={size === 'md'}>
|
|
27
|
+
<svg xmlns="http://www.w3.org/2000/svg" {viewBox} fill="none">
|
|
28
|
+
<!-- Background track -->
|
|
29
|
+
<path d={path} stroke="currentColor" stroke-opacity="0.25" stroke-width="2" fill="none" />
|
|
30
|
+
<!-- Progress indicator -->
|
|
31
|
+
<path
|
|
32
|
+
d={path}
|
|
33
|
+
stroke="currentColor"
|
|
34
|
+
stroke-width="2"
|
|
35
|
+
stroke-linecap="round"
|
|
36
|
+
fill="none"
|
|
37
|
+
style="stroke-dasharray: var(--pathLength);
|
|
38
|
+
stroke-dashoffset: calc(var(--pathLength) * (1 - {progress / 100}));"
|
|
39
|
+
pathLength="1"
|
|
40
|
+
/>
|
|
41
|
+
</svg>
|
|
42
|
+
</div>
|
|
43
|
+
|
|
44
|
+
<style>
|
|
45
|
+
.progress-wrapper {
|
|
46
|
+
|
|
47
|
+
position: relative;
|
|
48
|
+
|
|
49
|
+
display: inline-block;
|
|
50
|
+
|
|
51
|
+
aspect-ratio: 1;
|
|
52
|
+
}
|
|
53
|
+
.progress-wrapper.md {
|
|
54
|
+
|
|
55
|
+
width: 1.25rem;
|
|
56
|
+
|
|
57
|
+
height: 1.25rem;
|
|
58
|
+
}
|
|
59
|
+
.progress-wrapper.sm {
|
|
60
|
+
|
|
61
|
+
width: 1rem;
|
|
62
|
+
|
|
63
|
+
height: 1rem;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
svg {
|
|
67
|
+
|
|
68
|
+
position: absolute;
|
|
69
|
+
|
|
70
|
+
inset: 0px;
|
|
71
|
+
width: 100%;
|
|
72
|
+
height: 100%;
|
|
73
|
+
display: block;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
path {
|
|
77
|
+
--pathLength: 1;
|
|
78
|
+
}
|
|
79
|
+
</style>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from './ProgressCircle.svelte';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from './ProgressCircle.svelte';
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import type { Snippet } from 'svelte';
|
|
3
|
+
|
|
4
|
+
type Color = 'primary' | 'secondary';
|
|
5
|
+
|
|
6
|
+
interface Props {
|
|
7
|
+
class?: string;
|
|
8
|
+
color?: Color;
|
|
9
|
+
disabled?: boolean;
|
|
10
|
+
active?: boolean;
|
|
11
|
+
dataTestId?: string;
|
|
12
|
+
onclick?: () => void;
|
|
13
|
+
children?: Snippet;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
let {
|
|
17
|
+
class: className = '',
|
|
18
|
+
color = 'primary',
|
|
19
|
+
disabled = false,
|
|
20
|
+
active = false,
|
|
21
|
+
dataTestId,
|
|
22
|
+
onclick,
|
|
23
|
+
children
|
|
24
|
+
}: Props = $props();
|
|
25
|
+
const colors: Record<Color, string> = {
|
|
26
|
+
primary:
|
|
27
|
+
'bg-transparent text-primary hover:bg-neutral disabled:bg-neutral disabled:text-tertiary',
|
|
28
|
+
secondary:
|
|
29
|
+
'bg-transparent text-primary hover:bg-neutral disabled:bg-neutral disabled:text-tertiary'
|
|
30
|
+
};
|
|
31
|
+
</script>
|
|
32
|
+
|
|
33
|
+
<div class="join-item flex h-full flex-1">
|
|
34
|
+
<button
|
|
35
|
+
{onclick}
|
|
36
|
+
class={`control-button flex flex-1 items-center justify-center gap-2 rounded-md text-sm leading-4 ${colors[color]} ${className} ${color}`}
|
|
37
|
+
class:active
|
|
38
|
+
type="button"
|
|
39
|
+
{disabled}
|
|
40
|
+
data-testid={dataTestId}
|
|
41
|
+
>
|
|
42
|
+
{@render children?.()}
|
|
43
|
+
</button>
|
|
44
|
+
</div>
|
|
45
|
+
|
|
46
|
+
<style>
|
|
47
|
+
.primary.active {
|
|
48
|
+
--tw-bg-opacity: 1;
|
|
49
|
+
background-color: rgb(87 80 238 / var(--tw-bg-opacity, 1));
|
|
50
|
+
--tw-text-opacity: 1;
|
|
51
|
+
color: rgb(255 255 255 / var(--tw-text-opacity, 1))
|
|
52
|
+
}
|
|
53
|
+
.secondary.active {
|
|
54
|
+
--tw-bg-opacity: 1;
|
|
55
|
+
background-color: rgb(255 255 255 / var(--tw-bg-opacity, 1));
|
|
56
|
+
--tw-text-opacity: 1;
|
|
57
|
+
color: rgb(18 25 42 / var(--tw-text-opacity, 1))
|
|
58
|
+
}
|
|
59
|
+
</style>
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { Snippet } from 'svelte';
|
|
2
|
+
type Color = 'primary' | 'secondary';
|
|
3
|
+
interface Props {
|
|
4
|
+
class?: string;
|
|
5
|
+
color?: Color;
|
|
6
|
+
disabled?: boolean;
|
|
7
|
+
active?: boolean;
|
|
8
|
+
dataTestId?: string;
|
|
9
|
+
onclick?: () => void;
|
|
10
|
+
children?: Snippet;
|
|
11
|
+
}
|
|
12
|
+
declare const ControlButton: import("svelte").Component<Props, {}, "">;
|
|
13
|
+
type ControlButton = ReturnType<typeof ControlButton>;
|
|
14
|
+
export default ControlButton;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
<script module lang="ts">
|
|
2
|
+
import { Star } from 'phosphor-svelte';
|
|
3
|
+
import SegmentedControlButtons from './SegmentedControlButtons.svelte';
|
|
4
|
+
import { defineMeta } from '@storybook/addon-svelte-csf';
|
|
5
|
+
|
|
6
|
+
const { Story } = defineMeta({
|
|
7
|
+
component: SegmentedControlButtons,
|
|
8
|
+
title: 'Design System/SegmentedControlButtons',
|
|
9
|
+
tags: ['autodocs']
|
|
10
|
+
});
|
|
11
|
+
</script>
|
|
12
|
+
|
|
13
|
+
<Story name="Primary">
|
|
14
|
+
<SegmentedControlButtons class="w-[350px]">
|
|
15
|
+
{#snippet children(ControlButton)}
|
|
16
|
+
<ControlButton active><Star /> Low</ControlButton>
|
|
17
|
+
<ControlButton><Star /> Medium</ControlButton>
|
|
18
|
+
<ControlButton disabled><Star /> High</ControlButton>
|
|
19
|
+
{/snippet}
|
|
20
|
+
</SegmentedControlButtons>
|
|
21
|
+
</Story>
|
|
22
|
+
<Story name="Large">
|
|
23
|
+
<SegmentedControlButtons size="lg" class="w-[350px]">
|
|
24
|
+
{#snippet children(ControlButton)}
|
|
25
|
+
<ControlButton active><Star /> Low</ControlButton>
|
|
26
|
+
<ControlButton><Star /> Medium</ControlButton>
|
|
27
|
+
<ControlButton disabled><Star /> High</ControlButton>
|
|
28
|
+
{/snippet}
|
|
29
|
+
</SegmentedControlButtons>
|
|
30
|
+
</Story>
|
|
31
|
+
<Story name="Secondary">
|
|
32
|
+
<SegmentedControlButtons class="w-[350px]">
|
|
33
|
+
{#snippet children(ControlButton)}
|
|
34
|
+
<ControlButton active color="secondary">
|
|
35
|
+
<Star /> Low
|
|
36
|
+
</ControlButton>
|
|
37
|
+
<ControlButton color="secondary">
|
|
38
|
+
<Star /> Medium
|
|
39
|
+
</ControlButton>
|
|
40
|
+
<ControlButton color="secondary">
|
|
41
|
+
<Star /> High
|
|
42
|
+
</ControlButton>
|
|
43
|
+
{/snippet}
|
|
44
|
+
</SegmentedControlButtons>
|
|
45
|
+
</Story>
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import type { Snippet } from 'svelte';
|
|
3
|
+
import ControlButton from './ControlButton.svelte';
|
|
4
|
+
|
|
5
|
+
interface Props {
|
|
6
|
+
class?: string;
|
|
7
|
+
size?: 'md' | 'lg';
|
|
8
|
+
children?: Snippet<[typeof ControlButton]>;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
let { class: className = '', size = 'md', children }: Props = $props();
|
|
12
|
+
|
|
13
|
+
const sizes = {
|
|
14
|
+
md: 'h-10 ',
|
|
15
|
+
lg: 'h-16 [&>*>.control-button]:flex-col'
|
|
16
|
+
};
|
|
17
|
+
</script>
|
|
18
|
+
|
|
19
|
+
<div class={`join flex gap-1 rounded-lg bg-neutral p-1 ${sizes[size]} ${size} ${className}`}>
|
|
20
|
+
{@render children?.(ControlButton)}
|
|
21
|
+
</div>
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { Snippet } from 'svelte';
|
|
2
|
+
import ControlButton from './ControlButton.svelte';
|
|
3
|
+
interface Props {
|
|
4
|
+
class?: string;
|
|
5
|
+
size?: 'md' | 'lg';
|
|
6
|
+
children?: Snippet<[typeof ControlButton]>;
|
|
7
|
+
}
|
|
8
|
+
declare const SegmentedControlButtons: import("svelte").Component<Props, {}, "">;
|
|
9
|
+
type SegmentedControlButtons = ReturnType<typeof SegmentedControlButtons>;
|
|
10
|
+
export default SegmentedControlButtons;
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
<script module lang="ts">
|
|
2
|
+
import Select from './Select.svelte';
|
|
3
|
+
|
|
4
|
+
import { defineMeta } from '@storybook/addon-svelte-csf';
|
|
5
|
+
|
|
6
|
+
const { Story } = defineMeta({
|
|
7
|
+
component: Select,
|
|
8
|
+
title: 'Design System/Select',
|
|
9
|
+
tags: ['autodocs']
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
const items = [
|
|
13
|
+
{ value: '1', label: 'One', group: 'Group 1', description: 'Description 1' },
|
|
14
|
+
{ value: '2', label: 'Two', group: 'Group 1', description: 'Description 2' },
|
|
15
|
+
{ value: '3', label: 'Three', group: 'Group 2' },
|
|
16
|
+
{ value: '4', label: 'Four', group: 'Group 2' }
|
|
17
|
+
];
|
|
18
|
+
let value: any = $state();
|
|
19
|
+
let thisChanged = $state(false);
|
|
20
|
+
|
|
21
|
+
function handleInput(e: Event) {
|
|
22
|
+
thisChanged = true;
|
|
23
|
+
}
|
|
24
|
+
</script>
|
|
25
|
+
|
|
26
|
+
<Story name="Default">
|
|
27
|
+
<div class="py-12">
|
|
28
|
+
<Select listOpen {items} />
|
|
29
|
+
</div>
|
|
30
|
+
</Story>
|
|
31
|
+
<Story name="Grouped">
|
|
32
|
+
<div class="py-12">
|
|
33
|
+
<Select listOpen {items} withGroup />
|
|
34
|
+
</div>
|
|
35
|
+
</Story>
|
|
36
|
+
|
|
37
|
+
<Story name="DefaultValue">
|
|
38
|
+
<div class="py-12">
|
|
39
|
+
<Select listOpen {items} withGroup value={{ value: '1', label: 'One', group: 'Group 1' }} />
|
|
40
|
+
</div>
|
|
41
|
+
</Story>
|
|
42
|
+
|
|
43
|
+
<Story name="Disabled">
|
|
44
|
+
<div class="py-12">
|
|
45
|
+
<Select listOpen {items} disabled />
|
|
46
|
+
</div>
|
|
47
|
+
</Story>
|
|
48
|
+
<Story name="Searchable">
|
|
49
|
+
<div class="py-12">
|
|
50
|
+
<Select listOpen {items} searchable />
|
|
51
|
+
</div>
|
|
52
|
+
</Story>
|
|
53
|
+
<Story name="Open">
|
|
54
|
+
<div class="py-12">
|
|
55
|
+
<Select listOpen {items} />
|
|
56
|
+
</div>
|
|
57
|
+
</Story>
|
|
58
|
+
<Story name="Error">
|
|
59
|
+
<div class="py-12">
|
|
60
|
+
<Select listOpen {items} hasError />
|
|
61
|
+
</div>
|
|
62
|
+
</Story>
|
|
63
|
+
<Story name="Placeholder">
|
|
64
|
+
<div class="py-12">
|
|
65
|
+
<Select listOpen {items} placeholder="Select a value" />
|
|
66
|
+
</div>
|
|
67
|
+
</Story>
|
|
68
|
+
<Story name="Multiple">
|
|
69
|
+
<div class="py-12">
|
|
70
|
+
<Select listOpen {items} multiple bind:value />
|
|
71
|
+
</div>
|
|
72
|
+
</Story>
|
|
73
|
+
|
|
74
|
+
<Story name="Bind value input changed">
|
|
75
|
+
<div class="py-12">
|
|
76
|
+
<Select listOpen {items} bind:value on:input={handleInput} />
|
|
77
|
+
{#if thisChanged}
|
|
78
|
+
<p class="text-secondary">Wow you picked something from the dropdown 💪</p>{/if}
|
|
79
|
+
</div>
|
|
80
|
+
</Story>
|
|
81
|
+
|
|
82
|
+
<Story name="Custom Item">
|
|
83
|
+
<div class="py-12">
|
|
84
|
+
<Select listOpen {items} value={{ value: '1', label: 'One', group: 'Group 1' }}>
|
|
85
|
+
<!-- @migration-task: migrate this slot by hand, `custom-item` is an invalid identifier -->
|
|
86
|
+
<div
|
|
87
|
+
slot="custom-item"
|
|
88
|
+
class="flex h-14 w-full items-center overflow-hidden whitespace-nowrap"
|
|
89
|
+
let:item
|
|
90
|
+
>
|
|
91
|
+
<div class="flex flex-col">
|
|
92
|
+
<p class="text-sm">
|
|
93
|
+
{item.label}
|
|
94
|
+
</p>
|
|
95
|
+
<p class="max-w-20 text-xs text-secondary">
|
|
96
|
+
{item.description} very very long long loooooong long description
|
|
97
|
+
</p>
|
|
98
|
+
</div>
|
|
99
|
+
</div>
|
|
100
|
+
</Select>
|
|
101
|
+
</div>
|
|
102
|
+
</Story>
|
|
103
|
+
|
|
104
|
+
<Story name="Custom selection label">
|
|
105
|
+
<div class="py-12">
|
|
106
|
+
<Select {items} value={{ value: '1', label: 'One', group: 'Group 1' }}>
|
|
107
|
+
<!-- @migration-task: migrate this slot by hand, `custom-selection` is an invalid identifier -->
|
|
108
|
+
<div slot="custom-selection" let:selection>
|
|
109
|
+
<p>💩{selection.label} poopoo💩</p>
|
|
110
|
+
</div>
|
|
111
|
+
</Select>
|
|
112
|
+
</div>
|
|
113
|
+
</Story>
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
<!-- @migration-task Error while migrating Svelte code: Cannot overwrite a zero-length range – use appendLeft or prependRight instead -->
|
|
2
|
+
<!-- @migration-task Error while migrating Svelte code: This migration would change the name of a slot making the component unusable -->
|
|
3
|
+
<script lang="ts">
|
|
4
|
+
import { backgroundColor, textColor } from '../../tokens';
|
|
5
|
+
import { CaretDown, X } from 'phosphor-svelte';
|
|
6
|
+
import { createEventDispatcher } from 'svelte';
|
|
7
|
+
let className = '';
|
|
8
|
+
export { className as class };
|
|
9
|
+
import SvelteSelect from 'svelte-select';
|
|
10
|
+
import type { ItemProps } from '.';
|
|
11
|
+
|
|
12
|
+
// Docs: https://github.com/rob-balfre/svelte-select
|
|
13
|
+
|
|
14
|
+
const dispatch = createEventDispatcher();
|
|
15
|
+
|
|
16
|
+
export let items: ItemProps[] = [];
|
|
17
|
+
export let id: string | undefined = undefined;
|
|
18
|
+
export let value: ItemProps | ItemProps[] | null = null;
|
|
19
|
+
export let searchable = false;
|
|
20
|
+
export let listOpen = false;
|
|
21
|
+
export let placeholder: string | undefined = undefined;
|
|
22
|
+
export let disabled = false;
|
|
23
|
+
export let hasError = false;
|
|
24
|
+
export let withGroup = false;
|
|
25
|
+
export let multiple = false;
|
|
26
|
+
export let clearable = true;
|
|
27
|
+
export let required = false;
|
|
28
|
+
export let onChange: (value: ItemProps | ItemProps[]) => void = () => {};
|
|
29
|
+
|
|
30
|
+
const groupBy = withGroup ? (item: ItemProps) => item.group : undefined;
|
|
31
|
+
</script>
|
|
32
|
+
|
|
33
|
+
<SvelteSelect
|
|
34
|
+
{items}
|
|
35
|
+
{searchable}
|
|
36
|
+
{placeholder}
|
|
37
|
+
{disabled}
|
|
38
|
+
{id}
|
|
39
|
+
{hasError}
|
|
40
|
+
{multiple}
|
|
41
|
+
{clearable}
|
|
42
|
+
{groupBy}
|
|
43
|
+
on:select={(e) => dispatch('change', e.detail)}
|
|
44
|
+
on:input={(e) => dispatch('input', e.detail)}
|
|
45
|
+
on:change={(e) => {
|
|
46
|
+
dispatch('change', e.detail);
|
|
47
|
+
onChange(e.detail);
|
|
48
|
+
}}
|
|
49
|
+
class={`select ${className}`}
|
|
50
|
+
{required}
|
|
51
|
+
bind:value
|
|
52
|
+
bind:listOpen
|
|
53
|
+
showChevron={true}
|
|
54
|
+
floatingConfig={{
|
|
55
|
+
placement: 'bottom'
|
|
56
|
+
}}
|
|
57
|
+
createGroupHeaderItem={(groupValue) => {
|
|
58
|
+
return {
|
|
59
|
+
value: groupValue,
|
|
60
|
+
label: groupValue
|
|
61
|
+
};
|
|
62
|
+
}}
|
|
63
|
+
--group-title-border-style="1px solid black"
|
|
64
|
+
--group-item-padding-left="1rem"
|
|
65
|
+
--item-height="100%"
|
|
66
|
+
--group-title-color={textColor['secondary']}
|
|
67
|
+
--group-title-font-size="0.75rem"
|
|
68
|
+
--group-title-font-weight="400"
|
|
69
|
+
--group-title-text-transform="none"
|
|
70
|
+
--placeholder-color={textColor['secondary']}
|
|
71
|
+
--item-is-active-bg={backgroundColor['accent']}
|
|
72
|
+
--item-is-active-color={textColor['primary']}
|
|
73
|
+
--item-hover-bg={backgroundColor['neutral']}
|
|
74
|
+
--border="0"
|
|
75
|
+
--border-hover="0"
|
|
76
|
+
--border-focused="0"
|
|
77
|
+
>
|
|
78
|
+
<div slot="chevron-icon" class="">
|
|
79
|
+
<CaretDown weight="bold" size="1rem" />
|
|
80
|
+
</div>
|
|
81
|
+
|
|
82
|
+
<div slot="selection" let:selection>
|
|
83
|
+
{#if $$slots['custom-selection']}
|
|
84
|
+
<slot name="custom-selection" {selection} />
|
|
85
|
+
{:else}
|
|
86
|
+
{selection.label}
|
|
87
|
+
{/if}
|
|
88
|
+
</div>
|
|
89
|
+
|
|
90
|
+
<div slot="clear-icon">
|
|
91
|
+
<X weight="bold" size="1rem" />
|
|
92
|
+
</div>
|
|
93
|
+
|
|
94
|
+
<div slot="item" let:item let:index class="flex">
|
|
95
|
+
<div class="relative flex flex-1 justify-between">
|
|
96
|
+
{#if $$slots['custom-item']}
|
|
97
|
+
<slot name="custom-item" {item} {index} />
|
|
98
|
+
{:else}
|
|
99
|
+
<div class="flex h-full flex-1 items-center text-ellipsis whitespace-nowrap">
|
|
100
|
+
<p>{item.label}</p>
|
|
101
|
+
</div>
|
|
102
|
+
{/if}
|
|
103
|
+
</div>
|
|
104
|
+
<slot />
|
|
105
|
+
</div></SvelteSelect
|
|
106
|
+
>
|
|
107
|
+
|
|
108
|
+
<style>
|
|
109
|
+
:global(.svelte-select.focused) {
|
|
110
|
+
outline: 1px solid var(--colors-gray-1) !important;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
:global(.svelte-select) {
|
|
114
|
+
box-shadow: 0px 4px 17px 0px rgba(0, 0, 0, 0.02);
|
|
115
|
+
width: 100%;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
:global(.svelte-select .item.active) {
|
|
119
|
+
background-color: #5750ee1A;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
:global(.svelte-select .list-item:not(:first-of-type) > .list-group-title) {
|
|
123
|
+
padding-top: 0.5rem;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
:global(.svelte-select .list-item:not(:first-of-type) > .list-group-title)::before {
|
|
127
|
+
position: relative;
|
|
128
|
+
bottom: 0px;
|
|
129
|
+
left: 0px;
|
|
130
|
+
clear: both;
|
|
131
|
+
display: block;
|
|
132
|
+
border-top-width: 1px;
|
|
133
|
+
border-color: #12192A26;
|
|
134
|
+
--tw-content: '';
|
|
135
|
+
content: var(--tw-content);
|
|
136
|
+
}
|
|
137
|
+
</style>
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import type { ItemProps } from '.';
|
|
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: Props & {
|
|
7
|
+
$$events?: Events;
|
|
8
|
+
$$slots?: Slots;
|
|
9
|
+
}): Exports & {
|
|
10
|
+
$set?: any;
|
|
11
|
+
$on?: any;
|
|
12
|
+
};
|
|
13
|
+
z_$$bindings?: Bindings;
|
|
14
|
+
}
|
|
15
|
+
type $$__sveltets_2_PropsWithChildren<Props, Slots> = Props & (Slots extends {
|
|
16
|
+
default: any;
|
|
17
|
+
} ? Props extends Record<string, never> ? any : {
|
|
18
|
+
children?: any;
|
|
19
|
+
} : {});
|
|
20
|
+
declare const Select: $$__sveltets_2_IsomorphicComponent<$$__sveltets_2_PropsWithChildren<{
|
|
21
|
+
class?: string;
|
|
22
|
+
items?: ItemProps[];
|
|
23
|
+
id?: string | undefined;
|
|
24
|
+
value?: ItemProps | ItemProps[] | null;
|
|
25
|
+
searchable?: boolean;
|
|
26
|
+
listOpen?: boolean;
|
|
27
|
+
placeholder?: string | undefined;
|
|
28
|
+
disabled?: boolean;
|
|
29
|
+
hasError?: boolean;
|
|
30
|
+
withGroup?: boolean;
|
|
31
|
+
multiple?: boolean;
|
|
32
|
+
clearable?: boolean;
|
|
33
|
+
required?: boolean;
|
|
34
|
+
onChange?: (value: ItemProps | ItemProps[]) => void;
|
|
35
|
+
}, {
|
|
36
|
+
'custom-selection': {
|
|
37
|
+
selection: any;
|
|
38
|
+
};
|
|
39
|
+
'custom-item': {
|
|
40
|
+
item: any;
|
|
41
|
+
index: any;
|
|
42
|
+
};
|
|
43
|
+
default: {};
|
|
44
|
+
}>, {
|
|
45
|
+
change: CustomEvent<any>;
|
|
46
|
+
input: CustomEvent<any>;
|
|
47
|
+
} & {
|
|
48
|
+
[evt: string]: CustomEvent<any>;
|
|
49
|
+
}, {
|
|
50
|
+
'custom-selection': {
|
|
51
|
+
selection: any;
|
|
52
|
+
};
|
|
53
|
+
'custom-item': {
|
|
54
|
+
item: any;
|
|
55
|
+
index: any;
|
|
56
|
+
};
|
|
57
|
+
default: {};
|
|
58
|
+
}, {}, string>;
|
|
59
|
+
type Select = InstanceType<typeof Select>;
|
|
60
|
+
export default Select;
|