@reshape-biotech/design-system 1.2.6 → 1.2.7
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 +3 -1
- package/dist/app.css +97 -97
- package/dist/components/activity/Activity.stories.svelte +104 -104
- package/dist/components/activity/Activity.svelte +112 -112
- package/dist/components/avatar/Avatar.stories.svelte +23 -23
- package/dist/components/avatar/Avatar.svelte +54 -54
- package/dist/components/banner/Banner.stories.svelte +105 -105
- package/dist/components/banner/Banner.svelte +42 -42
- package/dist/components/button/Button.stories.svelte +61 -61
- package/dist/components/button/Button.svelte +95 -95
- package/dist/components/card/Card.stories.svelte +112 -112
- package/dist/components/card/Card.svelte +18 -18
- package/dist/components/checkbox/Checkbox.stories.svelte +8 -8
- package/dist/components/checkbox/Checkbox.svelte +17 -17
- package/dist/components/collapsible/Collapsible.stories.svelte +26 -26
- package/dist/components/collapsible/components/collapsible-content.svelte +20 -20
- package/dist/components/collapsible/components/collapsible-trigger.svelte +12 -12
- package/dist/components/combobox/Combobox.stories.svelte +412 -412
- package/dist/components/combobox/components/combobox-add.svelte +8 -8
- package/dist/components/combobox/components/combobox-content.svelte +39 -39
- package/dist/components/combobox/components/combobox-indicator.svelte +1 -1
- package/dist/components/datepicker/DatePicker.stories.svelte +196 -196
- package/dist/components/datepicker/DatePicker.svelte +173 -173
- package/dist/components/divider/Divider.stories.svelte +7 -7
- package/dist/components/divider/Divider.svelte +9 -9
- package/dist/components/drawer/Drawer.stories.svelte +51 -51
- package/dist/components/drawer/Drawer.svelte +33 -33
- package/dist/components/drawer/DrawerLabel.svelte +10 -10
- package/dist/components/dropdown/Dropdown.stories.svelte +210 -210
- package/dist/components/dropdown/Dropdown.svelte +57 -57
- package/dist/components/dropdown/components/DropdownContent.svelte +16 -16
- package/dist/components/dropdown/components/DropdownMenu.svelte +10 -10
- package/dist/components/dropdown/components/DropdownTrigger.svelte +37 -37
- package/dist/components/dropdown/components/OutlinedButton.svelte +9 -9
- package/dist/components/empty-content/EmptyContent.stories.svelte +38 -38
- package/dist/components/empty-content/EmptyContent.svelte +12 -12
- package/dist/components/graphs/bar-chart/BarChart.stories.svelte +91 -91
- package/dist/components/graphs/bar-chart/BarChart.svelte +147 -147
- package/dist/components/graphs/bar-chart/StackedBarChart.stories.svelte +57 -57
- package/dist/components/graphs/bar-chart/StackedBarChart.svelte +198 -199
- package/dist/components/graphs/chart/Chart.stories.svelte +96 -96
- package/dist/components/graphs/chart/Chart.svelte +207 -207
- package/dist/components/graphs/line/LineChart.stories.svelte +138 -138
- package/dist/components/graphs/line/LineChart.svelte +140 -142
- package/dist/components/graphs/matrix/Matrix.stories.svelte +117 -117
- package/dist/components/graphs/matrix/Matrix.svelte +141 -141
- package/dist/components/graphs/multiline/MultiLineChart.stories.svelte +168 -168
- package/dist/components/graphs/multiline/MultiLineChart.svelte +236 -236
- package/dist/components/graphs/scatterplot/Scatterplot.stories.svelte +84 -84
- package/dist/components/graphs/scatterplot/Scatterplot.svelte +302 -302
- package/dist/components/graphs/utils/duration.d.ts +1 -0
- package/dist/components/graphs/utils/duration.js +33 -0
- package/dist/components/graphs/utils/tooltipFormatter.js +1 -1
- package/dist/components/icon-button/IconButton.stories.svelte +64 -64
- package/dist/components/icon-button/IconButton.svelte +88 -88
- package/dist/components/icons/AnalysisIcon.stories.svelte +18 -18
- package/dist/components/icons/AnalysisIcon.svelte +96 -96
- package/dist/components/icons/Icon.stories.svelte +111 -111
- package/dist/components/icons/Icon.svelte +17 -17
- package/dist/components/icons/PrincipalIcon.svelte +59 -59
- package/dist/components/icons/custom/Halo.svelte +31 -31
- package/dist/components/icons/custom/Well.svelte +27 -27
- package/dist/components/icons/index.js +1 -1
- package/dist/components/image/Image.svelte +42 -42
- package/dist/components/input/Input.stories.svelte +55 -55
- package/dist/components/input/Input.svelte +121 -121
- package/dist/components/label/Label.stories.svelte +18 -18
- package/dist/components/label/Label.svelte +11 -11
- package/dist/components/list/List.stories.svelte +84 -84
- package/dist/components/list/List.svelte +20 -20
- package/dist/components/logo/Logo.stories.svelte +15 -15
- package/dist/components/logo/Logo.svelte +30 -30
- package/dist/components/manual-cfu-counter/ManualCFUCounter.stories.svelte +102 -102
- package/dist/components/manual-cfu-counter/ManualCFUCounter.svelte +557 -557
- package/dist/components/manual-cfu-counter/test/ManualCFUCounterTestWrapper.svelte +11 -11
- package/dist/components/markdown/Markdown.stories.svelte +10 -10
- package/dist/components/markdown/Markdown.svelte +6 -6
- package/dist/components/modal/Modal.stories.svelte +29 -29
- package/dist/components/modal/Modal.svelte +71 -71
- package/dist/components/multi-cfu-counter/MultiCFUCounter.stories.svelte +201 -201
- package/dist/components/multi-cfu-counter/MultiCFUCounter.svelte +606 -606
- package/dist/components/multi-cfu-counter/test/MultiCFUCounterTestWrapper.svelte +17 -17
- package/dist/components/notification-popup/NotificationPopup.stories.svelte +18 -18
- package/dist/components/notification-popup/NotificationPopup.svelte +26 -26
- package/dist/components/notifications/Notifications.stories.svelte +101 -101
- package/dist/components/notifications/Notifications.svelte +9 -9
- package/dist/components/pill/Pill.stories.svelte +8 -8
- package/dist/components/pill/Pill.svelte +27 -27
- package/dist/components/progress-circle/ProgressCircle.stories.svelte +8 -8
- package/dist/components/progress-circle/ProgressCircle.svelte +54 -54
- package/dist/components/required-status-indicator/RequiredStatusIndicator.stories.svelte +18 -18
- package/dist/components/required-status-indicator/RequiredStatusIndicator.svelte +14 -14
- package/dist/components/segmented-control-buttons/ControlButton.svelte +36 -36
- package/dist/components/segmented-control-buttons/SegmentedControlButtons.stories.svelte +35 -35
- package/dist/components/segmented-control-buttons/SegmentedControlButtons.svelte +13 -13
- package/dist/components/select/Select.stories.svelte +77 -77
- package/dist/components/select/Select.svelte +114 -114
- package/dist/components/select-new/Select.stories.svelte +188 -188
- package/dist/components/select-new/components/Group.svelte +17 -17
- package/dist/components/select-new/components/MultiSelectTrigger.svelte +57 -57
- package/dist/components/select-new/components/SelectContent.svelte +22 -22
- package/dist/components/select-new/components/SelectGroupHeading.svelte +10 -10
- package/dist/components/select-new/components/SelectItem.svelte +25 -25
- package/dist/components/select-new/components/SelectTrigger.svelte +38 -38
- package/dist/components/sjsf-wrappers/SjsfNumberInputWrapper.svelte +76 -76
- package/dist/components/sjsf-wrappers/SjsfNumberInputWrapper.svelte.d.ts +1 -1
- package/dist/components/sjsf-wrappers/SjsfTextInputWrapper.svelte +53 -53
- package/dist/components/sjsf-wrappers/SjsfTextInputWrapper.svelte.d.ts +1 -1
- package/dist/components/sjsf-wrappers/sjsfCustomTheme.js +1 -1
- package/dist/components/skeleton-loader/SkeletonLoader.stories.svelte +32 -32
- package/dist/components/skeleton-loader/SkeletonLoader.svelte +10 -10
- package/dist/components/skeleton-loader/StatcardSkeleton.svelte +9 -9
- package/dist/components/skeleton-loader/components/Skeleton.svelte +7 -7
- package/dist/components/skeleton-loader/components/SkeletonImage.svelte +12 -12
- package/dist/components/slider/Slider.stories.svelte +23 -23
- package/dist/components/slider/Slider.svelte +107 -107
- package/dist/components/spinner/Spinner.stories.svelte +8 -8
- package/dist/components/spinner/Spinner.svelte +18 -18
- package/dist/components/stat-card/StatCard.stories.svelte +26 -26
- package/dist/components/stat-card/StatCard.svelte +128 -128
- package/dist/components/status-badge/StatusBadge.stories.svelte +365 -365
- package/dist/components/status-badge/StatusBadge.svelte +54 -54
- package/dist/components/stepper/Stepper.stories.svelte +219 -219
- package/dist/components/stepper/components/stepper-root.svelte +12 -12
- package/dist/components/stepper/components/stepper-step.svelte +83 -83
- package/dist/components/table/Table.stories.svelte +87 -87
- package/dist/components/table/Table.svelte +32 -32
- package/dist/components/table/components/TBody.svelte +7 -7
- package/dist/components/table/components/THead.svelte +7 -7
- package/dist/components/table/components/Td.svelte +8 -8
- package/dist/components/table/components/Th.svelte +8 -8
- package/dist/components/table/components/Tr.svelte +11 -11
- package/dist/components/tabs/Tabs.stories.svelte +20 -20
- package/dist/components/tabs/Tabs.svelte +8 -8
- package/dist/components/tabs/components/Content.svelte +8 -8
- package/dist/components/tabs/components/Tab.svelte +14 -14
- package/dist/components/tabs/components/Tabs.svelte +7 -7
- package/dist/components/tag/Tag.stories.svelte +57 -57
- package/dist/components/tag/Tag.svelte +95 -95
- package/dist/components/textarea/Textarea.stories.svelte +70 -70
- package/dist/components/textarea/Textarea.svelte +76 -76
- package/dist/components/toast/Toast.stories.svelte +204 -204
- package/dist/components/toast/Toast.svelte +53 -53
- package/dist/components/toggle/Toggle.stories.svelte +9 -9
- package/dist/components/toggle/Toggle.svelte +53 -53
- package/dist/components/toggle-icon-button/ToggleIconButton.stories.svelte +152 -152
- package/dist/components/toggle-icon-button/ToggleIconButton.svelte +99 -99
- package/dist/components/tooltip/Tooltip.stories.svelte +105 -105
- package/dist/components/tooltip/Tooltip.svelte +26 -26
- package/dist/fonts/index.js +1 -1
- package/dist/notifications.d.ts +1 -4
- package/dist/notifications.js +1 -1
- package/dist/tailwind-safelist.js +406 -406
- package/dist/tailwind.preset.js +10 -10
- package/dist/tokens/colors.js +18 -18
- package/dist/tokens/typography.js +6 -6
- package/dist/tokens.js +19 -19
- package/dist/types/fonts.d.ts +2 -2
- package/package.json +199 -198
|
@@ -1,127 +1,127 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
import { Icon, type IconName, type IconColor, type BackgroundClass } from '../icons';
|
|
3
|
+
import { DateTime } from 'luxon';
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
5
|
+
type ActivityIcon =
|
|
6
|
+
| 'add'
|
|
7
|
+
| 'capture'
|
|
8
|
+
| 'delete'
|
|
9
|
+
| 'edit'
|
|
10
|
+
| 'failed'
|
|
11
|
+
| 'pause'
|
|
12
|
+
| 'start'
|
|
13
|
+
| 'stop'
|
|
14
|
+
| 'warning'
|
|
15
|
+
| 'success'
|
|
16
|
+
| 'export-succeeded'
|
|
17
|
+
| 'export-failed';
|
|
18
18
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
19
|
+
type Activity = {
|
|
20
|
+
activity_type?: string;
|
|
21
|
+
icon: ActivityIcon;
|
|
22
|
+
label: string;
|
|
23
|
+
timestamp: string;
|
|
24
|
+
author?: string | null;
|
|
25
|
+
field?: string | null;
|
|
26
|
+
previous_value?: string | null;
|
|
27
|
+
value?: string | null;
|
|
28
|
+
};
|
|
29
29
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
30
|
+
type Props = {
|
|
31
|
+
activity: Activity;
|
|
32
|
+
class?: string;
|
|
33
|
+
};
|
|
34
34
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
35
|
+
const ACTIVITY_ICONS: Record<ActivityIcon, IconName> = {
|
|
36
|
+
add: 'Plus',
|
|
37
|
+
capture: 'Aperture',
|
|
38
|
+
delete: 'Trash',
|
|
39
|
+
edit: 'PencilSimple',
|
|
40
|
+
failed: 'WarningCircle',
|
|
41
|
+
pause: 'Pause',
|
|
42
|
+
start: 'Play',
|
|
43
|
+
stop: 'Stop',
|
|
44
|
+
warning: 'Warning',
|
|
45
|
+
success: 'Check',
|
|
46
|
+
'export-succeeded': 'DownloadSimple',
|
|
47
|
+
'export-failed': 'DownloadSimple',
|
|
48
|
+
};
|
|
49
49
|
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
50
|
+
const ACTIVITY_COLOR: Record<ActivityIcon, IconColor> = {
|
|
51
|
+
add: 'icon-secondary',
|
|
52
|
+
capture: 'icon-secondary',
|
|
53
|
+
delete: 'icon-danger',
|
|
54
|
+
edit: 'icon-secondary',
|
|
55
|
+
failed: 'icon-danger',
|
|
56
|
+
pause: 'icon-secondary',
|
|
57
|
+
start: 'icon-secondary',
|
|
58
|
+
stop: 'icon-secondary',
|
|
59
|
+
warning: 'icon-warning',
|
|
60
|
+
success: 'icon-secondary',
|
|
61
|
+
'export-succeeded': 'icon-secondary',
|
|
62
|
+
'export-failed': 'icon-danger',
|
|
63
|
+
};
|
|
64
64
|
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
65
|
+
const ACTIVITY_BACKGROUND: Record<ActivityIcon, BackgroundClass> = {
|
|
66
|
+
add: 'bg-neutral',
|
|
67
|
+
capture: 'bg-neutral',
|
|
68
|
+
delete: 'bg-neutral',
|
|
69
|
+
edit: 'bg-neutral',
|
|
70
|
+
failed: 'bg-danger',
|
|
71
|
+
pause: 'bg-neutral',
|
|
72
|
+
start: 'bg-neutral',
|
|
73
|
+
stop: 'bg-neutral',
|
|
74
|
+
warning: 'bg-warning',
|
|
75
|
+
success: 'bg-neutral',
|
|
76
|
+
'export-succeeded': 'bg-neutral',
|
|
77
|
+
'export-failed': 'bg-danger',
|
|
78
|
+
};
|
|
79
79
|
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
80
|
+
function formatDateTime(timestamp: string): string {
|
|
81
|
+
try {
|
|
82
|
+
const dateTime = DateTime.fromISO(timestamp);
|
|
83
83
|
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
84
|
+
if (dateTime.isValid) {
|
|
85
|
+
return dateTime.toLocaleString(DateTime.DATETIME_MED, {
|
|
86
|
+
locale: navigator.language === 'en-US' ? 'en-US' : 'en-GB',
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
89
|
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
90
|
+
return timestamp;
|
|
91
|
+
} catch (err) {
|
|
92
|
+
return timestamp;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
95
|
|
|
96
|
-
|
|
96
|
+
let { class: className = '', activity }: Props = $props();
|
|
97
97
|
</script>
|
|
98
98
|
|
|
99
99
|
<div class={`group flex items-stretch gap-3 ${className}`}>
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
100
|
+
<div class="flex min-h-12 flex-col items-center gap-1.5">
|
|
101
|
+
<div class="w-0.5 grow bg-neutral group-first:invisible"></div>
|
|
102
|
+
<div
|
|
103
|
+
class="flex h-5 w-5 shrink-0 items-center justify-center rounded p-0.5 text-secondary {ACTIVITY_BACKGROUND[
|
|
104
|
+
activity.icon
|
|
105
|
+
]}"
|
|
106
|
+
>
|
|
107
|
+
<Icon iconName={ACTIVITY_ICONS[activity.icon]} color={ACTIVITY_COLOR[activity.icon]} />
|
|
108
|
+
</div>
|
|
109
|
+
<div class="w-0.5 grow bg-neutral group-last:invisible"></div>
|
|
110
|
+
</div>
|
|
111
|
+
<div class="flex items-center py-4">
|
|
112
|
+
<div class="text-secondary">
|
|
113
|
+
<span class="text-primary">{activity.label}</span>
|
|
114
|
+
{#if activity.previous_value}
|
|
115
|
+
<span> from <span class="text-primary">{activity.previous_value}</span></span>
|
|
116
|
+
{/if}
|
|
117
|
+
{#if activity.value}
|
|
118
|
+
<span> to <span class="text-primary">{activity.value}</span></span>
|
|
119
|
+
{/if}
|
|
120
|
+
<span class="px-0.5">⸱</span>
|
|
121
|
+
<span>{formatDateTime(activity.timestamp)}</span>
|
|
122
|
+
{#if activity.author}
|
|
123
|
+
<span> by <span class="text-primary">{activity.author}</span></span>
|
|
124
|
+
{/if}
|
|
125
|
+
</div>
|
|
126
|
+
</div>
|
|
127
127
|
</div>
|
|
@@ -1,27 +1,27 @@
|
|
|
1
1
|
<script module lang="ts">
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
2
|
+
import { defineMeta } from '@storybook/addon-svelte-csf';
|
|
3
|
+
import Avatar from './Avatar.svelte';
|
|
4
|
+
|
|
5
|
+
const { Story } = defineMeta({
|
|
6
|
+
component: Avatar,
|
|
7
|
+
title: 'Design System/Avatar',
|
|
8
|
+
tags: ['autodocs'],
|
|
9
|
+
parameters: {
|
|
10
|
+
design: {
|
|
11
|
+
type: 'figma',
|
|
12
|
+
url: 'https://www.figma.com/design/VHTMNdy8PAXAMx43edNZGW/%F0%9F%92%A0--Reshape-Design-System%3A-V1?node-id=9-9253&t=sCuBI8dX6K6NjNR6-0',
|
|
13
|
+
},
|
|
14
|
+
},
|
|
15
|
+
});
|
|
16
16
|
</script>
|
|
17
17
|
|
|
18
18
|
<Story name="Default" args={{ name: 'John Doe' }} />
|
|
19
19
|
|
|
20
20
|
<Story name="Sizes" asChild>
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
21
|
+
<div class="flex gap-2">
|
|
22
|
+
<Avatar name="John Doe" size="sm" />
|
|
23
|
+
<Avatar name="John Doe" size="md" />
|
|
24
|
+
</div>
|
|
25
25
|
</Story>
|
|
26
26
|
|
|
27
27
|
<Story name="Email" args={{ name: 'john.doe@example.com' }} />
|
|
@@ -33,9 +33,9 @@
|
|
|
33
33
|
<Story name="Without Tooltip" args={{ showTooltip: false }} />
|
|
34
34
|
|
|
35
35
|
<Story name="Multiple Avatars" asChild>
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
36
|
+
<div class="flex gap-2">
|
|
37
|
+
<Avatar name="John Doe" />
|
|
38
|
+
<Avatar name="Jane Smith" />
|
|
39
|
+
<Avatar name="Alex Johnson" />
|
|
40
|
+
</div>
|
|
41
41
|
</Story>
|
|
@@ -1,63 +1,63 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
2
|
+
import Tooltip from '../tooltip/Tooltip.svelte';
|
|
3
|
+
export interface AvatarProps {
|
|
4
|
+
name: string | null | undefined;
|
|
5
|
+
size?: 'sm' | 'md';
|
|
6
|
+
showTooltip?: boolean;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
let { name, size = 'md', showTooltip = true }: AvatarProps = $props();
|
|
10
|
+
const sizes = {
|
|
11
|
+
sm: 'h-6 w-6 min-w-6 text-xxs font-semibold tracking-wide',
|
|
12
|
+
md: 'h-8 w-8 min-w-8 text-xs font-semibold tracking-wide',
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
let sizeClassName = $derived(sizes[size]);
|
|
16
|
+
|
|
17
|
+
const getInitials = (name: string | null | undefined) => {
|
|
18
|
+
if (!name) {
|
|
19
|
+
return '?'; // You can use any default value here
|
|
20
|
+
}
|
|
21
|
+
// Check if the name is an email
|
|
22
|
+
const isEmail = name.includes('@');
|
|
23
|
+
if (isEmail) {
|
|
24
|
+
return name.slice(0, 2).toUpperCase();
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
// Split the name by space
|
|
28
|
+
const splitName = name.split(' ');
|
|
29
|
+
|
|
30
|
+
// Check if the name is a single word or already initials
|
|
31
|
+
if (splitName.length === 1 || (splitName.length === 1 && splitName[0].length <= 2)) {
|
|
32
|
+
return name.slice(0, 2).toUpperCase();
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
// If the name is multiple words, use the first letter of the first and last word
|
|
36
|
+
const firstInitial = splitName[0][0];
|
|
37
|
+
const lastInitial = splitName[splitName.length - 1][0];
|
|
38
|
+
|
|
39
|
+
return (firstInitial + lastInitial).toUpperCase();
|
|
40
|
+
};
|
|
41
|
+
let initials = $derived(getInitials(name));
|
|
42
42
|
</script>
|
|
43
43
|
|
|
44
44
|
{#snippet avatar()}
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
45
|
+
<div
|
|
46
|
+
class="{sizeClassName} flex items-center justify-center rounded-full border border-static bg-accent text-accent"
|
|
47
|
+
>
|
|
48
|
+
{initials}
|
|
49
|
+
</div>
|
|
50
50
|
{/snippet}
|
|
51
51
|
|
|
52
52
|
{#if showTooltip}
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
53
|
+
<Tooltip>
|
|
54
|
+
{#snippet trigger()}
|
|
55
|
+
{@render avatar()}
|
|
56
|
+
{/snippet}
|
|
57
|
+
{#snippet content()}
|
|
58
|
+
<span>{name ? name : 'Unknown'}</span>
|
|
59
|
+
{/snippet}
|
|
60
|
+
</Tooltip>
|
|
61
61
|
{:else}
|
|
62
|
-
|
|
62
|
+
{@render avatar()}
|
|
63
63
|
{/if}
|
|
@@ -1,129 +1,129 @@
|
|
|
1
1
|
<script module lang="ts">
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
2
|
+
import { Icon } from '../icons';
|
|
3
|
+
import Banner from './Banner.svelte';
|
|
4
|
+
import Button from '../button/Button.svelte';
|
|
5
|
+
import { defineMeta } from '@storybook/addon-svelte-csf';
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
7
|
+
const { Story } = defineMeta({
|
|
8
|
+
component: Banner,
|
|
9
|
+
title: 'Design System/Banner',
|
|
10
|
+
tags: ['autodocs'],
|
|
11
|
+
});
|
|
12
12
|
|
|
13
|
-
|
|
13
|
+
let showBanner = $state(true);
|
|
14
14
|
</script>
|
|
15
15
|
|
|
16
16
|
<Story name="Well finding warning" asChild>
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
17
|
+
<Banner type="warning" closable={false}>
|
|
18
|
+
{#snippet icon()}
|
|
19
|
+
<Icon size={20} iconName="Warning" color="warning" weight="bold" />
|
|
20
|
+
{/snippet}
|
|
21
|
+
{#snippet content()}
|
|
22
|
+
Our system couldn't find the wells in some plates. Analysis can't be done. For more help, <a
|
|
23
|
+
href="https://docs.reshapebiotech.com/reshape-biotech-knowledgebase/general-info/troubleshooting/well-detection"
|
|
24
|
+
>check our documentation</a
|
|
25
|
+
>
|
|
26
|
+
or <a href="mailto:support@reshapebiotech.com">contact us</a>.
|
|
27
|
+
{/snippet}
|
|
28
|
+
</Banner>
|
|
29
29
|
</Story>
|
|
30
30
|
|
|
31
31
|
<Story name="No icon" asChild>
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
32
|
+
<Banner type="success">
|
|
33
|
+
{#snippet content()}
|
|
34
|
+
This banner has no icon.
|
|
35
|
+
{/snippet}
|
|
36
|
+
</Banner>
|
|
37
37
|
</Story>
|
|
38
38
|
|
|
39
39
|
<Story name="No toggle" asChild>
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
40
|
+
<Banner type="progress" closable={false}>
|
|
41
|
+
{#snippet icon()}
|
|
42
|
+
<Icon size={20} iconName="Info" color="icon-blue" weight="bold" />
|
|
43
|
+
{/snippet}
|
|
44
|
+
{#snippet content()}
|
|
45
|
+
This banner has no toggle.
|
|
46
|
+
{/snippet}
|
|
47
|
+
</Banner>
|
|
48
48
|
</Story>
|
|
49
49
|
|
|
50
50
|
<Story name="Toggle back on" asChild>
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
51
|
+
<div class="h-28">
|
|
52
|
+
<Button onClick={() => (showBanner = true)} disabled={showBanner}>Toggle banner back on</Button>
|
|
53
|
+
<br />
|
|
54
|
+
<br />
|
|
55
55
|
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
56
|
+
<Banner type="error" bind:show={showBanner}>
|
|
57
|
+
{#snippet icon()}
|
|
58
|
+
<Icon size={20} iconName="Info" color="danger" weight="bold" />
|
|
59
|
+
{/snippet}
|
|
60
|
+
{#snippet content()}
|
|
61
|
+
This banner can be toggled off with the "x" to the right and back on with the button above.
|
|
62
|
+
{/snippet}
|
|
63
|
+
</Banner>
|
|
64
|
+
</div>
|
|
65
65
|
</Story>
|
|
66
66
|
|
|
67
67
|
<Story name="Type variations" asChild>
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
68
|
+
<div class="space-y-4">
|
|
69
|
+
<div class="space-y-2">
|
|
70
|
+
<h4>Neutral</h4>
|
|
71
|
+
<Banner type="neutral">
|
|
72
|
+
{#snippet icon()}
|
|
73
|
+
<Icon size={20} iconName="Info" weight="bold" />
|
|
74
|
+
{/snippet}
|
|
75
|
+
{#snippet content()}
|
|
76
|
+
This is a "neutral" banner.
|
|
77
|
+
{/snippet}
|
|
78
|
+
</Banner>
|
|
79
|
+
</div>
|
|
80
80
|
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
81
|
+
<div class="space-y-2">
|
|
82
|
+
<h4>Success</h4>
|
|
83
|
+
<Banner type="success">
|
|
84
|
+
{#snippet icon()}
|
|
85
|
+
<Icon size={20} iconName="CheckCircle" color="icon-success" weight="bold" />
|
|
86
|
+
{/snippet}
|
|
87
|
+
{#snippet content()}
|
|
88
|
+
This is a "success" banner.
|
|
89
|
+
{/snippet}
|
|
90
|
+
</Banner>
|
|
91
|
+
</div>
|
|
92
92
|
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
93
|
+
<div class="space-y-2">
|
|
94
|
+
<h4>Progress</h4>
|
|
95
|
+
<Banner type="progress">
|
|
96
|
+
{#snippet icon()}
|
|
97
|
+
<Icon size={20} iconName="Circle" color="icon-blue" weight="bold" />
|
|
98
|
+
{/snippet}
|
|
99
|
+
{#snippet content()}
|
|
100
|
+
This is a "progress" banner.
|
|
101
|
+
{/snippet}
|
|
102
|
+
</Banner>
|
|
103
|
+
</div>
|
|
104
104
|
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
105
|
+
<div class="space-y-2">
|
|
106
|
+
<h4>Warning</h4>
|
|
107
|
+
<Banner type="warning">
|
|
108
|
+
{#snippet icon()}
|
|
109
|
+
<Icon size={20} iconName="Warning" color="icon-warning" weight="bold" />
|
|
110
|
+
{/snippet}
|
|
111
|
+
{#snippet content()}
|
|
112
|
+
This is a "warning" banner.
|
|
113
|
+
{/snippet}
|
|
114
|
+
</Banner>
|
|
115
|
+
</div>
|
|
116
116
|
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
117
|
+
<div class="space-y-2">
|
|
118
|
+
<h4>Error</h4>
|
|
119
|
+
<Banner type="error">
|
|
120
|
+
{#snippet icon()}
|
|
121
|
+
<Icon size={20} iconName="WarningCircle" color="icon-danger" weight="bold" />
|
|
122
|
+
{/snippet}
|
|
123
|
+
{#snippet content()}
|
|
124
|
+
This is an "error" banner.
|
|
125
|
+
{/snippet}
|
|
126
|
+
</Banner>
|
|
127
|
+
</div>
|
|
128
|
+
</div>
|
|
129
129
|
</Story>
|