@widgetic/editor 4.1.14 → 4.1.15

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 (76) hide show
  1. package/dist/components/PreviewChromeControls.svelte +15 -21
  2. package/dist/components/WidgetPreview.svelte +136 -105
  3. package/dist/components/color-select/ColorSelect.svelte +203 -224
  4. package/dist/components/color-select/constants.d.ts +4 -2
  5. package/dist/components/color-select/constants.js +4 -2
  6. package/dist/components/color-select/render.js +10 -9
  7. package/dist/components/editors/CompositionEditorApp.svelte +47 -40
  8. package/dist/components/editors/EditLeaseNotice.svelte +44 -33
  9. package/dist/components/editors/EmbedEditor.svelte +133 -259
  10. package/dist/components/editors/PropsEditor.svelte +418 -1338
  11. package/dist/components/editors/props-editor.css +5 -68
  12. package/dist/components/ic/AngleInputController.svelte +202 -277
  13. package/dist/components/ic/BrowserInputController.svelte +813 -803
  14. package/dist/components/ic/CheckboxInputController.svelte +92 -169
  15. package/dist/components/ic/CheckboxInputController.svelte.d.ts +2 -8
  16. package/dist/components/ic/ColorPickerInputController.svelte +1589 -1587
  17. package/dist/components/ic/ColorPickerInputController.svelte.d.ts +3 -3
  18. package/dist/components/ic/DateFieldInputController.svelte +455 -465
  19. package/dist/components/ic/DatePickerInputController.svelte +355 -368
  20. package/dist/components/ic/DatePickerInputController.svelte.d.ts +1 -1
  21. package/dist/components/ic/DropdownInputController.svelte +130 -200
  22. package/dist/components/ic/FixedPositionInputController.svelte +255 -276
  23. package/dist/components/ic/FixedPositionInputController.svelte.d.ts +5 -1
  24. package/dist/components/ic/FontInputController.svelte +2110 -2231
  25. package/dist/components/ic/FontInputController.svelte.d.ts +11 -11
  26. package/dist/components/ic/InputControllerHeader.svelte +141 -147
  27. package/dist/components/ic/InputControllerRow.svelte +74 -0
  28. package/dist/components/ic/InputControllerRow.svelte.d.ts +14 -0
  29. package/dist/components/ic/KnowledgeDocumentsInputController.svelte +84 -47
  30. package/dist/components/ic/KnowledgeTextForm.svelte +35 -33
  31. package/dist/components/ic/NumberControls.svelte +303 -269
  32. package/dist/components/ic/NumberControls.svelte.d.ts +4 -1
  33. package/dist/components/ic/NumberInputController.svelte +361 -301
  34. package/dist/components/ic/NumberInputController.svelte.d.ts +2 -0
  35. package/dist/components/ic/PositionInputController.svelte +253 -176
  36. package/dist/components/ic/PositionInputController.svelte.d.ts +2 -0
  37. package/dist/components/ic/RadioGroupInputController.svelte +71 -137
  38. package/dist/components/ic/RadioGroupInputController.svelte.d.ts +2 -8
  39. package/dist/components/ic/RangeCalendarInputController.svelte +233 -270
  40. package/dist/components/ic/RangeCalendarInputController.svelte.d.ts +2 -2
  41. package/dist/components/ic/RoundedCornersInputController.svelte +412 -435
  42. package/dist/components/ic/RoundedCornersInputController.svelte.d.ts +2 -0
  43. package/dist/components/ic/SliderInputController.svelte +263 -332
  44. package/dist/components/ic/SliderInputController.svelte.d.ts +1 -1
  45. package/dist/components/ic/SliderRangeInputController.svelte +140 -144
  46. package/dist/components/ic/SliderRangeInputController.svelte.d.ts +3 -3
  47. package/dist/components/ic/SwitchInputController.svelte +47 -109
  48. package/dist/components/ic/TagsInputController.svelte +95 -110
  49. package/dist/components/ic/TextAreaInputController.svelte +1794 -1935
  50. package/dist/components/ic/TextAreaPreviewInputController.svelte +436 -438
  51. package/dist/components/ic/TextAreaPreviewInputController.svelte.d.ts +2 -2
  52. package/dist/components/ic/TextInputController.svelte +65 -75
  53. package/dist/components/ic/TextInputController.svelte.d.ts +2 -0
  54. package/dist/components/ic/TimeInputController.svelte +433 -431
  55. package/dist/components/ic/VectorInputController.svelte +1833 -1831
  56. package/dist/components/ic/VectorInputController.svelte.d.ts +10 -10
  57. package/dist/components/ic/index.d.ts +1 -0
  58. package/dist/components/ic/index.js +1 -0
  59. package/dist/components/ic/shared/CategoryTabs.svelte +28 -35
  60. package/dist/components/ic/shared/ItemGrid.svelte +145 -179
  61. package/dist/components/ic/shared/RecentItemsSection.svelte +208 -271
  62. package/dist/components/ic/shared/RecentItemsSection.svelte.d.ts +1 -1
  63. package/dist/components/ui/arrows/OpacitySliderArrows.svelte +23 -38
  64. package/dist/components/ui/arrows/OpacitySliderArrows.svelte.d.ts +1 -4
  65. package/dist/components/ui/calendar-editor-fit/EditorCalendarStyles.svelte +45 -0
  66. package/dist/components/ui/calendar-editor-fit/EditorCalendarStyles.svelte.d.ts +26 -0
  67. package/dist/components/ui/checkerboard-background/CheckerboardBackground.svelte +20 -12
  68. package/dist/components/ui/shadow-picker-host/ShadowPickerHost.svelte +39 -0
  69. package/dist/components/ui/shadow-picker-host/ShadowPickerHost.svelte.d.ts +10 -0
  70. package/dist/i18n/language.d.ts +43 -36
  71. package/dist/i18n/messages.d.ts +41 -34
  72. package/dist/i18n/messages.js +47 -34
  73. package/dist/i18n/translate.d.ts +1 -1
  74. package/dist/utils.d.ts +7 -0
  75. package/dist/utils.js +26 -2
  76. package/package.json +4 -4
