From c07f4b32af17d6794bdaeb4458302e65c14692d3 Mon Sep 17 00:00:00 2001 From: Smit Date: Thu, 19 Jun 2025 03:04:55 +0530 Subject: [PATCH] phase 2: update bindings to svelte 5 for files in runesGlob --- frontend/src/app.d.ts | 1 + .../floating-menus/ColorPicker.svelte | 208 +++++++++--------- .../components/floating-menus/Dialog.svelte | 2 +- .../components/floating-menus/MenuList.svelte | 155 ++++++++----- .../floating-menus/NodeCatalog.svelte | 2 +- .../layout/ConditionalWrapper.svelte | 15 +- .../src/components/layout/FloatingMenu.svelte | 141 +++++++----- .../src/components/layout/LayoutCol.svelte | 82 ++++--- .../src/components/layout/LayoutRow.svelte | 83 ++++--- .../src/components/panels/Document.svelte | 24 +- frontend/src/components/panels/Layers.svelte | 4 +- frontend/src/components/views/Graph.svelte | 10 +- .../components/widgets/WidgetSection.svelte | 6 +- .../src/components/widgets/WidgetSpan.svelte | 28 +-- .../buttons/BreadcrumbTrailButtons.svelte | 19 +- .../widgets/buttons/IconButton.svelte | 44 ++-- .../widgets/buttons/ImageButton.svelte | 34 ++- .../buttons/ParameterExposeButton.svelte | 21 +- .../widgets/buttons/PopoverButton.svelte | 37 +++- .../widgets/buttons/TextButton.svelte | 52 +++-- .../widgets/inputs/CheckboxInput.svelte | 35 +-- .../widgets/inputs/ColorInput.svelte | 52 +++-- .../widgets/inputs/CurveInput.svelte | 63 +++--- .../widgets/inputs/DropdownInput.svelte | 82 ++++--- .../widgets/inputs/FieldInput.svelte | 121 ++++++---- .../widgets/inputs/FontInput.svelte | 59 +++-- .../widgets/inputs/NumberInput.svelte | 202 +++++++++-------- .../widgets/inputs/RadioInput.svelte | 27 ++- .../widgets/inputs/ReferencePointInput.svelte | 35 +-- .../widgets/inputs/RulerInput.svelte | 41 ++-- .../widgets/inputs/ScrollbarInput.svelte | 70 +++--- .../widgets/inputs/SpectrumInput.svelte | 68 +++--- .../widgets/inputs/TextAreaInput.svelte | 34 +-- .../widgets/inputs/TextInput.svelte | 59 ++--- .../widgets/inputs/WorkingColorsInput.svelte | 26 ++- .../widgets/labels/IconLabel.svelte | 32 ++- .../widgets/labels/Separator.svelte | 10 +- .../widgets/labels/TextLabel.svelte | 62 ++++-- .../widgets/labels/UserInputLabel.svelte | 27 ++- .../window/title-bar/TitleBar.svelte | 6 +- .../components/window/workspace/Panel.svelte | 99 +++++---- frontend/vite.config.ts | 19 +- 42 files changed, 1299 insertions(+), 898 deletions(-) diff --git a/frontend/src/app.d.ts b/frontend/src/app.d.ts index 177c0e399..e7b104c47 100644 --- a/frontend/src/app.d.ts +++ b/frontend/src/app.d.ts @@ -2,6 +2,7 @@ declare global { namespace Graphite { type Platform = "Windows" | "Mac" | "Linux" | "Web"; type MenuType = "Popover" | "Dropdown" | "Dialog" | "Cursor"; + type Axis = "Horizontal" | "Vertical"; // interface Error {} } diff --git a/frontend/src/components/floating-menus/ColorPicker.svelte b/frontend/src/components/floating-menus/ColorPicker.svelte index 53a20010f..6f070b137 100644 --- a/frontend/src/components/floating-menus/ColorPicker.svelte +++ b/frontend/src/components/floating-menus/ColorPicker.svelte @@ -1,5 +1,5 @@ - + - + {#if !isNone} -
+
{/if} {#if alignedAxis}
+ >
{/if} - + {#if !isNone} -
+
{/if} - + {#if !isNone} -
+
{/if} {#if gradient} { - gradient = gradient; - if (gradient) dispatch("colorOrGradient", gradient); + gradient={gradient} + ongradient={(detail) => { + gradient = detail; + if (gradient) oncolorOrGradient?.(gradient); }} - on:activeMarkerIndexChange={gradientActiveMarkerIndexChange} + onactiveMarkerIndexChange={gradientActiveMarkerIndexChange} activeMarkerIndex={activeIndex} - on:dragging={({ detail }) => (gradientSpectrumDragging = detail)} + bind:drag={gradientSpectrumDragging} bind:this={gradientSpectrumInputWidget} /> {#if gradientSpectrumInputWidget && activeIndex !== undefined} { + onvalue={(detail) => { if (gradientSpectrumInputWidget && activeIndex !== undefined && detail !== undefined) gradientSpectrumInputWidget.setPosition(activeIndex, detail / 100); }} displayDecimalPlaces={0} @@ -480,7 +498,7 @@ > {#if !newColor.equals(oldColor)}
- + {/if} {#if !newColor.equals(oldColor)} @@ -499,9 +517,9 @@ { - dispatch("startHistoryTransaction"); + value={newColor.toHexOptionalAlpha() ?? "-"} + oncommitText={(detail ) => { + onstartHistoryTransaction?.(); setColorCode(detail); }} centered={true} @@ -519,14 +537,12 @@ {/if} { - strength = detail; + value={rgbChannels[index][1]} + onvalue={(detail) => { + rgbChannels[index][1] = detail; setColorRGB(channel, detail); }} - on:startHistoryTransaction={() => { - dispatch("startHistoryTransaction"); - }} + {onstartHistoryTransaction} min={0} max={255} minWidth={1} @@ -546,14 +562,12 @@ {/if} { - strength = detail; + value={hsvChannels[index][1]} + onvalue={(detail) => { + hsvChannels[index][1] = detail; setColorHSV(channel, detail); }} - on:startHistoryTransaction={() => { - dispatch("startHistoryTransaction"); - }} + {onstartHistoryTransaction} min={0} max={channel === "h" ? 360 : 100} unit={channel === "h" ? "°" : "%"} @@ -573,13 +587,11 @@ { + onvalue={(detail) => { if (detail !== undefined) alpha = detail / 100; setColorAlphaPercent(detail); }} - on:startHistoryTransaction={() => { - dispatch("startHistoryTransaction"); - }} + {onstartHistoryTransaction} min={0} max={100} rangeMin={0} @@ -593,23 +605,23 @@ {#if allowNone && !gradient} - + {/if} - + - + - - +
diff --git a/frontend/src/components/floating-menus/Dialog.svelte b/frontend/src/components/floating-menus/Dialog.svelte index e9d0ba5fa..4ba70719f 100644 --- a/frontend/src/components/floating-menus/Dialog.svelte +++ b/frontend/src/components/floating-menus/Dialog.svelte @@ -16,7 +16,7 @@ const dialog = getContext("dialog"); - let self: FloatingMenu | undefined; + let self: FloatingMenu | undefined = $state(); onMount(() => { // Focus the button which is marked as emphasized, or otherwise the first button, in the popup diff --git a/frontend/src/components/floating-menus/MenuList.svelte b/frontend/src/components/floating-menus/MenuList.svelte index 0695d3830..7b8bac402 100644 --- a/frontend/src/components/floating-menus/MenuList.svelte +++ b/frontend/src/components/floating-menus/MenuList.svelte @@ -1,7 +1,5 @@ - - (open = detail)} - on:naturalWidth + bind:open type="Dropdown" windowEdgeMargin={0} escapeCloses={false} {direction} {minWidth} scrollableY={scrollableY && virtualScrollingEntryHeight === 0} + {onnaturalWidth} bind:this={self} > {#if search.length > 0} - (search = detail)} bind:this={searchTextInput}> + {/if} {#if virtualScrollingEntryHeight} @@ -424,14 +464,14 @@ classes={{ open: isEntryOpen(entry), active: entry.label === highlighted?.label, disabled: Boolean(entry.disabled) }} styles={{ height: virtualScrollingEntryHeight || "20px" }} {tooltip} - on:click={() => !entry.disabled && onEntryClick(entry)} - on:pointerenter={() => !entry.disabled && onEntryPointerEnter(entry)} - on:pointerleave={() => !entry.disabled && onEntryPointerLeave(entry)} + onclick={() => !entry.disabled && onEntryClick(entry)} + onpointerenter={() => !entry.disabled && onEntryPointerEnter(entry)} + onpointerleave={() => !entry.disabled && onEntryPointerLeave(entry)} > {#if entry.icon && drawIcon} {:else if drawIcon} -
+
{/if} {#if entry.font} @@ -447,18 +487,13 @@ {#if entry.children?.length} {:else} -
+
{/if} {#if entry.children} { - // We do a manual dispatch here instead of just `on:naturalWidth` as a workaround for the
- (searchTerm = detail)} bind:this={nodeSearchInput} /> +
{#each nodeCategories as nodeCategory}
diff --git a/frontend/src/components/layout/ConditionalWrapper.svelte b/frontend/src/components/layout/ConditionalWrapper.svelte index 46d5e80b0..f8679efc6 100644 --- a/frontend/src/components/layout/ConditionalWrapper.svelte +++ b/frontend/src/components/layout/ConditionalWrapper.svelte @@ -1,14 +1,21 @@ {#if condition}
- + {@render children?.()}
{:else} - + {@render children?.()} {/if} diff --git a/frontend/src/components/layout/FloatingMenu.svelte b/frontend/src/components/layout/FloatingMenu.svelte index e4070cb15..b4a915426 100644 --- a/frontend/src/components/layout/FloatingMenu.svelte +++ b/frontend/src/components/layout/FloatingMenu.svelte @@ -1,6 +1,4 @@ - -
{#if displayTail} -
+
{/if} {#if displayContainer}
- + {@render children?.()}
{/if} diff --git a/frontend/src/components/layout/LayoutCol.svelte b/frontend/src/components/layout/LayoutCol.svelte index b69b6bfab..6b37da195 100644 --- a/frontend/src/components/layout/LayoutCol.svelte +++ b/frontend/src/components/layout/LayoutCol.svelte @@ -1,23 +1,43 @@ diff --git a/frontend/src/components/widgets/buttons/IconButton.svelte b/frontend/src/components/widgets/buttons/IconButton.svelte index 97fbc2c8c..efe69bb4d 100644 --- a/frontend/src/components/widgets/buttons/IconButton.svelte +++ b/frontend/src/components/widgets/buttons/IconButton.svelte @@ -1,24 +1,37 @@