@reshape-biotech/design-system 1.2.5 → 1.2.6

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.
@@ -1,10 +1,11 @@
1
1
  import type { IconComponentProps } from 'phosphor-svelte';
2
2
  import type { Component } from 'svelte';
3
- import type { textColor } from './../../tokens';
3
+ import type { textColor, backgroundColor } from './../../tokens';
4
4
  export type PhosphorIconProps = Component<IconComponentProps, object, ''>;
5
- export type IconName = 'Aperture' | 'ArrowFatLineRight' | 'ArrowCounterClockwise' | 'ArrowRight' | 'ArrowUpRight' | 'ArrowUpLeft' | 'ArrowUUpLeft' | 'Barcode' | 'Bell' | 'BookOpen' | 'BookOpenText' | 'BowlingBall' | 'BugBeetle' | 'Calendar' | 'CalendarBlank' | 'Camera' | 'CameraSlash' | 'CaretDown' | 'CaretLeft' | 'CaretRight' | 'CaretUp' | 'CaretUpDown' | 'ChatTeardropDots' | 'Check' | 'CheckCircle' | 'CheckFat' | 'Circle' | 'CircleDashed' | 'CircleHalf' | 'CirclesFour' | 'CirclesThreePlus' | 'Clock' | 'ClockCountdown' | 'Copy' | 'Crop' | 'Cube' | 'Database' | 'Dna' | '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' | 'Link' | 'ListMagnifyingGlass' | 'MagnifyingGlass' | 'MegaphoneSimple' | 'MicrosoftExcelLogo' | 'Moon' | 'Minus' | 'Palette' | 'Pause' | 'Pencil' | 'PencilSimple' | 'Percent' | 'Phone' | 'Plant' | 'Play' | 'Plus' | 'PlusMinus' | 'Ruler' | 'Question' | 'SealCheck' | 'RadioButton' | 'SealQuestion' | 'SealWarning' | 'SelectionAll' | 'Share' | 'SidebarSimple' | 'SkipBack' | 'SkipForward' | 'SignIn' | 'SignOut' | 'SortAscending' | 'Sparkle' | 'SpinnerGap' | 'SquaresFour' | 'Star' | 'Stop' | 'StopCircle' | 'Sun' | 'Table' | 'Tag' | 'Target' | 'TestTube' | 'Trash' | 'TrashSimple' | 'TreeStructure' | 'UserCircle' | 'UserPlus' | 'Video' | 'Warning' | 'WarningCircle' | 'WifiSlash' | 'X';
5
+ export type IconName = 'Aperture' | 'ArrowFatLineRight' | 'ArrowCounterClockwise' | 'ArrowRight' | 'ArrowUpRight' | 'ArrowUpLeft' | 'ArrowUUpLeft' | 'Barcode' | 'Bell' | 'BookOpen' | 'BookOpenText' | 'BowlingBall' | 'BugBeetle' | 'Calendar' | 'CalendarBlank' | 'Camera' | 'CameraSlash' | 'CaretDown' | 'CaretLeft' | 'CaretRight' | 'CaretUp' | 'CaretUpDown' | 'ChatTeardropDots' | 'Check' | 'CheckCircle' | 'CheckFat' | 'Circle' | 'CircleDashed' | 'CircleHalf' | 'CirclesFour' | 'CirclesThreePlus' | 'Clock' | 'ClockCountdown' | 'Copy' | 'Crop' | 'Cube' | 'CursorClick' | 'Database' | 'Dna' | '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' | 'Link' | 'ListMagnifyingGlass' | 'MagnifyingGlass' | 'MegaphoneSimple' | 'MicrosoftExcelLogo' | 'Moon' | 'Minus' | 'Palette' | 'Pause' | 'Pencil' | 'PencilSimple' | 'Percent' | 'Phone' | 'Plant' | 'Play' | 'Plus' | 'PlusMinus' | 'Ruler' | 'Question' | 'SealCheck' | 'RadioButton' | 'SealQuestion' | 'SealWarning' | 'SelectionAll' | 'Share' | 'SidebarSimple' | 'SkipBack' | 'SkipForward' | 'SignIn' | 'SignOut' | 'SortAscending' | 'Sparkle' | 'SpinnerGap' | 'SquaresFour' | 'Star' | 'Stop' | 'StopCircle' | 'Sun' | 'Table' | 'Tag' | 'Target' | 'TestTube' | 'Trash' | 'TrashSimple' | 'TreeStructure' | '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
+ export type BackgroundClass = `bg-${keyof typeof backgroundColor}`;
8
9
  export type IconColor = keyof typeof textColor;
