@widgetic/workflows 0.2.6 → 0.2.8

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.
Files changed (91) hide show
  1. package/README.md +51 -44
  2. package/dist/api/types.d.ts +17 -0
  3. package/dist/api/types.js +7 -0
  4. package/dist/api/workflowsApi.js +23 -2
  5. package/dist/components/Workflows.svelte +13 -15
  6. package/dist/components/WorkflowsEmptyState.svelte +14 -12
  7. package/dist/components/WorkflowsHeader.svelte +9 -5
  8. package/dist/components/WorkflowsHeader.svelte.d.ts +4 -16
  9. package/dist/components/WorkflowsWorkspace.svelte +3 -2
  10. package/dist/components/canvas/AddBlockMenu.svelte +11 -2
  11. package/dist/components/canvas/CanvasToolbar.svelte +42 -31
  12. package/dist/components/canvas/CanvasToolbar.svelte.d.ts +2 -0
  13. package/dist/components/canvas/CompositionNodeView.svelte +58 -36
  14. package/dist/components/canvas/ConditionNodeView.svelte +31 -18
  15. package/dist/components/canvas/HandlePoint.svelte +10 -3
  16. package/dist/components/canvas/HandlePoint.svelte.d.ts +1 -1
  17. package/dist/components/canvas/TriggerNodeView.svelte +39 -13
  18. package/dist/components/canvas/WorkflowCanvas.svelte +22 -7
  19. package/dist/components/canvas/WorkflowCanvas.svelte.d.ts +2 -0
  20. package/dist/components/canvas/WorkflowEdgeView.svelte +5 -6
  21. package/dist/components/editor/ConflictBanner.svelte +1 -1
  22. package/dist/components/editor/EditorBanners.svelte +11 -4
  23. package/dist/components/editor/EditorCanvasArea.svelte +17 -10
  24. package/dist/components/editor/EditorTabs.svelte +10 -44
  25. package/dist/components/editor/EditorTopBar.svelte +166 -54
  26. package/dist/components/editor/PresenceBanner.svelte +106 -85
  27. package/dist/components/editor/RunsFlow.svelte +136 -42
  28. package/dist/components/editor/RunsTab.svelte +52 -46
  29. package/dist/components/editor/SettingsRow.svelte +35 -0
  30. package/dist/components/editor/SettingsRow.svelte.d.ts +14 -0
  31. package/dist/components/editor/SettingsTab.svelte +66 -50
  32. package/dist/components/editor/WorkflowEditor.svelte +4 -5
  33. package/dist/components/list/CreateWorkflowDialog.svelte +123 -73
  34. package/dist/components/list/WorkflowList.svelte +227 -100
  35. package/dist/components/list/WorkflowRow.svelte +84 -42
  36. package/dist/components/panel/BlockProblems.svelte +9 -8
  37. package/dist/components/panel/CompositionForm.svelte +52 -34
  38. package/dist/components/panel/CompositionPicker.svelte +43 -21
  39. package/dist/components/panel/CompositionPicker.svelte.d.ts +5 -0
  40. package/dist/components/panel/CompositionSelect.svelte +105 -0
  41. package/dist/components/panel/CompositionSelect.svelte.d.ts +23 -0
  42. package/dist/components/panel/ConditionForm.svelte +50 -17
  43. package/dist/components/panel/EventValueRow.svelte +5 -4
  44. package/dist/components/panel/ProblemsList.svelte +17 -19
  45. package/dist/components/panel/RuleCard.svelte +127 -89
  46. package/dist/components/panel/RuleCard.svelte.d.ts +2 -0
  47. package/dist/components/panel/SidePanel.svelte +101 -50
  48. package/dist/components/panel/TestResultLine.svelte +35 -0
  49. package/dist/components/panel/TestResultLine.svelte.d.ts +9 -0
  50. package/dist/components/panel/TestRow.svelte +21 -18
  51. package/dist/components/panel/TestRunPanel.svelte +61 -39
  52. package/dist/components/panel/TestTriggerCard.svelte +66 -6
  53. package/dist/components/panel/TestTriggerCard.svelte.d.ts +10 -0
  54. package/dist/components/panel/TriggerForm.svelte +24 -25
  55. package/dist/components/panel/VersionHistory.svelte +31 -43
  56. package/dist/components/ui/ActionButton.svelte +44 -12
  57. package/dist/components/ui/ActionButton.svelte.d.ts +2 -1
  58. package/dist/components/ui/Badge.svelte +39 -0
  59. package/dist/components/ui/Badge.svelte.d.ts +12 -0
  60. package/dist/components/ui/ConfirmDialog.svelte +4 -3
  61. package/dist/components/ui/Menu.svelte +28 -14
  62. package/dist/components/ui/Menu.svelte.d.ts +3 -1
  63. package/dist/components/ui/Modal.svelte +15 -8
  64. package/dist/components/ui/Notice.svelte +35 -11
  65. package/dist/components/ui/Notice.svelte.d.ts +4 -1
  66. package/dist/components/ui/SelectField.svelte +48 -20
  67. package/dist/components/ui/SelectField.svelte.d.ts +2 -0
  68. package/dist/components/ui/StatusBadge.svelte +13 -24
  69. package/dist/components/ui/StatusBadge.svelte.d.ts +0 -2
  70. package/dist/components/ui/Tabs.svelte +79 -0
  71. package/dist/components/ui/Tabs.svelte.d.ts +21 -0
  72. package/dist/components/ui/TextField.svelte +47 -27
  73. package/dist/components/ui/TextField.svelte.d.ts +5 -0
  74. package/dist/components/ui/icons.d.ts +43 -29
  75. package/dist/components/ui/icons.js +101 -40
  76. package/dist/editor/editorState.svelte.d.ts +23 -2
  77. package/dist/editor/editorState.svelte.js +36 -0
  78. package/dist/editor/listState.svelte.d.ts +32 -2
  79. package/dist/editor/listState.svelte.js +41 -0
  80. package/dist/editor/runsFlow.d.ts +28 -3
  81. package/dist/editor/runsFlow.js +27 -2
  82. package/dist/editor/runsFlowLayout.d.ts +6 -2
  83. package/dist/editor/runsFlowLayout.js +7 -2
  84. package/dist/editor/statsRange.d.ts +7 -1
  85. package/dist/editor/statsRange.js +14 -0
  86. package/dist/i18n/language.d.ts +3 -3
  87. package/dist/i18n/messages.d.ts +32 -13
  88. package/dist/i18n/messages.js +33 -14
  89. package/dist/i18n/statusWords.d.ts +12 -0
  90. package/dist/i18n/statusWords.js +12 -0
  91. package/package.json +3 -3
