@widgetic/editor 4.1.14 → 4.1.16
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/PreviewChromeControls.svelte +15 -21
- package/dist/components/WidgetPreview.svelte +136 -105
- package/dist/components/color-select/ColorSelect.svelte +203 -224
- package/dist/components/color-select/constants.d.ts +4 -2
- package/dist/components/color-select/constants.js +4 -2
- package/dist/components/color-select/render.js +10 -9
- package/dist/components/editors/CompositionEditorApp.svelte +47 -40
- package/dist/components/editors/EditLeaseNotice.svelte +44 -33
- package/dist/components/editors/EmbedEditor.svelte +133 -259
- package/dist/components/editors/PropsEditor.svelte +418 -1338
- package/dist/components/editors/props-editor.css +5 -68
- package/dist/components/ic/AngleInputController.svelte +202 -277
- package/dist/components/ic/BrowserInputController.svelte +813 -803
- package/dist/components/ic/CheckboxInputController.svelte +92 -169
- package/dist/components/ic/CheckboxInputController.svelte.d.ts +2 -8
- package/dist/components/ic/ColorPickerInputController.svelte +1589 -1587
- package/dist/components/ic/ColorPickerInputController.svelte.d.ts +3 -3
- package/dist/components/ic/DateFieldInputController.svelte +455 -465
- package/dist/components/ic/DatePickerInputController.svelte +355 -368
- package/dist/components/ic/DatePickerInputController.svelte.d.ts +1 -1
- package/dist/components/ic/DropdownInputController.svelte +130 -200
- package/dist/components/ic/FixedPositionInputController.svelte +255 -276
- package/dist/components/ic/FixedPositionInputController.svelte.d.ts +5 -1
- package/dist/components/ic/FontInputController.svelte +2110 -2231
- package/dist/components/ic/FontInputController.svelte.d.ts +11 -11
- package/dist/components/ic/InputControllerHeader.svelte +141 -147
- package/dist/components/ic/InputControllerRow.svelte +74 -0
- package/dist/components/ic/InputControllerRow.svelte.d.ts +14 -0
- package/dist/components/ic/KnowledgeDocumentsInputController.svelte +84 -47
- package/dist/components/ic/KnowledgeTextForm.svelte +35 -33
- package/dist/components/ic/NumberControls.svelte +303 -269
- package/dist/components/ic/NumberControls.svelte.d.ts +4 -1
- package/dist/components/ic/NumberInputController.svelte +361 -301
- package/dist/components/ic/NumberInputController.svelte.d.ts +2 -0
- package/dist/components/ic/PositionInputController.svelte +253 -176
- package/dist/components/ic/PositionInputController.svelte.d.ts +2 -0
- package/dist/components/ic/RadioGroupInputController.svelte +71 -137
- package/dist/components/ic/RadioGroupInputController.svelte.d.ts +2 -8
- package/dist/components/ic/RangeCalendarInputController.svelte +233 -270
- package/dist/components/ic/RangeCalendarInputController.svelte.d.ts +2 -2
- package/dist/components/ic/RoundedCornersInputController.svelte +412 -435
- package/dist/components/ic/RoundedCornersInputController.svelte.d.ts +2 -0
- package/dist/components/ic/SliderInputController.svelte +263 -332
- package/dist/components/ic/SliderInputController.svelte.d.ts +1 -1
- package/dist/components/ic/SliderRangeInputController.svelte +140 -144
- package/dist/components/ic/SliderRangeInputController.svelte.d.ts +3 -3
- package/dist/components/ic/SwitchInputController.svelte +47 -109
- package/dist/components/ic/TagsInputController.svelte +95 -110
- package/dist/components/ic/TextAreaInputController.svelte +1794 -1935
- package/dist/components/ic/TextAreaPreviewInputController.svelte +436 -438
- package/dist/components/ic/TextAreaPreviewInputController.svelte.d.ts +2 -2
- package/dist/components/ic/TextInputController.svelte +65 -75
- package/dist/components/ic/TextInputController.svelte.d.ts +2 -0
- package/dist/components/ic/TimeInputController.svelte +433 -431
- package/dist/components/ic/VectorInputController.svelte +1833 -1831
- package/dist/components/ic/VectorInputController.svelte.d.ts +10 -10
- package/dist/components/ic/index.d.ts +1 -0
- package/dist/components/ic/index.js +1 -0
- package/dist/components/ic/shared/CategoryTabs.svelte +28 -35
- package/dist/components/ic/shared/ItemGrid.svelte +145 -179
- package/dist/components/ic/shared/RecentItemsSection.svelte +208 -271
- package/dist/components/ic/shared/RecentItemsSection.svelte.d.ts +1 -1
- package/dist/components/ui/arrows/OpacitySliderArrows.svelte +23 -38
- package/dist/components/ui/arrows/OpacitySliderArrows.svelte.d.ts +1 -4
- package/dist/components/ui/calendar-editor-fit/EditorCalendarStyles.svelte +45 -0
- package/dist/components/ui/calendar-editor-fit/EditorCalendarStyles.svelte.d.ts +26 -0
- package/dist/components/ui/checkerboard-background/CheckerboardBackground.svelte +20 -12
- package/dist/components/ui/shadow-picker-host/ShadowPickerHost.svelte +39 -0
- package/dist/components/ui/shadow-picker-host/ShadowPickerHost.svelte.d.ts +10 -0
- package/dist/i18n/language.d.ts +44 -281
- package/dist/i18n/messages.d.ts +41 -34
- package/dist/i18n/messages.js +47 -34
- package/dist/i18n/translate.d.ts +1 -1
- package/dist/utils.d.ts +7 -0
- package/dist/utils.js +26 -2
- package/package.json +5 -5
|
@@ -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
|
-
|
|
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
|
|
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
|
-
<
|
|
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
|
|
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
|
-
<
|
|
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
|
-
|
|
49
|
-
|
|
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
|
|
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-
|
|
61
|
-
<label class="preview-dim-label flex items-center gap-1 text-
|
|
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
|
|
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
|
-
|
|
129
|
-
const
|
|
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
|
|
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
|
|
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
|
-
|
|
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-
|
|
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
|
-
<
|
|
817
|
-
|
|
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
|
-
<
|
|
826
|
-
</
|
|
841
|
+
<IconCopy />
|
|
842
|
+
</IconButton>
|
|
827
843
|
{#if showUrlBarButtons}
|
|
828
|
-
<
|
|
829
|
-
|
|
830
|
-
|
|
844
|
+
<IconButton
|
|
845
|
+
variant="outline"
|
|
846
|
+
label={$t('editor.preview.refresh')}
|
|
831
847
|
title={$t('editor.preview.refresh')}
|
|
832
|
-
|
|
833
|
-
|
|
848
|
+
onclick={handleRefreshClick}
|
|
849
|
+
>
|
|
850
|
+
<IconRefresh />
|
|
851
|
+
</IconButton>
|
|
834
852
|
{#if showViewportButtons && enableResize}
|
|
835
|
-
<
|
|
836
|
-
|
|
837
|
-
|
|
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
|
-
|
|
858
|
+
onclick={handleFitToAreaClick}
|
|
840
859
|
>
|
|
841
|
-
<
|
|
842
|
-
</
|
|
843
|
-
<
|
|
844
|
-
|
|
845
|
-
|
|
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
|
-
|
|
867
|
+
onclick={applyMobileViewport}
|
|
848
868
|
>
|
|
849
|
-
<
|
|
850
|
-
</
|
|
851
|
-
<
|
|
852
|
-
|
|
853
|
-
|
|
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
|
-
|
|
876
|
+
onclick={handleDesktopViewport}
|
|
856
877
|
>
|
|
857
|
-
<
|
|
858
|
-
</
|
|
878
|
+
<IconDeviceDesktop />
|
|
879
|
+
</IconButton>
|
|
859
880
|
{/if}
|
|
860
|
-
<
|
|
861
|
-
|
|
862
|
-
|
|
881
|
+
<Button
|
|
882
|
+
variant="outline"
|
|
883
|
+
size="sm"
|
|
863
884
|
title={$t('editor.preview.openInNewTab')}
|
|
864
|
-
|
|
865
|
-
>
|
|
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-
|
|
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-
|
|
877
|
-
<
|
|
878
|
-
<div class="
|
|
879
|
-
<div class="text-
|
|
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-
|
|
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="
|
|
891
|
-
<
|
|
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-
|
|
897
|
-
<p class="text-
|
|
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-
|
|
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-
|
|
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-
|
|
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-
|
|
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-
|
|
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-
|
|
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
|
-
<
|
|
994
|
-
|
|
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
|
-
|
|
1001
|
-
|
|
1002
|
-
<
|
|
1003
|
-
<div class="text-
|
|
1004
|
-
<div class="
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
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
|
-
</
|
|
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-
|
|
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-
|
|
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-
|
|
1035
|
-
<
|
|
1036
|
-
<div class="
|
|
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="
|
|
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
|
|
1046
|
-
<
|
|
1047
|
-
|
|
1048
|
-
|
|
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-
|
|
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="
|
|
1128
|
+
<div class="text-body-medium text-foreground">{$t('editor.preview.noCodeYet')}</div>
|
|
1098
1129
|
{:else if previewError}
|
|
1099
|
-
<
|
|
1100
|
-
<div class="text-
|
|
1101
|
-
<
|
|
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-
|
|
1138
|
+
<div class="text-body-medium text-foreground">{$t('editor.preview.building')}</div>
|
|
1104
1139
|
{:else}
|
|
1105
|
-
<
|
|
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:
|
|
1132
|
-
border: 1.5px solid
|
|
1133
|
-
border-radius:
|
|
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:
|
|
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
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
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>
|