9
10
  export type SupportedAnalysisModelIcons = 'pipeline_halos' | 'pipeline_large_colonies' | 'pipeline_microbial_colonies' | 'pipeline_small_colonies' | 'sgs_enteros' | 'general_germination_rate_with_tracking' | 'general_germination_rate_without_tracking' | 'pipeline_insects' | 'pipeline_colony_formation' | 'pipeline_radial_growth' | 'syngenta_health_score_crw' | 'pipeline_seed_germination' | 'syngenta_health_score_faw' | 'syngenta_health_score_sbl' | 'unilever_cfu_count_lowres';
10
11
  export type SupportedPrincipalIcons = 'user' | 'group' | 'organization';
@@ -34,6 +34,7 @@ import ClockCountdown from 'phosphor-svelte/lib/ClockCountdown';
34
34
  import Copy from 'phosphor-svelte/lib/Copy';
35
35
  import Crop from 'phosphor-svelte/lib/Crop';
36
36
  import Cube from 'phosphor-svelte/lib/Cube';
37
+ import CursorClick from 'phosphor-svelte/lib/CursorClick';
37
38
  import Database from 'phosphor-svelte/lib/Database';
38
39
  import Dna from 'phosphor-svelte/lib/Dna';
39
40
  import DotsThree from 'phosphor-svelte/lib/DotsThree';
@@ -151,6 +152,7 @@ export const iconMap = {
151
152
  Copy,
152
153
  Crop,
153
154
  Cube,
155
+ CursorClick,
154
156
  Database,
155
157
  Dna,
156
158
  DotsThree,
@@ -8,8 +8,8 @@
8
8
 
9
9
  // Constants for the component
10
10
  const BASE_IMAGE_SIZE = 464; // Base size, will be overriden by container dimensions
11
- const BASE_MARKER_SIZE = 12; // Base size at zoom level 1
12
- const BASE_MARKER_FONT_SIZE = 10; // Base font size at zoom level 1
11
+ const BASE_MARKER_SIZE = 8; // Base size at zoom level 1
12
+ const BASE_MARKER_FONT_SIZE = 8; // Base font size at zoom level 1
13
13
  const MAX_ZOOM = 10;
14
14
  const MIN_ZOOM = 1;
15
15
  const ZOOM_STEP = 0.001;
@@ -37,7 +37,6 @@
37
37
  let svgElement: SVGSVGElement;
38
38
  let viewport: SVGGraphicsElement;
39
39
  let dotsGroup: SVGElement;
40
- let marksHistory: Array<Array<{ x: number; y: number }>> = $state([]);
41
40
  let container: HTMLDivElement;
42
41
 
43
42
  let containerW = BASE_IMAGE_SIZE;
@@ -245,7 +244,6 @@
245
244
  panningState = null;
246
245
  return;
247
246
  }
248
- saveCurrentState();
249
247
  const pt = getSvgPoint(event);
250
248
  marks.push({ x: pt.x, y: pt.y });
251
249
 
@@ -372,23 +370,17 @@
372
370
  updateTransform();
373
371
  }
374
372
 
375
- function saveCurrentState() {
376
- marksHistory.push([...marks]);
377
- }
378
-
373
+ // Simplified undo function - just pop the last mark
379
374
  function undo() {
380
- if (marksHistory.length === 0) return;
381
- const previousState = marksHistory.pop();
382
- if (previousState) {
383
- marks.splice(0, marks.length, ...previousState);
384
- marks = marks;
385
- renderMarkers();
386
- }
375
+ if (marks.length === 0) return;
376
+
377
+ marks.pop();
378
+ marks = marks;
379
+ renderMarkers();
387
380
  }
388
381
 