@@ -18,13 +18,14 @@
18
18
  import type { WorkflowGraph } from '@widgetic/workflows-engine';
19
19
  import { useTextDirection } from '@widgetic/design-system/components/textDirection';
20
20
  import { formatCount } from '../../editor/formatCount.js';
21
- import { buildRunsFlow } from '../../editor/runsFlow.js';
22
- import type { RunsFlow, RunsFlowStep } from '../../editor/runsFlow.js';
21
+ import { buildRunsFlow, listNumberLines } from '../../editor/runsFlow.js';
22
+ import type { RunsFlow, RunsFlowLineKind, RunsFlowStep } from '../../editor/runsFlow.js';
23
23
  import { RUNS_FLOW_METRICS, layoutRunsFlow } from '../../editor/runsFlowLayout.js';
24
24
  import type { PlacedLink, PlacedStep } from '../../editor/runsFlowLayout.js';
25
25
  import type { RunsFlowWords } from '../../editor/runsFlowWords.js';
26
26
  import type { RunCounts } from '../../editor/statsRange.js';
27
27
  import { useWorkflowsLanguage } from '../../i18n/language.js';
28
+ import type { WorkflowsMessageKey } from '../../i18n/messages.js';
28
29
  import { workflowsError } from '../../utils/logger.js';
29
30
 
