@reshape-biotech/design-system 2.6.5 → 2.7.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/activity/Activity.stories.svelte +7 -2
- package/dist/components/activity/Activity.svelte +6 -48
- package/dist/components/activity/Activity.svelte.d.ts +2 -2
- package/dist/components/activity/ActivityIcon.svelte +75 -0
- package/dist/components/activity/ActivityIcon.svelte.d.ts +10 -0
- package/dist/components/banner/Banner.stories.svelte +46 -9
- package/dist/components/banner/Banner.svelte +3 -2
- package/dist/components/checkbox/Checkbox.svelte +5 -3
- package/dist/components/collapsible/components/collapsible-trigger.svelte +3 -2
- package/dist/components/combobox/Combobox.stories.svelte +18 -4
- package/dist/components/combobox/components/combobox-add.svelte +3 -2
- package/dist/components/combobox/components/combobox-content.svelte +5 -3
- package/dist/components/combobox/components/combobox-indicator.svelte +3 -2
- package/dist/components/datepicker/DatePicker.stories.svelte +12 -3
- package/dist/components/datepicker/DatePicker.svelte +5 -3
- package/dist/components/drawer/components/drawer-content.svelte +3 -2
- package/dist/components/empty-content/EmptyContent.stories.svelte +13 -15
- package/dist/components/graphs/bar-chart/BarChart.svelte +1 -1
- package/dist/components/graphs/bar-chart/BarChart.svelte.d.ts +1 -1
- package/dist/components/graphs/bar-chart/StackedBarChart.svelte +1 -2
- package/dist/components/graphs/bar-chart/StackedBarChart.svelte.d.ts +1 -1
- package/dist/components/graphs/chart/Chart.svelte +16 -7
- package/dist/components/graphs/chart/Chart.svelte.d.ts +1 -1
- package/dist/components/graphs/line/LineChart.stories.svelte +1 -1
- package/dist/components/graphs/line/LineChart.svelte +1 -2
- package/dist/components/graphs/line/types.d.ts +1 -1
- package/dist/components/graphs/multiline/MultiLineChart.stories.svelte +1 -1
- package/dist/components/graphs/multiline/MultiLineChart.svelte +7 -4
- package/dist/components/graphs/multiline/MultiLineChart.svelte.d.ts +1 -1
- package/dist/components/graphs/multiline/types.d.ts +1 -1
- package/dist/components/graphs/scatterplot/Scatterplot.svelte +8 -4
- package/dist/components/graphs/scatterplot/Scatterplot.svelte.d.ts +5 -2
- package/dist/components/graphs/utils/tooltipFormatter.d.ts +1 -1
- package/dist/components/icon-button/IconButton.stories.svelte +17 -49
- package/dist/components/icons/AnalysisIcon.svelte +10 -6
- package/dist/components/icons/Icon.stories.svelte +19 -37
- package/dist/components/icons/Icon.svelte +46 -13
- package/dist/components/icons/Icon.svelte.d.ts +21 -2
- package/dist/components/icons/PrincipalIcon.svelte +25 -5
- package/dist/components/icons/PrincipalIcon.svelte.d.ts +2 -1
- package/dist/components/icons/index.d.ts +3 -10
- package/dist/components/icons/index.js +2 -253
- package/dist/components/input/Input.svelte +3 -2
- package/dist/components/legend/Legend.stories.svelte +13 -3
- package/dist/components/list/List.stories.svelte +12 -3
- package/dist/components/manual-cfu-counter/ManualCFUCounter.svelte +6 -3
- package/dist/components/modal/Modal.stories.svelte +6 -1
- package/dist/components/modal/components/modal-content.svelte +3 -2
- package/dist/components/multi-cfu-counter/MultiCFUCounter.svelte +8 -4
- package/dist/components/notification-popup/NotificationPopup.stories.svelte +7 -2
- package/dist/components/notification-popup/NotificationPopup.svelte +3 -2
- package/dist/components/notifications/Notifications.stories.svelte +11 -11
- package/dist/components/pill/Pill.svelte +3 -2
- package/dist/components/required-status-indicator/RequiredStatusIndicator.svelte +4 -3
- package/dist/components/segmented-control-buttons/SegmentedControlButtons.stories.svelte +59 -10
- package/dist/components/select/components/MultiSelectTrigger.svelte +4 -6
- package/dist/components/select/components/MultiSelectTrigger.svelte.d.ts +0 -2
- package/dist/components/select/components/SelectContent.svelte +5 -3
- package/dist/components/select/components/SelectItem.svelte +3 -2
- package/dist/components/select/components/SelectTrigger.svelte +3 -2
- package/dist/components/slider/Slider.svelte +3 -2
- package/dist/components/stat-card/StatCard.svelte +5 -3
- package/dist/components/status-badge/StatusBadge.stories.svelte +132 -26
- package/dist/components/stepper/components/stepper-step.svelte +3 -2
- package/dist/components/table/Table.stories.svelte +7 -2
- package/dist/components/tag/Tag.stories.svelte +7 -2
- package/dist/components/toast/Toast.svelte +26 -6
- package/dist/components/toggle-icon-button/ToggleIconButton.stories.svelte +112 -23
- package/dist/echarts-config.d.ts +5 -0
- package/dist/echarts-config.js +36 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +3 -0
- package/dist/notifications.d.ts +6 -7
- package/dist/notifications.js +2 -1
- package/package.json +1 -1
|
@@ -1,6 +1,13 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
|
-
import {
|
|
3
|
-
|
|
2
|
+
import {
|
|
3
|
+
init,
|
|
4
|
+
type EChartsOption,
|
|
5
|
+
type ECharts,
|
|
6
|
+
type SeriesOption,
|
|
7
|
+
type ECElementEvent,
|
|
8
|
+
} from '../../../echarts-config';
|
|
9
|
+
import type { EChartsType } from 'echarts/core';
|
|
10
|
+
|
|
4
11
|
import { onMount, type Snippet } from 'svelte';
|
|
5
12
|
import { colors, textColor } from '../../../tokens';
|
|
6
13
|
|
|
@@ -45,7 +52,7 @@
|
|
|
45
52
|
onChartReady,
|
|
46
53
|
}: ChartProps = $props();
|
|
47
54
|
|
|
48
|
-
let chart = $state<
|
|
55
|
+
let chart = $state<EChartsType | null>(null);
|
|
49
56
|
let container: HTMLElement;
|
|
50
57
|
|
|
51
58
|
const defaultOptions: EChartsOption = {
|
|
@@ -110,15 +117,17 @@
|
|
|
110
117
|
function initChart() {
|
|
111
118
|
if (container) {
|
|
112
119
|
chart = init(container, theme, { renderer });
|
|
120
|
+
if (!chart) return;
|
|
121
|
+
|
|
113
122
|
chart.setOption(defaultOptions);
|
|
114
123
|
chart.setOption(options, { notMerge: false });
|
|
115
|
-
if (onitemclick) chart.on('click', onitemclick);
|
|
116
|
-
if (onmouseover) chart.on('mouseover', onmouseover);
|
|
117
|
-
if (onmouseout) chart.on('mouseout', onmouseout);
|
|
124
|
+
if (onitemclick) chart.on('click', (params) => onitemclick(params as ECElementEvent));
|
|
125
|
+
if (onmouseover) chart.on('mouseover', (params) => onmouseover(params as ECElementEvent));
|
|
126
|
+
if (onmouseout) chart.on('mouseout', () => onmouseout());
|
|
118
127
|
|
|
119
128
|
if (loading) chart.showLoading();
|
|
120
129
|
|
|
121
|
-
onChartReady?.(chart);
|
|
130
|
+
onChartReady?.(chart as unknown as ECharts);
|
|
122
131
|
}
|
|
123
132
|
}
|
|
124
133
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
<script module lang="ts">
|
|
2
2
|
import { defineMeta } from '@storybook/addon-svelte-csf';
|
|
3
|
-
import type { ECElementEvent } from 'echarts';
|
|
3
|
+
import type { ECElementEvent } from '../../../echarts-config';
|
|
4
4
|
import { within, userEvent } from '@storybook/test';
|
|
5
5
|
import LineChart from './LineChart.svelte';
|
|
6
6
|
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
2
|
import { textColor, borderColor, chartColor, boxShadow } from '../../../tokens';
|
|
3
3
|
import Chart from '../chart/Chart.svelte';
|
|
4
|
-
import
|
|
5
|
-
import * as echarts from 'echarts/core';
|
|
4
|
+
import echarts, { type EChartsOption } from '../../../echarts-config';
|
|
6
5
|
import { createTooltipFormatter } from '../utils/tooltipFormatter';
|
|
7
6
|
import { formattedDurationCompact } from '../utils/duration';
|
|
8
7
|
import type { LineChartProps } from './types';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
<script module lang="ts">
|
|
2
2
|
import { defineMeta } from '@storybook/addon-svelte-csf';
|
|
3
|
-
import type { ECElementEvent } from 'echarts';
|
|
3
|
+
import type { ECElementEvent } from '../../../echarts-config';
|
|
4
4
|
import MultiLineChart from './MultiLineChart.svelte';
|
|
5
5
|
|
|
6
6
|
const { Story } = defineMeta({
|
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
2
|
import { textColor, borderColor, chartColor, boxShadow } from '../../../tokens';
|
|
3
3
|
import Chart, { type GenericChartProps } from '../chart/Chart.svelte';
|
|
4
|
-
import
|
|
5
|
-
|
|
4
|
+
import echarts, {
|
|
5
|
+
type ECElementEvent,
|
|
6
|
+
type EChartsOption,
|
|
7
|
+
type LineSeriesOption,
|
|
8
|
+
} from '../../../echarts-config';
|
|
6
9
|
import { createTooltipFormatter } from '../utils/tooltipFormatter';
|
|
7
10
|
import { formattedDurationCompact } from '../utils/duration';
|
|
8
11
|
|
|
@@ -63,7 +66,7 @@
|
|
|
63
66
|
|
|
64
67
|
function handleMouseOver(params: ECElementEvent) {
|
|
65
68
|
focusedSeries = params.seriesName;
|
|
66
|
-
props.onmouseover?.(params);
|
|
69
|
+
props.onmouseover?.(params as any);
|
|
67
70
|
}
|
|
68
71
|
|
|
69
72
|
function handleMouseOut() {
|
|
@@ -257,7 +260,7 @@
|
|
|
257
260
|
...props,
|
|
258
261
|
xAxisName,
|
|
259
262
|
yAxisName,
|
|
260
|
-
onmouseover: handleMouseOver,
|
|
263
|
+
onmouseover: (params: any) => handleMouseOver(params),
|
|
261
264
|
onmouseout: handleMouseOut,
|
|
262
265
|
}}
|
|
263
266
|
/>
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
|
+
import Info from 'phosphor-svelte/lib/Info';
|
|
3
|
+
import { Icon } from '../../icons';
|
|
2
4
|
import { backgroundColor, textColor } from '../../../tokens';
|
|
3
|
-
import Icon from '../../icons/Icon.svelte';
|
|
4
5
|
import Chart, { type GenericChartProps } from '../chart/Chart.svelte';
|
|
5
6
|
import type {
|
|
6
7
|
EChartsOption,
|
|
@@ -8,6 +9,7 @@
|
|
|
8
9
|
CustomSeriesRenderItemAPI,
|
|
9
10
|
CustomSeriesRenderItemParams,
|
|
10
11
|
} from 'echarts';
|
|
12
|
+
import type { ECElementEvent } from '../../../echarts-config';
|
|
11
13
|
import Tooltip from '../../tooltip/Tooltip.svelte';
|
|
12
14
|
import type { Snippet } from 'svelte';
|
|
13
15
|
|
|
@@ -19,7 +21,7 @@
|
|
|
19
21
|
highlighted?: boolean | null;
|
|
20
22
|
};
|
|
21
23
|
|
|
22
|
-
export type ScatterPlotEchartsEvent =
|
|
24
|
+
export type ScatterPlotEchartsEvent = ECElementEvent & {
|
|
23
25
|
data: DataPoint;
|
|
24
26
|
};
|
|
25
27
|
|
|
@@ -34,10 +36,12 @@
|
|
|
34
36
|
lineData?: [[number, number], [number, number]];
|
|
35
37
|
showConfidenceBand?: boolean;
|
|
36
38
|
showLegend?: boolean;
|
|
39
|
+
onitemclick?: (params: ScatterPlotEchartsEvent) => void;
|
|
40
|
+
onmouseover?: (params: ScatterPlotEchartsEvent) => void;
|
|
37
41
|
legendItems?: LegendItem[];
|
|
38
42
|
highlightIndex?: number | null;
|
|
39
43
|
children?: Snippet;
|
|
40
|
-
} & Omit<GenericChartProps, 'timeIndex'>;
|
|
44
|
+
} & Omit<GenericChartProps, 'timeIndex' | 'onmouseover' | 'onitemclick'>;
|
|
41
45
|
|
|
42
46
|
const {
|
|
43
47
|
data,
|
|
@@ -347,7 +351,7 @@
|
|
|
347
351
|
{#if item.label === 'Error margin'}
|
|
348
352
|
<Tooltip placement="right">
|
|
349
353
|
{#snippet trigger()}
|
|
350
|
-
<Icon
|
|
354
|
+
<Icon color="icon-tertiary" icon={Info} />
|
|
351
355
|
{/snippet}
|
|
352
356
|
{#snippet content()}
|
|
353
357
|
{@render confBandTooltip()}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { type GenericChartProps } from '../chart/Chart.svelte';
|
|
2
|
+
import type { ECElementEvent } from '../../../echarts-config';
|
|
2
3
|
import type { Snippet } from 'svelte';
|
|
3
4
|
export type DataPoint = {
|
|
4
5
|
value: [number, number];
|
|
@@ -7,7 +8,7 @@ export type DataPoint = {
|
|
|
7
8
|
disagreement?: boolean | null;
|
|
8
9
|
highlighted?: boolean | null;
|
|
9
10
|
};
|
|
10
|
-
export type ScatterPlotEchartsEvent =
|
|
11
|
+
export type ScatterPlotEchartsEvent = ECElementEvent & {
|
|
11
12
|
data: DataPoint;
|
|
12
13
|
};
|
|
13
14
|
type LegendItem = {
|
|
@@ -20,10 +21,12 @@ type ScatterPlotProps = {
|
|
|
20
21
|
lineData?: [[number, number], [number, number]];
|
|
21
22
|
showConfidenceBand?: boolean;
|
|
22
23
|
showLegend?: boolean;
|
|
24
|
+
onitemclick?: (params: ScatterPlotEchartsEvent) => void;
|
|
25
|
+
onmouseover?: (params: ScatterPlotEchartsEvent) => void;
|
|
23
26
|
legendItems?: LegendItem[];
|
|
24
27
|
highlightIndex?: number | null;
|
|
25
28
|
children?: Snippet;
|
|
26
|
-
} & Omit<GenericChartProps, 'timeIndex'>;
|
|
29
|
+
} & Omit<GenericChartProps, 'timeIndex' | 'onmouseover' | 'onitemclick'>;
|
|
27
30
|
declare const Scatterplot: import("svelte").Component<ScatterPlotProps, {}, "">;
|
|
28
31
|
type Scatterplot = ReturnType<typeof Scatterplot>;
|
|
29
32
|
export default Scatterplot;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
<script module lang="ts">
|
|
2
|
+
import Plus from 'phosphor-svelte/lib/Plus';
|
|
2
3
|
import { defineMeta } from '@storybook/addon-svelte-csf';
|
|
3
4
|
import IconButton from '../icon-button/IconButton.svelte';
|
|
4
|
-
import { Icon } from '../icons';
|
|
5
5
|
|
|
6
6
|
const { Story } = defineMeta({
|
|
7
7
|
component: IconButton,
|
|
@@ -12,71 +12,39 @@
|
|
|
12
12
|
|
|
13
13
|
<Story name="Base" asChild>
|
|
14
14
|
<div class="flex flex-col gap-2">
|
|
15
|
-
<IconButton variant="primary"
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
<IconButton variant="
|
|
19
|
-
<Icon iconName="Plus" />
|
|
20
|
-
</IconButton>
|
|
21
|
-
<IconButton variant="danger">
|
|
22
|
-
<Icon iconName="Plus" />
|
|
23
|
-
</IconButton>
|
|
24
|
-
<IconButton variant="transparent">
|
|
25
|
-
<Icon iconName="Plus" />
|
|
26
|
-
</IconButton>
|
|
15
|
+
<IconButton aria-label="Add" variant="primary" icon={Plus} />
|
|
16
|
+
<IconButton aria-label="Add" variant="secondary" icon={Plus} />
|
|
17
|
+
<IconButton aria-label="Add" variant="danger" icon={Plus} />
|
|
18
|
+
<IconButton aria-label="Add" variant="transparent" icon={Plus} />
|
|
27
19
|
</div>
|
|
28
20
|
</Story>
|
|
29
21
|
|
|
30
22
|
<Story name="Sizes" asChild>
|
|
31
23
|
<div class="flex flex-col gap-2">
|
|
32
|
-
<IconButton variant="secondary" size="xs"
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
<IconButton variant="secondary" size="sm">
|
|
36
|
-
<Icon iconName="Plus" />
|
|
37
|
-
</IconButton>
|
|
38
|
-
<IconButton variant="secondary" size="md">
|
|
39
|
-
<Icon iconName="Plus" />
|
|
40
|
-
</IconButton>
|
|
24
|
+
<IconButton aria-label="Add" icon={Plus} variant="secondary" size="xs" />
|
|
25
|
+
<IconButton aria-label="Add" icon={Plus} variant="secondary" size="sm" />
|
|
26
|
+
<IconButton aria-label="Add" icon={Plus} variant="secondary" size="md" />
|
|
41
27
|
</div>
|
|
42
28
|
</Story>
|
|
43
29
|
<Story name="Not rounded base" asChild>
|
|
44
30
|
<div class="flex flex-col gap-2">
|
|
45
|
-
<IconButton variant="primary" rounded={false}
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
<IconButton variant="
|
|
49
|
-
<Icon iconName="Plus" />
|
|
50
|
-
</IconButton>
|
|
51
|
-
<IconButton variant="danger" rounded={false}>
|
|
52
|
-
<Icon iconName="Plus" />
|
|
53
|
-
</IconButton>
|
|
54
|
-
<IconButton variant="transparent" rounded={false}>
|
|
55
|
-
<Icon iconName="Plus" />
|
|
56
|
-
</IconButton>
|
|
31
|
+
<IconButton aria-label="Add" icon={Plus} variant="primary" rounded={false} />
|
|
32
|
+
<IconButton aria-label="Add" icon={Plus} variant="secondary" rounded={false} />
|
|
33
|
+
<IconButton aria-label="Add" icon={Plus} variant="danger" rounded={false} />
|
|
34
|
+
<IconButton aria-label="Add" icon={Plus} variant="transparent" rounded={false} />
|
|
57
35
|
</div>
|
|
58
36
|
</Story>
|
|
59
37
|
|
|
60
38
|
<Story name="Not rounded sizes" asChild>
|
|
61
39
|
<div class="flex flex-col gap-2">
|
|
62
|
-
<IconButton variant="secondary" size="xs" rounded={false}
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
<IconButton variant="secondary" size="sm" rounded={false}>
|
|
66
|
-
<Icon iconName="Plus" />
|
|
67
|
-
</IconButton>
|
|
68
|
-
<IconButton variant="secondary" size="md" rounded={false}>
|
|
69
|
-
<Icon iconName="Plus" />
|
|
70
|
-
</IconButton>
|
|
40
|
+
<IconButton aria-label="Add" icon={Plus} variant="secondary" size="xs" rounded={false} />
|
|
41
|
+
<IconButton aria-label="Add" icon={Plus} variant="secondary" size="sm" rounded={false} />
|
|
42
|
+
<IconButton aria-label="Add" icon={Plus} variant="secondary" size="md" rounded={false} />
|
|
71
43
|
</div>
|
|
72
44
|
</Story>
|
|
73
45
|
<Story name="Disabled" asChild>
|
|
74
|
-
<IconButton disabled
|
|
75
|
-
<Icon iconName="Plus" />
|
|
76
|
-
</IconButton>
|
|
46
|
+
<IconButton aria-label="Add" disabled icon={Plus} />
|
|
77
47
|
</Story>
|
|
78
48
|
<Story name="Loading" asChild>
|
|
79
|
-
<IconButton loading
|
|
80
|
-
<Icon iconName="Plus" />
|
|
81
|
-
</IconButton>
|
|
49
|
+
<IconButton aria-label="Add" icon={Plus} loading />
|
|
82
50
|
</Story>
|
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
|
-
import
|
|
2
|
+
import RadioButton from 'phosphor-svelte/lib/RadioButton';
|
|
3
|
+
import BugBeetle from 'phosphor-svelte/lib/BugBeetle';
|
|
4
|
+
import Plant from 'phosphor-svelte/lib/Plant';
|
|
5
|
+
import LineSegments from 'phosphor-svelte/lib/LineSegments';
|
|
6
|
+
import { Icon } from './index';
|
|
3
7
|
import { Well, Halo } from './custom';
|
|
4
8
|
import type { IconColor, SupportedAnalysisModelIcons } from '.';
|
|
5
9
|
|
|
@@ -82,17 +86,17 @@
|
|
|
82
86
|
{#if model === 'pipeline_halos'}
|
|
83
87
|
<Halo size={getIconSize().toString()} color={mapAnalysisToColor(model)} />
|
|
84
88
|
{:else if ['sgs_enteros'].includes(model)}
|
|
85
|
-
<Icon
|
|
89
|
+
<Icon color={mapAnalysisToColor(model)} size={getIconSize()} icon={RadioButton} />
|
|
86
90
|
{:else if model === 'pipeline_large_colonies' || model === 'pipeline_radial_growth'}
|
|
87
|
-
<Icon
|
|
91
|
+
<Icon color={mapAnalysisToColor(model)} size={getIconSize()} icon={RadioButton} />
|
|
88
92
|
{:else if model === 'pipeline_small_colonies'}
|
|
89
93
|
<Well size={getIconSize().toString()} color={mapAnalysisToColor(model)} />
|
|
90
94
|
{:else if model === 'pipeline_insects'}
|
|
91
|
-
<Icon
|
|
95
|
+
<Icon color={mapAnalysisToColor(model)} size={getIconSize()} icon={BugBeetle} />
|
|
92
96
|
{:else if model === 'pipeline_seed_germination'}
|
|
93
|
-
<Icon
|
|
97
|
+
<Icon color={mapAnalysisToColor(model)} size={getIconSize()} icon={Plant} />
|
|
94
98
|
{:else}
|
|
95
|
-
<Icon
|
|
99
|
+
<Icon color={mapAnalysisToColor(model)} size={getIconSize()} icon={LineSegments} />
|
|
96
100
|
{/if}
|
|
97
101
|
</div>
|
|
98
102
|
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
<script module lang="ts">
|
|
2
|
+
import Star from 'phosphor-svelte/lib/Star';
|
|
2
3
|
import { defineMeta } from '@storybook/addon-svelte-csf';
|
|
3
|
-
import { Icon
|
|
4
|
+
import { Icon } from './index';
|
|
4
5
|
|
|
5
6
|
const { Story } = defineMeta({
|
|
6
7
|
component: Icon,
|
|
@@ -13,49 +14,30 @@
|
|
|
13
14
|
},
|
|
14
15
|
},
|
|
15
16
|
});
|
|
16
|
-
|
|
17
|
-
// Get all icon names from the iconMap
|
|
18
|
-
const iconNames = Object.keys(iconMap);
|
|
19
17
|
</script>
|
|
20
18
|
|
|
21
|
-
<Story name="All Icons" asChild>
|
|
22
|
-
<div class="p-4">
|
|
23
|
-
<h2 class="mb-6 text-xl font-semibold">Icon Gallery</h2>
|
|
24
|
-
<div class="grid grid-cols-1 gap-6 sm:grid-cols-2 md:grid-cols-3 lg:grid-cols-4">
|
|
25
|
-
{#each iconNames as iconName}
|
|
26
|
-
<div class="flex flex-col items-center rounded-lg border border-neutral p-4 text-center">
|
|
27
|
-
<div class="mb-3 flex h-12 w-12 items-center justify-center rounded-full bg-neutral">
|
|
28
|
-
<Icon iconName={iconName as IconName} size={24} />
|
|
29
|
-
</div>
|
|
30
|
-
<span class="text-sm">{iconName}</span>
|
|
31
|
-
</div>
|
|
32
|
-
{/each}
|
|
33
|
-
</div>
|
|
34
|
-
</div>
|
|
35
|
-
</Story>
|
|
36
|
-
|
|
37
19
|
<Story name="Icon Sizes" asChild>
|
|
38
20
|
<div class="p-4">
|
|
39
21
|
<h2 class="mb-6 text-xl font-semibold">Icon Sizes</h2>
|
|
40
22
|
<div class="flex flex-wrap items-end gap-8">
|
|
41
23
|
<div class="flex flex-col items-center">
|
|
42
|
-
<Icon
|
|
24
|
+
<Icon icon={Star} size={16} />
|
|
43
25
|
<span class="mt-2 text-xs">16px</span>
|
|
44
26
|
</div>
|
|
45
27
|
<div class="flex flex-col items-center">
|
|
46
|
-
<Icon
|
|
28
|
+
<Icon icon={Star} size={20} />
|
|
47
29
|
<span class="mt-2 text-xs">20px</span>
|
|
48
30
|
</div>
|
|
49
31
|
<div class="flex flex-col items-center">
|
|
50
|
-
<Icon
|
|
32
|
+
<Icon icon={Star} size={24} />
|
|
51
33
|
<span class="mt-2 text-xs">24px</span>
|
|
52
34
|
</div>
|
|
53
35
|
<div class="flex flex-col items-center">
|
|
54
|
-
<Icon
|
|
36
|
+
<Icon icon={Star} size={32} />
|
|
55
37
|
<span class="mt-2 text-xs">32px</span>
|
|
56
38
|
</div>
|
|
57
39
|
<div class="flex flex-col items-center">
|
|
58
|
-
<Icon
|
|
40
|
+
<Icon icon={Star} size={48} />
|
|
59
41
|
<span class="mt-2 text-xs">48px</span>
|
|
60
42
|
</div>
|
|
61
43
|
</div>
|
|
@@ -67,27 +49,27 @@
|
|
|
67
49
|
<h2 class="mb-6 text-xl font-semibold">Icon Weights</h2>
|
|
68
50
|
<div class="flex flex-wrap gap-8">
|
|
69
51
|
<div class="flex flex-col items-center">
|
|
70
|
-
<Icon
|
|
52
|
+
<Icon icon={Star} size={24} weight="thin" />
|
|
71
53
|
<span class="mt-2 text-xs">Thin</span>
|
|
72
54
|
</div>
|
|
73
55
|
<div class="flex flex-col items-center">
|
|
74
|
-
<Icon
|
|
56
|
+
<Icon icon={Star} size={24} weight="light" />
|
|
75
57
|
<span class="mt-2 text-xs">Light</span>
|
|
76
58
|
</div>
|
|
77
59
|
<div class="flex flex-col items-center">
|
|
78
|
-
<Icon
|
|
60
|
+
<Icon icon={Star} size={24} weight="regular" />
|
|
79
61
|
<span class="mt-2 text-xs">Regular</span>
|
|
80
62
|
</div>
|
|
81
63
|
<div class="flex flex-col items-center">
|
|
82
|
-
<Icon
|
|
64
|
+
<Icon icon={Star} size={24} weight="bold" />
|
|
83
65
|
<span class="mt-2 text-xs">Bold</span>
|
|
84
66
|
</div>
|
|
85
67
|
<div class="flex flex-col items-center">
|
|
86
|
-
<Icon
|
|
68
|
+
<Icon icon={Star} size={24} weight="fill" />
|
|
87
69
|
<span class="mt-2 text-xs">Fill</span>
|
|
88
70
|
</div>
|
|
89
71
|
<div class="flex flex-col items-center">
|
|
90
|
-
<Icon
|
|
72
|
+
<Icon icon={Star} size={24} weight="duotone" />
|
|
91
73
|
<span class="mt-2 text-xs">Duotone</span>
|
|
92
74
|
</div>
|
|
93
75
|
</div>
|
|
@@ -99,27 +81,27 @@
|
|
|
99
81
|
<h2 class="mb-6 text-xl font-semibold">Icon Colors</h2>
|
|
100
82
|
<div class="flex flex-wrap gap-8">
|
|
101
83
|
<div class="flex flex-col items-center">
|
|
102
|
-
<Icon
|
|
84
|
+
<Icon icon={Star} size={24} color="primary" />
|
|
103
85
|
<span class="mt-2 text-xs">Primary</span>
|
|
104
86
|
</div>
|
|
105
87
|
<div class="flex flex-col items-center">
|
|
106
|
-
<Icon
|
|
88
|
+
<Icon icon={Star} size={24} color="secondary" />
|
|
107
89
|
<span class="mt-2 text-xs">Secondary</span>
|
|
108
90
|
</div>
|
|
109
91
|
<div class="flex flex-col items-center">
|
|
110
|
-
<Icon
|
|
92
|
+
<Icon icon={Star} size={24} color="tertiary" />
|
|
111
93
|
<span class="mt-2 text-xs">Tertiary</span>
|
|
112
94
|
</div>
|
|
113
95
|
<div class="flex flex-col items-center">
|
|
114
|
-
<Icon
|
|
96
|
+
<Icon icon={Star} size={24} color="success" />
|
|
115
97
|
<span class="mt-2 text-xs">Success</span>
|
|
116
98
|
</div>
|
|
117
99
|
<div class="flex flex-col items-center">
|
|
118
|
-
<Icon
|
|
100
|
+
<Icon icon={Star} size={24} color="warning" />
|
|
119
101
|
<span class="mt-2 text-xs">Warning</span>
|
|
120
102
|
</div>
|
|
121
103
|
<div class="flex flex-col items-center">
|
|
122
|
-
<Icon
|
|
104
|
+
<Icon icon={Star} size={24} color="danger" />
|
|
123
105
|
<span class="mt-2 text-xs">Danger</span>
|
|
124
106
|
</div>
|
|
125
107
|
</div>
|
|
@@ -1,24 +1,57 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
|
+
import type { Snippet, Component } from 'svelte';
|
|
3
|
+
import type { IconComponentProps } from 'phosphor-svelte';
|
|
2
4
|
import { textColor } from '../../tokens';
|
|
3
|
-
|
|
5
|
+
|
|
6
|
+
type BaseProps = {
|
|
7
|
+
color?: keyof typeof textColor | 'inherit';
|
|
8
|
+
weight?: 'fill' | 'light' | 'regular' | 'thin' | 'bold' | 'duotone';
|
|
9
|
+
width?: number;
|
|
10
|
+
height?: number;
|
|
11
|
+
size?: number | string;
|
|
12
|
+
class?: string;
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
type WithIcon = {
|
|
16
|
+
icon: Component<IconComponentProps>;
|
|
17
|
+
children?: undefined;
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
type WithChildren = {
|
|
21
|
+
icon?: undefined;
|
|
22
|
+
children: Snippet<[IconComponentProps]>;
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
type Props = BaseProps & (WithIcon | WithChildren);
|
|
26
|
+
|
|
27
|
+
const props: Props = $props();
|
|
4
28
|
|
|
5
29
|
let {
|
|
6
|
-
|
|
30
|
+
icon: IconComponent,
|
|
7
31
|
color = 'inherit',
|
|
8
32
|
weight = 'bold',
|
|
9
33
|
width = 16,
|
|
10
34
|
height = 16,
|
|
11
35
|
size,
|
|
12
|
-
class: className,
|
|
13
|
-
|
|
36
|
+
class: className = '',
|
|
37
|
+
children,
|
|
38
|
+
} = props;
|
|
39
|
+
|
|
40
|
+
const iconProps = $derived({
|
|
41
|
+
color: color === 'inherit' ? 'currentColor' : textColor[color],
|
|
42
|
+
weight,
|
|
43
|
+
width: size ? size : width,
|
|
44
|
+
height: size ? size : height,
|
|
45
|
+
class: 'shrink-0',
|
|
46
|
+
});
|
|
14
47
|
</script>
|
|
15
48
|
|
|
16
|
-
|
|
17
|
-
<
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
{
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
49
|
+
{#if IconComponent}
|
|
50
|
+
<span class={className}>
|
|
51
|
+
<IconComponent {...iconProps} />
|
|
52
|
+
</span>
|
|
53
|
+
{:else if children}
|
|
54
|
+
<span class={className}>
|
|
55
|
+
{@render children(iconProps)}
|
|
56
|
+
</span>
|
|
57
|
+
{/if}
|
|
@@ -1,4 +1,23 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import type { Snippet, Component } from 'svelte';
|
|
2
|
+
import type { IconComponentProps } from 'phosphor-svelte';
|
|
3
|
+
import { textColor } from '../../tokens';
|
|
4
|
+
type BaseProps = {
|
|
5
|
+
color?: keyof typeof textColor | 'inherit';
|
|
6
|
+
weight?: 'fill' | 'light' | 'regular' | 'thin' | 'bold' | 'duotone';
|
|
7
|
+
width?: number;
|
|
8
|
+
height?: number;
|
|
9
|
+
size?: number | string;
|
|
10
|
+
class?: string;
|
|
11
|
+
};
|
|
12
|
+
type WithIcon = {
|
|
13
|
+
icon: Component<IconComponentProps>;
|
|
14
|
+
children?: undefined;
|
|
15
|
+
};
|
|
16
|
+
type WithChildren = {
|
|
17
|
+
icon?: undefined;
|
|
18
|
+
children: Snippet<[IconComponentProps]>;
|
|
19
|
+
};
|
|
20
|
+
type Props = BaseProps & (WithIcon | WithChildren);
|
|
21
|
+
declare const Icon: Component<Props, {}, "">;
|
|
3
22
|
type Icon = ReturnType<typeof Icon>;
|
|
4
23
|
export default Icon;
|
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
2
|
import type { IconColor, SupportedPrincipalIcons } from '.';
|
|
3
|
-
import
|
|
3
|
+
import type { Component } from 'svelte';
|
|
4
|
+
import type { IconComponentProps } from 'phosphor-svelte';
|
|
5
|
+
import Icon from './Icon.svelte';
|
|
4
6
|
import User from 'phosphor-svelte/lib/User';
|
|
7
|
+
import UsersThree from 'phosphor-svelte/lib/UsersThree';
|
|
5
8
|
import Buildings from 'phosphor-svelte/lib/Buildings';
|
|
6
9
|
|
|
7
10
|
type Props = {
|
|
@@ -13,7 +16,9 @@
|
|
|
13
16
|
|
|
14
17
|
let { principal, withBackground, size = 'md', class: className }: Props = $props();
|
|
15
18
|
|
|
16
|
-
const mapPrincipalToIcon = (
|
|
19
|
+
const mapPrincipalToIcon = (
|
|
20
|
+
principal: SupportedPrincipalIcons
|
|
21
|
+
): Component<IconComponentProps> => {
|
|
17
22
|
switch (principal) {
|
|
18
23
|
case 'user':
|
|
19
24
|
return User;
|
|
@@ -51,14 +56,29 @@
|
|
|
51
56
|
return 'bg-neutral';
|
|
52
57
|
}
|
|
53
58
|
};
|
|
59
|
+
|
|
60
|
+
const getIconSize = () => {
|
|
61
|
+
switch (size) {
|
|
62
|
+
case 'sm':
|
|
63
|
+
return 14;
|
|
64
|
+
case 'lg':
|
|
65
|
+
return 20;
|
|
66
|
+
default:
|
|
67
|
+
return 16;
|
|
68
|
+
}
|
|
69
|
+
};
|
|
54
70
|
</script>
|
|
55
71
|
|
|
56
|
-
<!-- svelte-ignore svelte_component_deprecated -->
|
|
57
72
|
<div
|
|
58
|
-
class={
|
|
73
|
+
class={`${withBackground ? backgroundColor(principal) : ''} ${className} size-${size} border border-static`}
|
|
59
74
|
class:withBackground
|
|
60
75
|
>
|
|
61
|
-
<
|
|
76
|
+
<Icon
|
|
77
|
+
icon={mapPrincipalToIcon(principal)}
|
|
78
|
+
color={mapPrincipalToColor(principal)}
|
|
79
|
+
size={getIconSize()}
|
|
80
|
+
weight="bold"
|
|
81
|
+
/>
|
|
62
82
|
</div>
|
|
63
83
|
|
|
64
84
|
<style>
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import type { SupportedPrincipalIcons } from '.';
|
|
2
|
+
import type { Component } from 'svelte';
|
|
2
3
|
type Props = {
|
|
3
4
|
principal: SupportedPrincipalIcons;
|
|
4
5
|
withBackground?: boolean;
|
|
5
6
|
size?: 'sm' | 'md' | 'lg';
|
|
6
7
|
class?: string;
|
|
7
8
|
};
|
|
8
|
-
declare const PrincipalIcon:
|
|
9
|
+
declare const PrincipalIcon: Component<Props, {}, "">;
|
|
9
10
|
type PrincipalIcon = ReturnType<typeof PrincipalIcon>;
|
|
10
11
|
export default PrincipalIcon;
|