389
382
  function reset() {
390
383
  if (marks.length === 0) return;
391
- saveCurrentState();
392
384
 
393
385
  marks = [];
394
386
  renderMarkers();
@@ -484,7 +476,7 @@
484
476
  variant="transparent-inverse"
485
477
  rounded={false}
486
478
  onclick={undo}
487
- disabled={marksHistory.length === 0 || disabled}
479
+ disabled={marks.length === 0 || disabled}
488
480
  aria-label="Undo last mark"
489
481
  >
490
482
  <Icon iconName={'ArrowUUpLeft'} />
@@ -0,0 +1,215 @@
1
+ <script module lang="ts">
2
+ import { defineMeta } from '@storybook/addon-svelte-csf';
3
+ import MultiCFUCounter from './MultiCFUCounter.svelte';
4
+ const { Story } = defineMeta({
5
+ component: MultiCFUCounter,
6
+ title: 'Design System/MultiCFUCounter',
7
+ tags: ['autodocs'],
8
+ args: {
9
+ imageUrl: '/imgs/ris.jpg',
10
+ marks: [],
11
+ disabled: false,
12
+ hideMarkers: false
13
+ },
14
+ argTypes: {
15
+ imageUrl: {
16
+ control: 'text',
17
+ description: 'URL of the image to display'
18
+ },
19
+ marks: {
20
+ control: 'object',
21
+ description: 'Array of marker coordinates. Bindable for two-way data flow.'
22
+ },
23
+ onclick: {
24
+ action: 'clicked',
25
+ description: 'Event handler for when a marker is added'
26
+ },
27
+ disabled: {
28
+ control: 'boolean',
29
+ description: 'Disables interaction with the counter'
30
+ },
31
+ hideMarkers: {
32
+ control: 'boolean',
33
+ description: 'Hides the markers and prevents new ones from being added'
34
+ }
35
+ }
36
+ });
37
+
38
+ const largeImage = '/imgs/ris.jpg';
39
+
40
+ function handleUpdate(event: MouseEvent, marks: Array<{ x: number; y: number }>) {
41
+ console.log('Marker count:', marks.length);
42
+ console.log('Marker positions:', marks);
43
+ }
44
+ </script>
45
+
46
+ <script lang="ts">
47
+ let activeConfigIndex = $state(0);
48
+ let allMarksMultiConfig = $state([
49
+ // Yeast Count (config 0) - blue markers
50
+ { x: 120, y: 150, configIndex: 0, color: 'icon-blue', id: 'yeast-1' },
51
+ { x: 180, y: 220, configIndex: 0, color: 'icon-blue', id: 'yeast-2' },
52
+ { x: 250, y: 180, configIndex: 0, color: 'icon-blue', id: 'yeast-3' },
53
+
54
+ // Mold Count (config 1) - orange markers
55
+ { x: 320, y: 160, configIndex: 1, color: 'icon-orange', id: 'mold-1' },
56
+ { x: 380, y: 240, configIndex: 1, color: 'icon-orange', id: 'mold-2' },
57
+
58
+ // Colony Type (config 2) - lime markers
59
+ { x: 400, y: 120, configIndex: 2, color: 'icon-lime', id: 'type-1' }
60
+ ]);
61
+
62
+ const configurations = [
63
+ { name: 'Yeast Count', color: 'icon-blue', configIndex: 0 },
64
+ { name: 'Mold Count', color: 'icon-orange', configIndex: 1 },
65
+ { name: 'Colony Type', color: 'icon-lime', configIndex: 2 }
66
+ ];
67
+
68
+ function handleMultiConfigUpdate(event: MouseEvent, marks: Array<{ x: number; y: number }>) {
69
+ console.log(`Configuration ${activeConfigIndex} updated:`, marks.length, 'marks');
70
+
71
+ allMarksMultiConfig = allMarksMultiConfig.filter(
72
+ (mark) => mark.configIndex !== activeConfigIndex
73
+ );
74
+
75
+ const newMarks = marks.map((mark, index) => ({
76
+ x: mark.x,
77
+ y: mark.y,
78
+ configIndex: activeConfigIndex,
79
+ color: configurations[activeConfigIndex].color,
80
+ id: `config-${activeConfigIndex}-${index + 1}`
81
+ }));
82
+
83
+ allMarksMultiConfig = [...allMarksMultiConfig, ...newMarks];
84
+ }
85
+
86
+ function switchConfiguration(configIndex: number) {
87
+ activeConfigIndex = configIndex;
88
+ }
89
+
90
+ const activeConfigMarks = $derived(
91
+ allMarksMultiConfig
92
+ .filter((mark) => mark.configIndex === activeConfigIndex)
93
+ .map((mark) => ({ x: mark.x, y: mark.y }))
94
+ );
95
+ </script>
96
+
97
+ <Story name="Default" asChild>
98
+ <div class="p-4">
99
+ <h3 class="mb-4 text-lg font-semibold">Manual CFU Counter</h3>
100
+ <p class="mb-4 text-sm text-secondary">
101
+ Click to add markers. Pan by clicking and dragging. Zoom with the mouse wheel.
102
+ </p>
103
+ <div class="h-[600px] rounded-lg border border-static p-4">
104
+ <MultiCFUCounter imageUrl={largeImage} onclick={handleUpdate} activeMarkerName="Yeast" />
105
+ </div>
106
+ </div>
107
+ </Story>
108
+
109
+ <Story name="Multi-Configuration Mode" asChild>
110
+ <div class="p-4">
111
+ <h3 class="mb-4 text-lg font-semibold">Multi-Configuration CFU Counter</h3>
112
+ <p class="mb-4 text-sm text-secondary">
113
+ This example demonstrates the multi-configuration mode used in assay analysis validation.
114
+ Switch between different configurations to count different types of objects with color-coded
115
+ markers.
116
+ </p>
117
+
118
+ <div class="mb-4 flex gap-2">
119
+ {#each configurations as config, index}
120
+ <button
121
+ class="flex items-center gap-2 rounded-lg border px-3 py-2 text-sm transition-colors"
122
+ class:border-interactive={activeConfigIndex === index}
123
+ class:bg-surface-secondary={activeConfigIndex === index}
124
+ class:border-neutral={activeConfigIndex !== index}
125
+ onclick={() => switchConfiguration(index)}
126
+ >
127
+ <div
128
+ class="h-3 w-3 rounded-full"
129
+ style="background-color: var(--text-{config.color})"
130
+ ></div>
131
+ {config.name}
132
+ <span class="text-xs text-tertiary">
133
+ ({allMarksMultiConfig.filter((m) => m.configIndex === index).length})
134
+ </span>
135
+ </button>
136
+ {/each}
137
+ </div>
138
+
139
+ <div class="mb-4 rounded-lg border border-neutral bg-surface-secondary p-3">
140
+ <div class="mb-2 flex items-center gap-2">
141
+ <div
142
+ class="h-4 w-4 rounded-full"
143
+ style="background-color: var(--text-{configurations[activeConfigIndex].color})"
144
+ ></div>
145
+ <span class="font-medium">Active: {configurations[activeConfigIndex].name}</span>
146
+ </div>
147
+ <p class="text-sm text-secondary">
148
+ Click on the image to add markers for {configurations[
149
+ activeConfigIndex
150
+ ].name.toLowerCase()}. Each configuration maintains its own set of markers with distinct
151
+ colors.
152
+ </p>
153
+ </div>
154
+
155
+ <div class="h-[600px] rounded-lg border border-static p-4">
156
+ <MultiCFUCounter
157
+ imageUrl={largeImage}
158
+ marks={activeConfigMarks}
159
+ allMarks={allMarksMultiConfig}
160
+ showMultiConfig={true}
161
+ activeMarkerColor={configurations[activeConfigIndex].color}
162
+ activeMarkerName={configurations[activeConfigIndex].name}
163
+ editableConfigIndex={activeConfigIndex}
164
+ onclick={handleMultiConfigUpdate}
165
+ />
166
+ </div>
167
+
168
+ <div class="mt-4 grid grid-cols-3 gap-4">
169
+ {#each configurations as config, index}
170
+ <div class="rounded-lg border border-neutral bg-surface p-3">
171
+ <div class="mb-1 flex items-center gap-2">
172
+ <div
173
+ class="h-3 w-3 rounded-full"
174
+ style="background-color: var(--text-{config.color})"
175
+ ></div>
176
+ <span class="text-sm font-medium">{config.name}</span>
177
+ </div>
178
+ <p class="text-lg font-bold">
179
+ {allMarksMultiConfig.filter((m) => m.configIndex === index).length}
180
+ </p>
181
+ <p class="text-xs text-tertiary">objects counted</p>
182
+ </div>
183
+ {/each}
184
+ </div>
185
+
186
+ <details class="mt-4 text-sm">
187
+ <summary>All Marks Data:</summary>
188
+ <pre class="mt-2 rounded bg-surface-secondary p-2 text-xs">{JSON.stringify(
189
+ allMarksMultiConfig,
190
+ null,
191
+ 2
192
+ )}</pre>
193
+ </details>
194
+ </div>
195
+ </Story>
196
+
197
+ <Story name="Disabled" asChild>
198
+ <div class="p-4">
199
+ <h3 class="mb-4 text-lg font-semibold">Disabled Counter</h3>
200
+ <p class="mb-4 text-sm text-secondary">No interactions are possible in disabled mode.</p>
201
+ <div class="h-[600px] rounded-lg border border-static p-4">
202
+ <MultiCFUCounter
203
+ imageUrl={largeImage}
204
+ marks={activeConfigMarks}
205
+ allMarks={allMarksMultiConfig}
206
+ showMultiConfig={true}
207
+ activeMarkerColor={configurations[activeConfigIndex].color}
208
+ activeMarkerName={configurations[activeConfigIndex].name}
209
+ editableConfigIndex={activeConfigIndex}
210
+ onclick={handleMultiConfigUpdate}
211
+ disabled
212
+ />
213
+ </div>
214
+ </div>
215
+ </Story>
@@ -0,0 +1,3 @@
1
+ declare const MultiCfuCounter: import("svelte").Component<Record<string, never>, {}, "">;
2
+ type MultiCfuCounter = ReturnType<typeof MultiCfuCounter>;
3
+ export default MultiCfuCounter;