30
31
  interface Props {
@@ -43,21 +44,37 @@
43
44
  const WIDTH_BEFORE_MEASURING = 720;
44
45
  /** The width of the place a band can be pointed at, however thin the band is. */
45
46
  const LEAST_POINTING_WIDTH = 14;
47
+ /** The distance between the pointer and the tooltip of a band, and the room the tooltip needs (its widest and a tall one). */
48
+ const TOOLTIP_GAP = 14;
49
+ const TOOLTIP_WIDTH = 240;
50
+ const TOOLTIP_HEIGHT = 96;
46
51
 
47
52
  // A band has one colour for each of its states; each is written whole so that the stylesheet of the page finds it.
48
53
  const BAND_STATE_CLASSES = {
49
- resting: 'stroke-primary-green/25',
50
- lit: 'stroke-primary-green/55',
51
- dimmed: 'stroke-primary-green/10',
54
+ resting: 'stroke-primary/30',
55
+ lit: 'stroke-primary/60',
56
+ dimmed: 'stroke-primary/10',
52
57
  // A way nobody took, in a chart that has visitors: a dashed hair.
53
- nobody: 'stroke-grey3/60',
58
+ nobody: 'stroke-border',
54
59
  // A chart nobody has been counted in: every band pale and whole, the shape of the workflow and no one in it.
55
- empty: 'stroke-grey3/20'
60
+ empty: 'stroke-border'
56
61
  } as const;
57
62
 
58
- /** One line of numbers under a composition's name. */
63
+ /** The words of each line of numbers under a composition's name (the lines themselves are the model's: `listNumberLines`). */
64
+ const LINE_MESSAGES = {
65
+ entered: 'workflows.runs.entered',
66
+ stayed: 'workflows.runs.stayed',
67
+ failed: 'workflows.runs.failed',
68
+ timeout: 'workflows.runs.failedTimeout',
69
+ widget_error: 'workflows.runs.failedWidgetError',
70
+ build: 'workflows.runs.failedBuild',
71
+ other: 'workflows.runs.failedOther',
72
+ unrecorded: 'workflows.runs.failedUnrecorded'
73
+ } as const satisfies Record<RunsFlowLineKind, WorkflowsMessageKey>;
74
+
75
+ /** One line of numbers under a composition's name, in words. */
59
76
  interface NumberLine {
60
- kind: 'entered' | 'stayed' | 'failed';
77
+ kind: RunsFlowLineKind;
61
78
  text: string;
62
79
  }
63
80
 
@@ -65,6 +82,10 @@
65
82
  let measuredWidth = $state(0);
66
83
  /** What a pointer is over: a bar or a band. Its bands (or itself) are lit and the others fade. */
67
84
  let pointedAt = $state.raw<{ kind: 'step' | 'link'; id: string } | null>(null);
85
+ /** What a mouse over a band is told (the band's words) and where, in pixels inside the frame; `null` when none is pointed at. */
86
+ let bandTooltip = $state.raw<{ bandId: string; text: string; left: number; top: number } | null>(
87
+ null
88
+ );
68
89
 
69
90
  const emptyFlow: RunsFlow = { steps: [], links: [], columnCount: 0, hasVisitors: false };
70
91
 
@@ -101,29 +122,26 @@
101
122
  return litBandIds.has(band.id) ? BAND_STATE_CLASSES.lit : BAND_STATE_CLASSES.dimmed;
102
123
  }
103
124
 