@@ -1,4 +1,6 @@
1
1
  <script lang="ts">
2
+ import { IconDeviceDesktop, IconDeviceMobile } from '@widgetic/design-system/icons';
3
+
2
4
  let className = '';
3
5
  export { className as class };
4
6
  export let style = '';
@@ -21,49 +23,51 @@
21
23
 
22
24
  <div class="preview-chrome-controls flex items-center gap-2 {className}" style={style}>
23
25
  {#if showDevices}
24
- <div class="preview-chrome-device-toggle flex shrink-0 items-center overflow-hidden rounded border border-gray-300">
26
+ <!-- The segmented control of the design system (the Tabs look): a soft track, and the pressed device raised on the page colour. -->
27
+ <div class="preview-chrome-device-toggle flex shrink-0 items-center gap-0.5 rounded-xl bg-accent p-0.5">
25
28
  <button
26
29
  type="button"
27
- class="preview-chrome-device-desktop flex h-6 w-6 items-center justify-center {!mobile ? 'bg-gray-100 text-gray-800' : 'bg-white text-gray-400'} hover:text-gray-800 focus:outline-none focus-visible:outline-none"
30
+ class="preview-chrome-device-desktop flex size-6 items-center justify-center rounded-lg transition-colors duration-fast focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-ring {!mobile ? 'bg-background text-foreground' : 'text-muted-foreground hover:text-foreground'}"
28
31
  aria-label={desktopLabel}
29
32
  aria-pressed={!mobile}
30
33
  onclick={() => onDevice(false)}
31
34
  onpointerdown={(event) => event.stopPropagation()}
32
35
  >
33
- <svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><rect x="2" y="3" width="20" height="14" rx="2" ry="2"/><line x1="8" y1="21" x2="16" y2="21"/><line x1="12" y1="17" x2="12" y2="21"/></svg>
36
+ <IconDeviceDesktop class="size-4 stroke-[1.333]" aria-hidden="true" />
34
37
  </button>
35
38
  <button
36
39
  type="button"
37
- class="preview-chrome-device-mobile flex h-6 w-6 items-center justify-center border-s border-gray-300 {mobile ? 'bg-gray-100 text-gray-800' : 'bg-white text-gray-400'} hover:text-gray-800 focus:outline-none focus-visible:outline-none"
40
+ class="preview-chrome-device-mobile flex size-6 items-center justify-center rounded-lg transition-colors duration-fast focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-ring {mobile ? 'bg-background text-foreground' : 'text-muted-foreground hover:text-foreground'}"
38
41
  aria-label={mobileLabel}
39
42
  aria-pressed={mobile}
40
43
  onclick={() => onDevice(true)}
41
44
  onpointerdown={(event) => event.stopPropagation()}
42
45
  >
43
- <svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><rect x="5" y="2" width="14" height="20" rx="2" ry="2"/><line x1="12" y1="18" x2="12.01" y2="18"/></svg>
46
+ <IconDeviceMobile class="size-4 stroke-[1.333]" aria-hidden="true" />
44
47
  </button>
45
48
  </div>
46
49
  {/if}
47
50
  {#if showDimensions}
48
- <div class="preview-chrome-dimensions flex items-center gap-1.5">
49
- <label class="preview-dim-label flex items-center gap-1 text-[10px] font-semibold text-gray-500">
51
+ <!-- The width and the height are soft fields of the design system (the "Width / Height" card of the Figma Editor page). -->
52
+ <div class="preview-chrome-dimensions flex items-center gap-2">
53
+ <label class="preview-dim-label flex items-center gap-1 text-caption text-muted-foreground">
50
54
  <span>{widthLabel}</span>
51
55
  <input
52
56
  type="number"
53
57
  min={minWidth}
54
- class="preview-dim-input w-14 h-6 rounded border border-gray-300 bg-white px-1 text-[11px] text-gray-800 focus:outline-none focus:border-blue-400 focus-visible:outline-none"
58
+ class="preview-dim-input h-6 w-14 rounded-lg border-0 bg-accent px-2 text-caption text-foreground transition-colors duration-fast hover:bg-accent-hover focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-ring"
55
59
  value={widthValue}
56
60
  oninput={(event) => onWidth(event.currentTarget.value)}
57
61
  onpointerdown={(event) => event.stopPropagation()}
58
62
  />
59
63
  </label>
60
- <span class="text-[10px] text-gray-400">×</span>
61
- <label class="preview-dim-label flex items-center gap-1 text-[10px] font-semibold text-gray-500">
64
+ <span class="text-caption text-muted-foreground" aria-hidden="true">×</span>
65
+ <label class="preview-dim-label flex items-center gap-1 text-caption text-muted-foreground">
62
66
  <span>{heightLabel}</span>
63
67
  <input
64
68
  type="number"
65
69
  min={minHeight}
66
- class="preview-dim-input w-14 h-6 rounded border border-gray-300 bg-white px-1 text-[11px] text-gray-800 focus:outline-none focus:border-blue-400 focus-visible:outline-none"
70
+ class="preview-dim-input h-6 w-14 rounded-lg border-0 bg-accent px-2 text-caption text-foreground transition-colors duration-fast hover:bg-accent-hover focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-ring"
67
71
  value={heightValue}
68
72
  oninput={(event) => onHeight(event.currentTarget.value)}
69
73
  onpointerdown={(event) => event.stopPropagation()}
@@ -72,13 +76,3 @@
72
76
  </div>
73
77
  {/if}
74
78
  </div>
75
-
76
- <style>
77
- .preview-chrome-controls button:focus,
78
- .preview-chrome-controls button:focus-visible,
79
- .preview-chrome-controls input:focus,
80
- .preview-chrome-controls input:focus-visible {
81
- outline: none;
82
- box-shadow: none;
83
- }
84
- </style>
@@ -1,6 +1,20 @@
1
1
  <script lang="ts">
2
2
  import { onMount, onDestroy, createEventDispatcher, tick } from 'svelte';
3
- import { GenerateLoader } from '@widgetic/design-system/components';
3
+ import { Button, GenerateLoader, IconButton } from '@widgetic/design-system/components';
4
+ import {
5
+ IconAlertTriangle,
6
+ IconArrowsDiagonal,
7
+ IconCopy,
8
+ IconDeviceDesktop,
9
+ IconDeviceMobile,
10
+ IconExternalLink,
11
+ IconGripVertical,
12
+ IconListDetails,
13
+ IconPhoto,
14
+ IconRefresh,
15
+ IconRocket,
16
+ IconTool
17
+ } from '@widgetic/design-system/icons';
4
18
  import { lockPointerStyle } from '../utils/shadowDom';
5
19
  import { useEditorLanguage } from '../i18n/language';
6
20
  import PreviewChromeControls from './PreviewChromeControls.svelte';
@@ -125,11 +139,12 @@
125
139
  /** Inset so resize handles stay inside bounds. 0 sits the frame on the stage edge. */
126
140
  export let edgeInset = 12;
127
141
  const PREVIEW_CHROME_HEADER_H = 36;
128
- const PREVIEW_STROKE = '#3b82f6';
129
- const PREVIEW_STROKE_ALT = '#f97316';
142
+ // The frame of the preview is drawn in the design system's own colours: the main colour, and the brand one while Alt is held.
143
+ const PREVIEW_STROKE = 'var(--primary)';
144
+ const PREVIEW_STROKE_ALT = 'var(--brand)';
130
145
  let isResizing = false;
131
146
  let isDraggingPreview = false;
132
- /** Alt held — keeps orange stroke on composition even after pointerup. */
147
+ /** Alt held — keeps the alternate stroke (the brand colour, orange before the redesign) on composition even after pointerup. */
133
148
  let isAltKeyDown = false;
134
149
  let previewShellLeft = 0;
135
150
  let previewShellTop = 0;
@@ -725,7 +740,7 @@
725
740
 
726
741
  function endResize() {
727
742
  isResizing = false;
728
- // Keep orange stroke while Alt remains held (composition corner mode).
743
+ // Keep the alternate stroke (the brand colour) while Alt remains held (composition corner mode).
729
744
  finishPointerGesture?.();
730
745
  if (resizeWidth != null && resizeHeight != null) {
731
746
  dispatch('resize', { width: resizeWidth, height: resizeHeight, source: 'drag' });
@@ -807,96 +822,103 @@
807
822
  style="{style ? style + ';' : ''}{hasFixedBounds ? `width: ${boundsWidth}px;` : mode === 'standalone' && !showUrlBar ? `width: ${width}; height: ${height};` : ''}"
808
823
  >
809
824
  {#if showUrlBar}
810
- <div class="preview-content-url-bar flex items-center gap-1.5 pb-1.5 min-w-0">
825
+ <!-- The address bar uses the design system's field and buttons: the address is a soft read-only field, each action an outline icon button. -->
826
+ <div class="preview-content-url-bar flex items-center gap-2 pb-2 min-w-0">
811
827
  <span
812
- class="preview-url-text flex-1 rounded border border-gray-300 px-2 py-1 text-xs text-gray-500 min-w-0 font-mono overflow-x-auto whitespace-nowrap"
828
+ class="preview-url-text flex-1 rounded-lg border border-input bg-background px-3 py-1.5 text-caption text-muted-foreground min-w-0 font-mono overflow-x-auto whitespace-nowrap"
813
829
  >
814
830
  {effectiveDisplayUrl || effectiveSrc || $t('editor.preview.noUrl')}
815
831
  </span>
816
- <button
817
- type="button"
832
+ <IconButton
833
+ variant="outline"
834
+ label={$t('editor.preview.copyUrl')}
835
+ title={$t('editor.preview.copyUrl')}
818
836
  onclick={() => {
819
837
  const url = effectiveDisplayUrl || effectiveSrc;
820
838
  if (url) navigator.clipboard.writeText(url);
821
839
  }}
822
- title={$t('editor.preview.copyUrl')}
823
- class="shrink-0 w-7 h-7 flex items-center justify-center rounded border border-gray-300 bg-white hover:bg-gray-100 text-sm cursor-pointer"
824
840
  >
825
- <svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="9" y="9" width="13" height="13" rx="2" ry="2"/><path d="M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"/></svg>
826
- </button>
841
+ <IconCopy />
842
+ </IconButton>
827
843
  {#if showUrlBarButtons}
828
- <button
829
- type="button"
830
- onclick={handleRefreshClick}
844
+ <IconButton
845
+ variant="outline"
846
+ label={$t('editor.preview.refresh')}
831
847
  title={$t('editor.preview.refresh')}
832
- class="shrink-0 w-7 h-7 flex items-center justify-center rounded border border-gray-300 bg-white hover:bg-gray-100 text-sm cursor-pointer"
833
- >🔄</button>
848
+ onclick={handleRefreshClick}
849
+ >
850
+ <IconRefresh />
851
+ </IconButton>
834
852
  {#if showViewportButtons && enableResize}
835
- <button
836
- type="button"
837
- onclick={handleFitToAreaClick}
853
+ <IconButton
854
+ variant="outline"
855
+ class="preview-fit-to-area-btn"
856
+ label={$t('editor.preview.fitToPanel')}
838
857
  title={$t('editor.preview.fitToPanel')}
839
- class="preview-fit-to-area-btn shrink-0 w-7 h-7 flex items-center justify-center rounded border border-gray-300 bg-white hover:bg-gray-100 cursor-pointer"
858
+ onclick={handleFitToAreaClick}
840
859
  >
841
- <svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M15 3h6v6"/><path d="M9 21H3v-6"/><path d="M21 3l-7 7"/><path d="M3 21l7-7"/></svg>
842
- </button>
843
- <button
844
- type="button"
845
- onclick={applyMobileViewport}
860
+ <IconArrowsDiagonal />
861
+ </IconButton>
862
+ <IconButton
863
+ variant="outline"
864
+ class="preview-mobile-viewport-btn"
865
+ label={$t('editor.preview.mobileViewport')}
846
866
  title={$t('editor.preview.mobileViewport')}
847
- class="preview-mobile-viewport-btn shrink-0 w-7 h-7 flex items-center justify-center rounded border border-gray-300 bg-white hover:bg-gray-100 cursor-pointer"
867
+ onclick={applyMobileViewport}
848
868
  >
849
- <svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="5" y="2" width="14" height="20" rx="2" ry="2"/><line x1="12" y1="18" x2="12.01" y2="18"/></svg>
850
- </button>
851
- <button
852
- type="button"
853
- onclick={handleDesktopViewport}
869
+ <IconDeviceMobile />
870
+ </IconButton>
871
+ <IconButton
872
+ variant="outline"
873
+ class="preview-desktop-viewport-btn"
874
+ label={$t('editor.preview.desktopViewport')}
854
875
  title={$t('editor.preview.desktopViewport')}
855
- class="preview-desktop-viewport-btn shrink-0 w-7 h-7 flex items-center justify-center rounded border border-gray-300 bg-white hover:bg-gray-100 cursor-pointer"
876
+ onclick={handleDesktopViewport}
856
877
  >
857
- <svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="2" y="3" width="20" height="14" rx="2" ry="2"/><line x1="8" y1="21" x2="16" y2="21"/><line x1="12" y1="17" x2="12" y2="21"/></svg>
858
- </button>
878
+ <IconDeviceDesktop />
879
+ </IconButton>
859
880
  {/if}
860
- <button
861
- type="button"
862
- onclick={handleOpenInTabClick}
881
+ <Button
882
+ variant="outline"
883
+ size="sm"
863
884
  title={$t('editor.preview.openInNewTab')}
864
- class="shrink-0 px-2 h-7 flex items-center justify-center rounded border border-gray-300 bg-white hover:bg-gray-100 text-xs cursor-pointer whitespace-nowrap"
865
- >{$t('editor.preview.newTab')}</button>
885
+ onclick={handleOpenInTabClick}
886
+ >
887
+ <IconExternalLink />
888
+ {$t('editor.preview.newTab')}
889
+ </Button>
866
890
  {/if}
867
891
  </div>
868
892
  {/if}
869
893
 
870
894
  <div
871
895
  bind:this={contentContainerEl}
872
- class="preview-content-container relative flex items-center justify-center {containerOverflowClass} {hasFixedBounds ? 'rounded-lg bg-gray-50 border border-gray-300 shrink-0' : compactChrome ? 'flex-1 min-h-0 h-full' : showUrlBar || mode === 'controlled' ? 'flex-1 min-h-0 rounded-lg bg-gray-50 border border-gray-300' : 'flex-1 min-h-0 h-full'}"
896
+ class="preview-content-container relative flex items-center justify-center {containerOverflowClass} {hasFixedBounds ? 'rounded-lg bg-muted border border-border shrink-0' : compactChrome ? 'flex-1 min-h-0 h-full' : showUrlBar || mode === 'controlled' ? 'flex-1 min-h-0 rounded-lg bg-muted border border-border' : 'flex-1 min-h-0 h-full'}"
873
897
  style="{boundedContainerStyle}{containerPaddingStyle}{contentHeight && (showUrlBar || mode === 'controlled') && !compactChrome && !hasFixedBounds ? ` min-height: 0;` : ''}"
874
898
  >
875
899
  {#if forceMockReady}
876
- <div class="flex flex-col items-center justify-center w-full h-full bg-gray-100 text-gray-500">
877
- <div class="text-4xl mb-2">🚀</div>
878
- <div class="font-semibold">Mock Preview Mode</div>
879
- <div class="text-sm">Preview simulated as Ready. URL: about:blank</div>
900
+ <div class="flex flex-col items-center justify-center gap-1 w-full h-full bg-muted text-muted-foreground">
901
+ <IconRocket class="mb-2 size-8 stroke-[1.333]" aria-hidden="true" />
902
+ <div class="text-body-medium text-foreground">Mock Preview Mode</div>
903
+ <div class="text-body">Preview simulated as Ready. URL: about:blank</div>
880
904
  </div>
881
905
 
882
906
  {:else if mode === 'standalone' && !widget}
883
- <div class="widget-preview-select-ct flex items-center justify-center h-full text-sm text-gray-400">
907
+ <div class="widget-preview-select-ct flex items-center justify-center h-full text-body text-muted-foreground">
884
908
  {$t('editor.preview.selectWidget')}
885
909
  </div>
886
910
 
887
911
  {:else if mode === 'standalone' && widget && !effectiveSrc && !isResolvingUrl && !iframeError}
888
912
  <div class="widget-preview-unpublished-ct flex items-center justify-center h-full w-full">
889
913
  <div class="widget-preview-unpublished-content-ct flex flex-col items-center gap-3 text-center px-6">
890
- <div class="w-10 h-10 rounded-full bg-amber-50 flex items-center justify-center">
891
- <svg class="w-5 h-5 text-amber-400" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2">
892
- <path stroke-linecap="round" stroke-linejoin="round" d="M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-2.5L13.732 4.5c-.77-.833-2.694-.833-3.464 0L3.34 16.5c-.77.833.192 2.5 1.732 2.5z" />
893
- </svg>
914
+ <div class="size-12 rounded-xl bg-brand-subtle flex items-center justify-center">
915
+ <IconAlertTriangle class="size-5 stroke-[1.333] text-foreground" aria-hidden="true" />
894
916
  </div>
895
917
  <div>
896
- <p class="text-sm font-medium text-gray-600">{widget.name || $t('editor.preview.widgetName')}</p>
897
- <p class="text-xs text-gray-400 mt-1">{$t('editor.preview.notPublished')}</p>
918
+ <p class="text-body-medium text-foreground">{widget.name || $t('editor.preview.widgetName')}</p>
919
+ <p class="text-caption text-muted-foreground mt-1">{$t('editor.preview.notPublished')}</p>
898
920
  </div>
899
- <p class="text-[11px] text-gray-300 max-w-[220px]">
921
+ <p class="text-caption text-muted-foreground max-w-[220px]">
900
922
  {$t('editor.preview.publishToPreview')}
901
923
  </p>
902
924
  </div>
@@ -935,14 +957,14 @@
935
957
  {#if showPreviewChrome}
936
958
  <!-- svelte-ignore a11y_no_static_element_interactions -->
937
959
  <div
938
- class="preview-chrome-header flex items-center gap-2 h-9 px-2 border border-b-0 rounded-t-md bg-white select-none {enableDrag ? 'cursor-move' : ''}"
960
+ class="preview-chrome-header flex items-center gap-2 h-9 px-2 border border-b-0 rounded-t-md bg-background select-none {enableDrag ? 'cursor-move' : ''}"
939
961
  style="border-color: {previewStrokeColor};"
940
962
  onpointerdown={startPreviewDrag}
941
963
  >
942
964
  {#if enableDrag}
943
- <span class="preview-chrome-drag-grip shrink-0 text-gray-400 text-xs leading-none" title={$t('editor.preview.dragHandle')} aria-hidden="true">⠿</span>
965
+ <span class="preview-chrome-drag-grip shrink-0 text-muted-foreground leading-none" title={$t('editor.preview.dragHandle')} aria-hidden="true"><IconGripVertical class="size-4 stroke-[1.333]" /></span>
944
966
  {/if}
945
- <span class="preview-chrome-title text-[11px] font-semibold uppercase tracking-wide text-gray-500 shrink-0">{$t('editor.preview.title')}</span>
967
+ <span class="preview-chrome-title text-label text-muted-foreground shrink-0">{$t('editor.preview.title')}</span>
946
968
  <PreviewChromeControls
947
969
  class="{showChromeDeviceToggle || showDimensionInputs ? 'ms-auto' : ''}"
948
970
  mobile={deviceMobile}
@@ -976,7 +998,7 @@
976
998
 
977
999
  {#if (resizeWidth || resizeHeight) && !showDimensionInputs}
978
1000
  <div
979
- class="widget-preview-dimension-badge absolute left-1/2 -translate-x-1/2 text-[10px] bg-black/70 px-1.5 py-px rounded text-gray-300 select-none pointer-events-none z-20 whitespace-nowrap"
1001
+ class="widget-preview-dimension-badge absolute left-1/2 -translate-x-1/2 text-caption bg-foreground/80 px-2 py-0.5 rounded-lg text-background select-none pointer-events-none z-20 whitespace-nowrap"
980
1002
  style="top: calc(100% + 4px);"
981
1003
  >
982
1004
  {resizeWidth != null ? Math.round(resizeWidth) + 'px' : '100%'} × {resizeHeight != null ? Math.round(resizeHeight) + 'px' : '100%'}
@@ -988,36 +1010,36 @@
988
1010
  style={enableResize ? `border-color: ${previewStrokeColor}; border-radius: ${showPreviewChrome ? '0 0 6px 6px' : '6px'};` : ''}
989
1011
  >
990
1012
  {#if mode === 'standalone' && iframeError}
991
- <div class="widget-preview-error-ct absolute inset-0 flex items-center justify-center bg-white z-10 rounded">
1013
+ <div class="widget-preview-error-ct absolute inset-0 flex items-center justify-center bg-background z-10 rounded">
992
1014
  <div class="widget-preview-error-content-ct flex flex-col items-center gap-2 text-center px-4">
993
- <svg class="w-8 h-8 text-gray-300" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="1.5">
994
- <path stroke-linecap="round" stroke-linejoin="round" d="M12 9v3.75m9-.75a9 9 0 11-18 0 9 9 0 0118 0zm-9 3.75h.008v.008H12v-.008z" />
995
- </svg>
996
- <span class="text-sm text-gray-500">{$t('editor.preview.loadFailedPreview')}</span>
1015
+ <IconAlertTriangle class="size-6 stroke-[1.333] text-muted-foreground" aria-hidden="true" />
1016
+ <span class="text-body text-muted-foreground">{$t('editor.preview.loadFailedPreview')}</span>
997
1017
  </div>
998
1018
  </div>
999
1019
  {:else if mode === 'controlled' && previewError && !isGeneratingCode}
1000
- <div class="preview-error-overlay absolute inset-0 z-10 flex h-full flex-col items-center justify-center bg-red-50/95 text-gray-700 p-6">
1001
- <div class="text-4xl mb-3">⚠️</div>
1002
- <div class="font-semibold text-lg text-red-600 mb-2">{$t('editor.preview.unavailable')}</div>
1003
- <div class="text-sm text-center max-w-md whitespace-pre-line text-gray-600 mb-4">{previewError}</div>
1004
- <div class="flex gap-3">
1005
- <button type="button" onclick={() => dispatch('retry')} class="px-3 py-1.5 text-xs rounded border border-blue-500 text-blue-600 bg-white hover:bg-blue-50 cursor-pointer">
1006
- 🔄 {$t('editor.preview.retry')} {previewRetryCount > 0 ? `(${previewRetryCount})` : ''}
1007
- </button>
1008
- <button type="button" onclick={() => dispatch('openInTab')} class="px-3 py-1.5 text-xs rounded border border-gray-300 text-gray-600 bg-white hover:bg-gray-100 cursor-pointer">
1020
+ <!-- The failed preview is the "Widget error" state of the Figma Composition Pages page: an icon, what happened, what to do. -->
1021
+ <div class="preview-error-overlay absolute inset-0 z-10 flex h-full flex-col items-center justify-center gap-3 bg-background text-center p-6">
1022
+ <IconAlertTriangle class="size-6 stroke-[1.333] text-destructive" aria-hidden="true" />
1023
+ <div class="text-body-medium text-foreground">{$t('editor.preview.unavailable')}</div>
1024
+ <div class="max-w-md whitespace-pre-line text-body text-muted-foreground">{previewError}</div>
1025
+ <div class="flex flex-wrap justify-center gap-2">
1026
+ <Button size="sm" onclick={() => dispatch('retry')}>
1027
+ <IconRefresh />
1028
+ {$t('editor.preview.retry')} {previewRetryCount > 0 ? `(${previewRetryCount})` : ''}
1029
+ </Button>
1030
+ <Button size="sm" variant="outline" onclick={() => dispatch('openInTab')}>
1009
1031
  {$t('editor.preview.openInNewTab')}
1010
- </button>
1032
+ </Button>
1011
1033
  </div>
1012
1034
  </div>
1013
1035
  {/if}
1014
1036
 
1015
1037
  {#if showStandaloneLoading}
1016
- <div class="widget-preview-loading-ct absolute inset-0 z-10 flex items-center justify-center bg-gray-50/80">
1038
+ <div class="widget-preview-loading-ct absolute inset-0 z-10 flex items-center justify-center bg-background/80">
1017
1039
  <GenerateLoader title={$t('editor.preview.loadingWidget')} subtitle="" size="md" />
1018
1040
  </div>
1019
1041
  {:else if showControlledLoading && !isGeneratingCode}
1020
- <div class="loading-overlay absolute inset-0 z-20 flex items-center justify-center bg-gray-50">
1042
+ <div class="loading-overlay absolute inset-0 z-20 flex items-center justify-center bg-background">
1021
1043
  <GenerateLoader
1022
1044
  title={$t('editor.preview.loadingPreview')}
1023
1045
  subtitle={!src && isLoadingUrl
@@ -1031,21 +1053,30 @@
1031
1053
  {/if}
1032
1054
 
1033
1055
  {#if mode === 'controlled' && previewHasRuntimeError && !isGeneratingCode}
1034
- <div class="compilation-error-overlay absolute inset-0 z-20 flex flex-col items-center justify-center bg-red-50 text-red-700 p-6">
1035
- <div class="text-5xl mb-4">⚠️</div>
1036
- <div class="font-semibold text-xl mb-2">
1056
+ <div class="compilation-error-overlay absolute inset-0 z-20 flex flex-col items-center justify-center gap-3 bg-background text-center p-6">
1057
+ <IconAlertTriangle class="size-6 stroke-[1.333] text-destructive" aria-hidden="true" />
1058
+ <div class="text-body-medium text-foreground">
1037
1059
  {previewError && /TypeError|Uncaught|is not a function|is not defined/i.test(previewError)
1038
1060
  ? $t('editor.preview.runtimeError')
1039
1061
  : $t('editor.preview.compilationErrors')}
1040
1062
  </div>
1041
- <div class="text-sm text-center text-red-600 mb-4 max-w-md whitespace-pre-line">
1063
+ <div class="max-w-md whitespace-pre-line text-body text-muted-foreground">
1042
1064
  {previewError
1043
1065
  || $t('editor.preview.compilationErrorsDetail', { status: previewRuntimeErrorStatus ?? '?' })}
1044
1066
  </div>
1045
- <div class="flex gap-3 flex-wrap justify-center">
1046
- <button type="button" onclick={() => dispatch('fixErrors')} class="px-4 py-2 text-xs rounded bg-red-600 hover:bg-red-700 text-white cursor-pointer border-0">🔧 {$t('editor.preview.fixErrors')}</button>
1047
- <button type="button" onclick={() => dispatch('viewErrors')} class="px-3 py-1.5 text-xs rounded border border-orange-400 text-orange-600 bg-white hover:bg-orange-50 cursor-pointer">📋 {$t('editor.preview.viewErrors')}</button>
1048
- <button type="button" onclick={() => dispatch('retryPreview')} class="px-3 py-1.5 text-xs rounded border border-red-300 text-red-600 bg-white hover:bg-red-50 cursor-pointer">🔄 {$t('editor.preview.retryPreview')}</button>
1067
+ <div class="flex flex-wrap justify-center gap-2">
1068
+ <Button size="sm" onclick={() => dispatch('fixErrors')}>
1069
+ <IconTool />
1070
+ {$t('editor.preview.fixErrors')}
1071
+ </Button>
1072
+ <Button size="sm" variant="outline" onclick={() => dispatch('viewErrors')}>
1073
+ <IconListDetails />
1074
+ {$t('editor.preview.viewErrors')}
1075
+ </Button>
1076
+ <Button size="sm" variant="outline" onclick={() => dispatch('retryPreview')}>
1077
+ <IconRefresh />
1078
+ {$t('editor.preview.retryPreview')}
1079
+ </Button>
1049
1080
  </div>
1050
1081
  </div>
1051
1082
  {/if}
@@ -1090,19 +1121,24 @@
1090
1121
  <GenerateLoader title={$t('editor.preview.loadingPreview')} subtitle="" size="lg" />
1091
1122
  </div>
1092
1123
  {:else}
1093
- <div class="flex h-full flex-col items-center justify-center p-6 text-center text-sm text-gray-600">
1124
+ <div class="flex h-full flex-col items-center justify-center gap-3 p-6 text-center text-body text-muted-foreground">
1094
1125
  {#if isGeneratingCode}
1095
1126
  <GenerateLoader title={$t('editor.preview.generatingCode')} subtitle="" size="lg" />
1096
1127
  {:else if previewError === 'NO_CODE_YET'}
1097
- <div class="font-semibold text-lg text-gray-700 mb-2">{$t('editor.preview.noCodeYet')}</div>
1128
+ <div class="text-body-medium text-foreground">{$t('editor.preview.noCodeYet')}</div>
1098
1129
  {:else if previewError}
1099
- <div class="font-semibold text-lg text-red-600 mb-2">{$t('editor.preview.unavailable')}</div>
1100
- <div class="text-sm text-gray-600 mb-4">{previewError}</div>
1101
- <button type="button" onclick={() => dispatch('retry')} class="px-3 py-1.5 text-xs rounded border border-blue-500 text-blue-600 bg-white hover:bg-blue-50 cursor-pointer">🔄 {$t('editor.preview.retryBuild')}</button>
1130
+ <IconAlertTriangle class="size-6 stroke-[1.333] text-destructive" aria-hidden="true" />
1131
+ <div class="text-body-medium text-foreground">{$t('editor.preview.unavailable')}</div>
1132
+ <div class="text-body text-muted-foreground">{previewError}</div>
1133
+ <Button size="sm" onclick={() => dispatch('retry')}>
1134
+ <IconRefresh />
1135
+ {$t('editor.preview.retryBuild')}
1136
+ </Button>
1102
1137
  {:else if previewLoading}
1103
- <div class="text-lg font-medium text-gray-700">{$t('editor.preview.building')}</div>
1138
+ <div class="text-body-medium text-foreground">{$t('editor.preview.building')}</div>
1104
1139
  {:else}
1105
- <div class="text-lg text-gray-600 mb-2">🖼️ {$t('editor.preview.noPreview')}</div>
1140
+ <IconPhoto class="size-6 stroke-[1.333]" aria-hidden="true" />
1141
+ <div class="text-body text-muted-foreground">{$t('editor.preview.noPreview')}</div>
1106
1142
  {/if}
1107
1143
  </div>
1108
1144
  {/if}
@@ -1128,22 +1164,14 @@
1128
1164
  height: 10px;
1129
1165
  z-index: 30;
1130
1166
  box-sizing: border-box;
1131
- background: #ffffff;
1132
- border: 1.5px solid #3b82f6;
1133
- border-radius: 1px;
1167
+ background: var(--background);
1168
+ border: 1.5px solid var(--primary);
1169
+ border-radius: 2px;
1134
1170
  }
1135
1171
 
1136
1172
  .preview-iframe-shell-symmetrical .preview-resize-handle,
1137
1173
  .preview-iframe-shell-symmetrical .preview-iframe-container {
1138
- border-color: #f97316 !important;
1139
- }
1140
-
1141
- .preview-chrome-header button:focus,
1142
- .preview-chrome-header button:focus-visible,
1143
- .preview-chrome-header input:focus,
1144
- .preview-chrome-header input:focus-visible {
1145
- outline: none;
1146
- box-shadow: none;
1174
+ border-color: var(--brand) !important;
1147
1175
  }
1148
1176
 
1149
1177
  /* The four corner handles of the preview are on the four corners of the box, a place on the screen: the set is the same in both directions. */
@@ -1170,8 +1198,11 @@
1170
1198
  .preview-resize-handle-e { right: -5px; cursor: ew-resize; } /* rtl-ok: right edge */
1171
1199
  .preview-resize-handle-w { left: -5px; cursor: ew-resize; } /* rtl-ok: left edge */
1172
1200
 
1173
- .preview-resize-handle:hover {
1174
- background: #eff6ff;
1175
- border-color: #2563eb;
1201
+ /* Only where a pointer can hover: on a touch screen the handle would stay highlighted after a tap. */
1202
+ @media (hover: hover) {
1203
+ .preview-resize-handle:hover {
1204
+ background: var(--brand-subtle);
1205
+ border-color: var(--primary);
1206
+ }
1176
1207
  }
1177
1208
  </style>