104
- /** The lines of numbers under a composition's name: how many entered, and, when they apply, how many stopped and how many failed. */
105
- function readNumbersOf(step: Pick<RunsFlowStep, 'entered' | 'stayed' | 'failed'>): NumberLine[] {
106
- const lines: NumberLine[] = [
107
- {
108
- kind: 'entered',
109
- text: $t('workflows.runs.entered', { count: formatCount(step.entered, $locale) })
110
- }
111
- ];
112
- if (step.stayed > 0) {
113
- lines.push({
114
- kind: 'stayed',
115
- text: $t('workflows.runs.stayed', { count: formatCount(step.stayed, $locale) })
116
- });
117
- }
118
- if (step.failed > 0) {
119
- lines.push({
120
- kind: 'failed',
121
- text: $t('workflows.runs.failed', { count: formatCount(step.failed, $locale) })
122
- });
123
- }
124
- return lines;
125
+ /**
126
+ * The lines of numbers under a composition's name: how many entered, and, when they apply, how many stopped, how many could
127
+ * not be shown and, under those, why (only when the embeds told). The list is the model's, which the layout counts too.
128
+ */
129
+ function readNumbersOf(
130
+ step: Pick<
131
+ RunsFlowStep,
132
+ 'entered' | 'stayed' | 'failed' | 'failedReasons' | 'failedWithoutReason'
133
+ >
134
+ ): NumberLine[] {
135
+ return listNumberLines(step).map((line) => ({
136
+ kind: line.kind,
137
+ text: $t(LINE_MESSAGES[line.kind], { count: formatCount(line.count, $locale) })
138
+ }));
125
139
  }
126
140
 
141
+ /** The lines that say why a composition could not be shown hang under the line that says how often. */
142
+ const isReasonLine = (kind: RunsFlowLineKind): boolean =>
143
+ kind !== 'entered' && kind !== 'stayed' && kind !== 'failed';
144
+
127
145
  /** One composition in one line, for its tooltip. */
128
146
  function describeStep(step: PlacedStep): string {
129
147
  return [words.nameStep(step.nodeId), ...readNumbersOf(step).map((line) => line.text)].join(
@@ -139,6 +157,58 @@
139
157
  ...words.describeRoute(band)
140
158
  ].join(' · ');
141
159
  }
160
+
161
+ /**
162
+ * Tells a mouse (or a pen) what the band under it is: next to the pointer, kept inside the frame (at the right edge it moves
163
+ * to the pointer's left, at the bottom above it). A finger gets no tooltip: it has no pointer to rest on a band, and the list
164
+ * for a screen reader says the same numbers.
165
+ */
166
+ function showBandTooltip(event: PointerEvent, band: PlacedLink, text: string): void {
167
+ if (event.pointerType === 'touch') return;
168
+ try {
169
+ // The scrolling frame of the chart: the tooltip is drawn inside it, so it moves and is cut with the drawing.
170
+ const chartFrame =
171
+ event.currentTarget instanceof Element
172
+ ? event.currentTarget.closest<HTMLElement>('[data-runs-frame]')
173
+ : null;
174
+ if (!chartFrame) return;
175
+ const frame = chartFrame.getBoundingClientRect();
176
+ const pointerLeft = event.clientX - frame.left + chartFrame.scrollLeft;
177
+ const pointerTop = event.clientY - frame.top + chartFrame.scrollTop;
178
+ const rightEdge = chartFrame.scrollLeft + chartFrame.clientWidth;
179
+ const bottomEdge = chartFrame.scrollTop + chartFrame.clientHeight;
180
+ bandTooltip = {
181
+ bandId: band.id,
182
+ text,
183
+ left:
184
+ pointerLeft + TOOLTIP_GAP + TOOLTIP_WIDTH > rightEdge
185
+ ? Math.max(chartFrame.scrollLeft, pointerLeft - TOOLTIP_GAP - TOOLTIP_WIDTH)
186
+ : pointerLeft + TOOLTIP_GAP,
187
+ top:
188
+ pointerTop + TOOLTIP_GAP + TOOLTIP_HEIGHT > bottomEdge
189
+ ? Math.max(chartFrame.scrollTop, pointerTop - TOOLTIP_GAP - TOOLTIP_HEIGHT)
190
+ : pointerTop + TOOLTIP_GAP
191
+ };
192
+ } catch (error) {
193
+ workflowsError('Placing the tooltip of a band failed.', error);
194
+ }
195
+ }
196
+
197
+ /** The tooltip that is on the screen: gone when the band it spoke of is no longer drawn (the counts were read again). */
198
+ const shownBandTooltip = $derived(
199
+ bandTooltip && placed.links.some((band) => band.id === bandTooltip?.bandId) ? bandTooltip : null
200
+ );
201
+
202
+ /**
203
+ * Where the tooltip stands, as the two lengths its style takes: from the start of the frame and from its top. The frame is
204
+ * drawn left to right in every language, so its start is its left edge, which is where the pointer was measured from.
205
+ * They are written here, in the script, so that the markup holds no unit text.
206
+ */
207
+ const bandTooltipPlace = $derived(
208
+ shownBandTooltip
209
+ ? { start: `${shownBandTooltip.left}px`, top: `${shownBandTooltip.top}px` }
210
+ : null
211
+ );
142
212
  </script>
143
213
 
144
214
  {#if placed.steps.length > 0}
@@ -149,8 +219,9 @@
149
219
  >
150
220
  <!-- rtl-ok: the chart is a left to right island in every language, like the canvas: the columns are the steps a visitor takes. -->
151
221
  <div
152
- class="min-h-72 flex-1 overflow-auto rounded-large border border-grey2 bg-white font-sans"
222
+ class="relative max-w-content min-h-72 w-full flex-1 overflow-auto rounded-xl border border-border bg-background"
153
223
  dir="ltr"
224
+ data-runs-frame
154
225
  bind:clientWidth={measuredWidth}
155
226
  >
156
227
  <!-- The drawing is for the eyes; the list below says the same numbers to a screen reader. -->
@@ -163,12 +234,20 @@
163
234
  focusable="false"
164
235
  >
165
236
  {#each placed.links as band (band.id)}
237
+ {@const bandWords = describeBand(band)}
166
238
  <!-- svelte-ignore a11y_no_static_element_interactions -->
167
239
  <g
168
- onpointerenter={() => (pointedAt = { kind: 'link', id: band.id })}
169
- onpointerleave={() => (pointedAt = null)}
240
+ data-tooltip={bandWords}
241
+ onpointerenter={(event) => {
242
+ pointedAt = { kind: 'link', id: band.id };
243
+ showBandTooltip(event, band, bandWords);
244
+ }}
245
+ onpointermove={(event) => showBandTooltip(event, band, bandWords)}
246
+ onpointerleave={() => {
247
+ pointedAt = null;
248
+ bandTooltip = null;
249
+ }}
170
250
  >
171
- <title>{describeBand(band)}</title>
172
251
  <path
173
252
  d={band.path}
174
253
  fill="none"
@@ -199,7 +278,7 @@
199
278
  y={step.barY}
200
279
  width={RUNS_FLOW_METRICS.barWidth}
201
280
  height={step.barHeight}
202
- class="fill-primary-green"
281
+ class="fill-primary"
203
282
  />
204
283
  {#if step.stayedHeight > 0}
205
284
  <!-- The visitors who reached the composition and did not go on: hollow, at the bottom of the bar. -->
@@ -208,7 +287,8 @@
208
287
  y={step.stayedY}
209
288
  width={RUNS_FLOW_METRICS.barWidth - 1}
210
289
  height={Math.max(0, step.stayedHeight - 0.5)}
211
- class="fill-grey1 stroke-grey3"
290
+ class="fill-muted stroke-border-strong/30"
291
+ stroke-width="1"
212
292
  />
213
293
  {/if}
214
294
  {:else}
@@ -219,7 +299,8 @@
219
299
  width={RUNS_FLOW_METRICS.barWidth - 1}
220
300
  height={step.barHeight}
221
301
  stroke-dasharray="3 3"
222
- class="fill-none stroke-grey3"
302
+ class="fill-none stroke-border-strong/30"
303
+ stroke-width="1"
223
304
  />
224
305
  {/if}
225
306
  {#if step.failedHeight > 0}
@@ -229,7 +310,7 @@
229
310
  y={step.failedY}
230
311
  width={RUNS_FLOW_METRICS.barWidth}
231
312
  height={step.failedHeight}
232
- class="fill-error"
313
+ class="fill-destructive"
233
314
  />
234
315
  {/if}
235
316
  <!-- The words are HTML in the drawing, so that a long name is cut with an ellipsis and a language that reads right to left is set properly. -->
@@ -242,7 +323,7 @@
242
323
  >
243
324
  <div class="w-fit max-w-full" dir={$textDirection}>
244
325
  <p
245
- class="truncate text-sm leading-5 font-medium text-ink-primary"
326
+ class="truncate text-body-medium text-foreground"
246
327
  dir="auto"
247
328
  title={words.nameStep(step.nodeId)}
248
329
  >
@@ -250,9 +331,10 @@
250
331
  </p>
251
332
  {#each readNumbersOf(step) as line (line.kind)}
252
333
  <p
253
- class="truncate text-xs leading-4 {line.kind === 'failed'
254
- ? 'text-error'
255
- : 'text-ink-muted'}"
334
+ class="truncate text-caption {line.kind === 'failed'
335
+ ? 'text-destructive'
336
+ : 'text-muted-foreground'} {isReasonLine(line.kind) ? 'ps-3' : ''}"
337
+ data-line={line.kind}
256
338
  >
257
339
  {line.text}
258
340
  </p>
@@ -262,6 +344,18 @@
262
344
  </g>
263
345
  {/each}
264
346
  </svg>
347
+
348
+ {#if shownBandTooltip}
349
+ <!-- The tooltip of the band under the mouse (the words are also in the list below, for a screen reader). -->
350
+ <div
351
+ class="pointer-events-none absolute z-10 w-max max-w-60 rounded-lg bg-primary px-3 py-2 text-caption text-primary-foreground"
352
+ style:inset-inline-start={bandTooltipPlace?.start}
353
+ style:top={bandTooltipPlace?.top}
354
+ aria-hidden="true"
355
+ >
356
+ {shownBandTooltip.text}
357
+ </div>
358
+ {/if}
265
359
  </div>
266
360
 
267
361
  <ul class="sr-only">
@@ -145,53 +145,59 @@
145
145
  });
146
146
  </script>
147
147
 
148
- <div class="flex min-h-0 flex-1 flex-col gap-3 p-4">
149
- {#if !hasBeenPublished}
150
- <p class="py-10 text-center text-sm text-ink-muted">{$t('workflows.runs.neverPublished')}</p>
151
- {:else}
152
- <div class="flex flex-wrap items-end gap-3">
153
- <SelectField
154
- class="w-48"
155
- label={$t('workflows.runs.rangeLabel')}
156
- bind:value={rangeDays}
157
- choices={rangeChoices}
158
- onchange={(chosenDays) => reload(Number(chosenDays), versionId)}
159
- />
160
- <SelectField
161
- class="w-56"
162
- label={$t('workflows.runs.versionLabel')}
163
- bind:value={versionId}
164
- choices={versionChoices}
165
- onchange={(chosenVersionId) => reload(Number(rangeDays), chosenVersionId)}
166
- />
167
- {#if startedText}
168
- <p class="pb-2 text-sm" aria-live="polite">{startedText}</p>
148
+ <div class="flex min-h-0 flex-1 flex-col overflow-auto px-4 pb-8 pt-2 @3xl:px-0">
149
+ <div class="mx-auto flex w-full max-w-content flex-col gap-4">
150
+ {#if !hasBeenPublished}
151
+ <!-- The design puts this one line 64px below the tabs: 16 of gap and 48 of room, both steps of the scale. -->
152
+ <p class="my-4 py-12 text-center text-body text-muted-foreground">
153
+ {$t('workflows.runs.neverPublished')}
154
+ </p>
155
+ {:else}
156
+ <!-- The two choices, each with its label above (Figma "filters"), and how many visitors started beside them. -->
157
+ <div class="flex flex-col gap-3 @3xl:flex-row @3xl:items-end">
158
+ <SelectField
159
+ class="w-full min-w-0 @3xl:w-48"
160
+ label={$t('workflows.runs.rangeLabel')}
161
+ bind:value={rangeDays}
162
+ choices={rangeChoices}
163
+ onchange={(chosenDays) => reload(Number(chosenDays), versionId)}
164
+ />
165
+ <SelectField
166
+ class="w-full min-w-0 @3xl:w-56"
167
+ label={$t('workflows.runs.versionLabel')}
168
+ bind:value={versionId}
169
+ choices={versionChoices}
170
+ onchange={(chosenVersionId) => reload(Number(rangeDays), chosenVersionId)}
171
+ />
172
+ {#if startedText}
173
+ <p class="text-body text-foreground @3xl:pb-2" aria-live="polite">{startedText}</p>
174
+ {/if}
175
+ </div>
176
+ <p class="text-caption text-muted-foreground">{$t('workflows.runs.help')}</p>
177
+ <!-- Nobody came in the period: the chart below still shows the place of every bar, empty. -->
178
+ {#if shown && shown.counts.busiest === 0 && loadState === 'ready'}
179
+ <p class="text-caption text-muted-foreground" role="status">{$t('workflows.runs.none')}</p>
180
+ {/if}
181
+ {#if loadState === 'failed'}
182
+ <Notice tone="problem">
183
+ {failureKey ? $t(failureKey) : ''}
184
+ {#snippet action()}
185
+ <ActionButton size="small" onclick={() => void load(Number(rangeDays), versionId)}
186
+ >{$t('workflows.error.retry')}</ActionButton
187
+ >
188
+ {/snippet}
189
+ </Notice>
169
190
  {/if}
170
- </div>
171
- <p class="text-xs text-ink-muted">{$t('workflows.runs.help')}</p>
172
- {#if shown && shown.counts.busiest === 0 && loadState === 'ready'}
173
- <p class="text-xs text-ink-muted" role="status">{$t('workflows.runs.none')}</p>
174
- {/if}
175
191
 
176
- {#if loadState === 'failed'}
177
- <Notice tone="problem">
178
- {failureKey ? $t(failureKey) : ''}
179
- {#snippet action()}
180
- <ActionButton size="small" onclick={() => void load(Number(rangeDays), versionId)}
181
- >{$t('workflows.error.retry')}</ActionButton
182
- >
183
- {/snippet}
184
- </Notice>
192
+ <div class="flex min-h-80 min-w-0 flex-1 flex-col" aria-busy={loadState === 'loading'}>
193
+ {#if shown && flowWords}
194
+ <RunsFlow graph={shown.graph} counts={shown.counts} words={flowWords} />
195
+ {:else if loadState === 'loading'}
196
+ <p class="py-8 text-center text-body text-muted-foreground" role="status">
197
+ {$t('workflows.common.loading')}
198
+ </p>
199
+ {/if}
200
+ </div>
185
201
  {/if}
186
-
187
- <div class="flex min-h-80 flex-1 flex-col" aria-busy={loadState === 'loading'}>
188
- {#if shown && flowWords}
189
- <RunsFlow graph={shown.graph} counts={shown.counts} words={flowWords} />
190
- {:else if loadState === 'loading'}
191
- <p class="py-10 text-center text-sm text-ink-muted" role="status">
192
- {$t('workflows.common.loading')}
193
- </p>
194
- {/if}
195
- </div>
196
- {/if}
202
+ </div>
197
203
  </div>
@@ -0,0 +1,35 @@
1
+ <!--
2
+ One row of the Settings tab (Figma "action / …"): what can be done, said with a title and a line under it, and the button
3
+ that does it at the end of the row. The rows of a section are told apart by a line under each; on a narrow screen the
4
+ button goes under the words and takes the whole width, so a thumb can reach it.
5
+
6
+ The title is red when what the button does cannot be undone (deleting).
7
+ -->
8
+ <script lang="ts">
9
+ import type { Snippet } from 'svelte';
10
+
11
+ interface Props {
12
+ /** What the row is about ("Pause"). */
13
+ title: string;
14
+ /** One sentence that says what the button does. */
15
+ description: string;
16
+ /** `danger` colours the title red; the button the row is given carries its own look. */
17
+ tone?: 'normal' | 'danger';
18
+ /** The button at the end of the row. */
19
+ children: Snippet;
20
+ }
21
+
22
+ let { title, description, tone = 'normal', children }: Props = $props();
23
+ </script>
24
+
25
+ <div
26
+ class="flex flex-col gap-3 border-b border-border py-4 @3xl:flex-row @3xl:items-center @3xl:gap-4"
27
+ >
28
+ <div class="flex min-w-0 flex-1 flex-col gap-0.5">
29
+ <p class="text-body-medium {tone === 'danger' ? 'text-destructive' : 'text-foreground'}">
30
+ {title}
31
+ </p>
32
+ <p class="text-body text-muted-foreground">{description}</p>
33
+ </div>
34
+ {@render children()}
35
+ </div>
@@ -0,0 +1,14 @@
1
+ import type { Snippet } from 'svelte';
2
+ interface Props {
3
+ /** What the row is about ("Pause"). */
4
+ title: string;
5
+ /** One sentence that says what the button does. */
6
+ description: string;
7
+ /** `danger` colours the title red; the button the row is given carries its own look. */
8
+ tone?: 'normal' | 'danger';
9
+ /** The button at the end of the row. */
10
+ children: Snippet;
11
+ }
12
+ declare const SettingsRow: import("svelte").Component<Props, {}, "">;
13
+ type SettingsRow = ReturnType<typeof SettingsRow>;
14
+ export default SettingsRow;
@@ -14,9 +14,9 @@
14
14
  import { useWorkflowsLanguage } from '../../i18n/language.js';
15
15
  import ActionButton from '../ui/ActionButton.svelte';
16
16
  import ConfirmDialog from '../ui/ConfirmDialog.svelte';
17
- import Icon from '../ui/Icon.svelte';
18
17
  import SelectField from '../ui/SelectField.svelte';
19
18
  import type { SelectChoice } from '../ui/types.js';
19
+ import SettingsRow from './SettingsRow.svelte';
20
20
 
21
21
  interface Props {
22
22
  /** Opens the embed code of this workflow; absent when the page that hosts the screen has no such dialog. */
@@ -60,44 +60,55 @@
60
60
  }
61
61
  </script>
62
62
 
63
- <div class="mx-auto flex w-full max-w-2xl flex-col gap-8 overflow-auto p-4 pb-10">
64
- <section class="flex flex-col gap-2" aria-labelledby="{sectionId}-zone">
65
- <h3 id="{sectionId}-zone" class="text-sm font-semibold">
66
- {$t('workflows.settings.zoneHeading')}
67
- </h3>
68
- <SelectField
69
- label={$t('workflows.settings.zoneLabel')}
70
- value={editor.timezone}
71
- choices={zoneChoices}
72
- disabled={editor.isReadOnly}
73
- help={$t('workflows.settings.zoneHelp')}
74
- onchange={(zone) => editor.setTimezone(zone)}
75
- />
76
- </section>
63
+ <div class="mx-auto flex w-full max-w-content flex-col gap-8 px-4 pb-8 pt-2 @3xl:px-0">
64
+ <!-- The time zone: the field is its own section, its label is what names it. -->
65
+ <SelectField
66
+ label={$t('workflows.settings.zoneLabel')}
67
+ value={editor.timezone}
68
+ choices={zoneChoices}
69
+ disabled={editor.isReadOnly}
70
+ help={$t('workflows.settings.zoneHelp')}
71
+ onchange={(zone) => editor.setTimezone(zone)}
72
+ />
77
73
 
78
74
  {#if onshowembedcode && editor.workflow?.everPublished}
79
75
  <section class="flex flex-col gap-2" aria-labelledby="{sectionId}-embed">
80
- <h3 id="{sectionId}-embed" class="text-sm font-semibold">
76
+ <h3 id="{sectionId}-embed" class="text-body-medium text-foreground">
81
77
  {$t('workflows.settings.embedHeading')}
82
78
  </h3>
83
- <p class="text-xs text-ink-muted">{$t('workflows.settings.embedHelp')}</p>
84
- <ActionButton size="small" class="self-start" onclick={onshowembedcode}>
85
- <Icon name="code" />
86
- {$t('workflows.top.embedCode')}
87
- </ActionButton>
79
+ <SettingsRow
80
+ title={$t('workflows.top.embedCode')}
81
+ description={$t('workflows.settings.embedHelp')}
82
+ >
83
+ <ActionButton
84
+ class="w-full shrink-0 @3xl:w-auto"
85
+ size="small"
86
+ disabled={editor.isReadOnly}
87
+ onclick={onshowembedcode}
88
+ >
89
+ {$t('workflows.top.embedCode')}
90
+ </ActionButton>
91
+ </SettingsRow>
88
92
  </section>
89
93
  {/if}
90
94
 
91
- <section class="flex flex-col gap-3" aria-labelledby="{sectionId}-state">
92
- <h3 id="{sectionId}-state" class="text-sm font-semibold">
95
+ <section class="flex flex-col gap-2" aria-labelledby="{sectionId}-state">
96
+ <h3 id="{sectionId}-state" class="text-body-medium text-foreground">
93
97
  {$t('workflows.settings.stateHeading')}
94
98
  </h3>
95
99
 
96
100
  {#if isLiveOrPaused}
97
- <div class="flex flex-col gap-1">
101
+ <SettingsRow
102
+ title={editor.status === 'paused'
103
+ ? $t('workflows.settings.resume')
104
+ : $t('workflows.settings.pause')}
105
+ description={editor.status === 'paused'
106
+ ? $t('workflows.settings.resumeHelp')
107
+ : $t('workflows.settings.pauseHelp')}
108
+ >
98
109
  <ActionButton
110
+ class="w-full shrink-0 @3xl:w-auto"
99
111
  size="small"
100
- class="self-start"
101
112
  disabled={!editor.canChangeWorkflow}
102
113
  onclick={() => void editor.changeState(editor.status === 'paused' ? 'resume' : 'pause')}
103
114
  >
@@ -105,64 +116,68 @@
105
116
  ? $t('workflows.settings.resume')
106
117
  : $t('workflows.settings.pause')}
107
118
  </ActionButton>
108
- <p class="text-xs text-ink-muted">
109
- {editor.status === 'paused'
110
- ? $t('workflows.settings.resumeHelp')
111
- : $t('workflows.settings.pauseHelp')}
112
- </p>
113
- </div>
119
+ </SettingsRow>
114
120
  {/if}
115
121
 
116
- <div class="flex flex-col gap-1">
117
- {#if editor.status === 'archived'}
122
+ {#if editor.status === 'archived'}
123
+ <SettingsRow
124
+ title={$t('workflows.settings.unarchive')}
125
+ description={$t('workflows.settings.unarchiveHelp')}
126
+ >
118
127
  <ActionButton
128
+ class="w-full shrink-0 @3xl:w-auto"
119
129
  size="small"
120
- class="self-start"
121
130
  disabled={!editor.canChangeWorkflow}
122
131
  onclick={() => void editor.changeState('unarchive')}
123
132
  >
124
133
  {$t('workflows.settings.unarchive')}
125
134
  </ActionButton>
126
- <p class="text-xs text-ink-muted">{$t('workflows.settings.unarchiveHelp')}</p>
127
- {:else if editor.workflow?.everPublished}
135
+ </SettingsRow>
136
+ {:else if editor.workflow?.everPublished}
137
+ <SettingsRow
138
+ title={$t('workflows.settings.archive')}
139
+ description={$t('workflows.settings.archiveHelp')}
140
+ >
128
141
  <ActionButton
142
+ class="w-full shrink-0 @3xl:w-auto"
129
143
  size="small"
130
- class="self-start"
131
144
  disabled={!editor.canChangeWorkflow}
132
145
  onclick={() => (asking = 'archive')}
133
146
  >
134
147
  {$t('workflows.settings.archive')}
135
148
  </ActionButton>
136
- <p class="text-xs text-ink-muted">{$t('workflows.settings.archiveHelp')}</p>
137
- {/if}
138
- </div>
149
+ </SettingsRow>
150
+ {/if}
139
151
 
140
- <div class="flex flex-col gap-1">
152
+ <SettingsRow
153
+ title={$t('workflows.settings.duplicate')}
154
+ description={$t('workflows.settings.duplicateHelp')}
155
+ >
141
156
  <ActionButton
157
+ class="w-full shrink-0 @3xl:w-auto"
142
158
  size="small"
143
- class="self-start"
144
159
  disabled={editor.busy !== null}
145
160
  onclick={() => void editor.duplicate()}
146
161
  >
147
- <Icon name="copy" />
148
162
  {$t('workflows.settings.duplicate')}
149
163
  </ActionButton>
150
- <p class="text-xs text-ink-muted">{$t('workflows.settings.duplicateHelp')}</p>
151
- </div>
164
+ </SettingsRow>
152
165
 
153
- <div class="flex flex-col gap-1">
166
+ <SettingsRow
167
+ tone="danger"
168
+ title={$t('workflows.settings.delete')}
169
+ description={$t('workflows.settings.deleteHelp')}
170
+ >
154
171
  <ActionButton
172
+ class="w-full shrink-0 @3xl:w-auto"
155
173
  variant="danger"
156
174
  size="small"
157
- class="self-start"
158
175
  disabled={!editor.canChangeWorkflow}
159
176
  onclick={() => (asking = 'delete')}
160
177
  >
161
- <Icon name="trash" />
162
178
  {$t('workflows.settings.delete')}
163
179
  </ActionButton>
164
- <p class="text-xs text-ink-muted">{$t('workflows.settings.deleteHelp')}</p>
165
- </div>
180
+ </SettingsRow>
166
181
  </section>
167
182
  </div>
168
183
 
@@ -171,6 +186,7 @@
171
186
  title={$t('workflows.settings.archiveTitle')}
172
187
  message={$t('workflows.settings.archiveMessage')}
173
188
  confirmLabel={$t('workflows.settings.archive')}
189
+ tone="normal"
174
190
  busy={editor.busy === 'changingState'}
175
191
  onconfirm={() => void confirmArchive()}
176
192
  oncancel={() => (asking = null)}