mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2026-10-02 07:38:12 +08:00
[wip]fix: use svelte component for optionsWidget
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { isWidgetColumn, isWidgetRow, isWidgetSection, type WidgetLayout } from "@graphite/wasm-communication/messages";
|
import { isWidgetColumn, isWidgetRow, isWidgetSection, LayoutGroup, type WidgetLayout } from "@graphite/wasm-communication/messages";
|
||||||
|
|
||||||
import WidgetSection from "@graphite/components/widgets/groups/WidgetSection.svelte";
|
import WidgetSection from "@graphite/components/widgets/groups/WidgetSection.svelte";
|
||||||
import WidgetRow from "@graphite/components/widgets/WidgetRow.svelte";
|
import WidgetRow from "@graphite/components/widgets/WidgetRow.svelte";
|
||||||
@@ -12,6 +12,7 @@
|
|||||||
$: extraClasses = Object.entries(classes)
|
$: extraClasses = Object.entries(classes)
|
||||||
.flatMap((classAndState) => (classAndState[1] ? [classAndState[0]] : []))
|
.flatMap((classAndState) => (classAndState[1] ? [classAndState[0]] : []))
|
||||||
.join(" ");
|
.join(" ");
|
||||||
|
console.log(layout);
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<!-- TODO: Refactor this component (together with `WidgetRow.svelte`) to be more logically consistent with our layout definition goals, in terms of naming and capabilities -->
|
<!-- TODO: Refactor this component (together with `WidgetRow.svelte`) to be more logically consistent with our layout definition goals, in terms of naming and capabilities -->
|
||||||
|
|||||||
@@ -138,11 +138,9 @@
|
|||||||
{/if}
|
{/if}
|
||||||
{@const popoverButton = narrowWidgetProps(component.props, "PopoverButton")}
|
{@const popoverButton = narrowWidgetProps(component.props, "PopoverButton")}
|
||||||
{#if popoverButton}
|
{#if popoverButton}
|
||||||
<PopoverButton {...exclude(popoverButton, ["header", "text"])}>
|
<PopoverButton {...exclude(popoverButton, ["header", "text", "optionsWidget", "layoutTarget"])}>
|
||||||
<TextLabel bold={true}>{popoverButton.header}</TextLabel>
|
<TextLabel bold={true}>{popoverButton.header}</TextLabel>
|
||||||
<TextLabel multiline={true}>{popoverButton.text}</TextLabel>
|
<TextLabel multiline={true}>{popoverButton.text}</TextLabel>
|
||||||
<!-- ! how will this work? -->
|
|
||||||
<!-- <DropdownInput entries={popoverButton.options_widget}></DropdownInput> -->
|
|
||||||
</PopoverButton>
|
</PopoverButton>
|
||||||
{/if}
|
{/if}
|
||||||
{@const radioInput = narrowWidgetProps(component.props, "RadioInput")}
|
{@const radioInput = narrowWidgetProps(component.props, "RadioInput")}
|
||||||
|
|||||||
@@ -1,15 +1,18 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import type { IconName } from "@graphite/utility-functions/icons";
|
import type { IconName } from "@graphite/utility-functions/icons";
|
||||||
|
// import { LayoutGroup, WidgetLayout } from "~src/wasm-communication/messages";
|
||||||
|
|
||||||
import FloatingMenu from "@graphite/components/layout/FloatingMenu.svelte";
|
import FloatingMenu from "@graphite/components/layout/FloatingMenu.svelte";
|
||||||
import LayoutRow from "@graphite/components/layout/LayoutRow.svelte";
|
import LayoutRow from "@graphite/components/layout/LayoutRow.svelte";
|
||||||
import IconButton from "@graphite/components/widgets/buttons/IconButton.svelte";
|
import IconButton from "@graphite/components/widgets/buttons/IconButton.svelte";
|
||||||
import WidgetLayout from "../WidgetLayout.svelte";
|
import WidgetLayout from "../WidgetLayout.svelte";
|
||||||
|
|
||||||
export let icon: IconName = "DropdownArrow";
|
export let icon: IconName = "DropdownArrow";
|
||||||
export let tooltip: string | undefined = undefined;
|
export let tooltip: string | undefined = undefined;
|
||||||
export let disabled = false;
|
export let disabled = false;
|
||||||
export let options_widget: WidgetLayout | undefined = undefined;
|
export let optionsWidget: WidgetLayout;
|
||||||
|
export let layoutTarget: unknown;
|
||||||
|
|
||||||
// Callbacks
|
// Callbacks
|
||||||
export let action: (() => void) | undefined = undefined;
|
export let action: (() => void) | undefined = undefined;
|
||||||
|
|
||||||
@@ -19,14 +22,15 @@
|
|||||||
open = true;
|
open = true;
|
||||||
action?.();
|
action?.();
|
||||||
}
|
}
|
||||||
|
// console.log(optionsWidget, layoutTarget);
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<LayoutRow class="popover-button">
|
<LayoutRow class="popover-button">
|
||||||
{#if options_widget === undefined}
|
{#if optionsWidget === undefined}
|
||||||
<IconButton classes={{ open }} {disabled} action={() => onClick()} icon={icon || "DropdownArrow"} size={16} {tooltip} data-floating-menu-spawner />
|
<IconButton classes={{ open }} {disabled} action={() => onClick()} icon={icon || "DropdownArrow"} size={16} {tooltip} data-floating-menu-spawner />
|
||||||
|
|
||||||
{:else}
|
{:else}
|
||||||
<IconButton classes={{ open }} {disabled} action={() => onClick()} icon={icon || "DropdownArrow"} size={16} {options_widget} data-floating-menu-spawner />
|
<IconButton classes={{ open }} {disabled} action={() => onClick()} icon={icon || "DropdownArrow"} size={16} options_widget={optionsWidget} data-floating-menu-spawner />
|
||||||
{/if}
|
{/if}
|
||||||
|
|
||||||
<FloatingMenu {open} on:open={({ detail }) => (open = detail)} type="Popover" direction="Bottom">
|
<FloatingMenu {open} on:open={({ detail }) => (open = detail)} type="Popover" direction="Bottom">
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import { Transform, Type, plainToClass } from "class-transformer";
|
|||||||
|
|
||||||
import { type IconName, type IconSize } from "@graphite/utility-functions/icons";
|
import { type IconName, type IconSize } from "@graphite/utility-functions/icons";
|
||||||
import { type WasmEditorInstance, type WasmRawInstance } from "@graphite/wasm-communication/editor";
|
import { type WasmEditorInstance, type WasmRawInstance } from "@graphite/wasm-communication/editor";
|
||||||
|
import WidgetLayout from "~src/components/widgets/WidgetLayout.svelte";
|
||||||
|
|
||||||
export class JsMessage {
|
export class JsMessage {
|
||||||
// The marker provides a way to check if an object is a sub-class constructor for a jsMessage.
|
// The marker provides a way to check if an object is a sub-class constructor for a jsMessage.
|
||||||
@@ -932,7 +933,8 @@ export class PopoverButton extends WidgetProps {
|
|||||||
@Transform(({ value }: { value: string }) => value || undefined)
|
@Transform(({ value }: { value: string }) => value || undefined)
|
||||||
tooltip!: string | undefined;
|
tooltip!: string | undefined;
|
||||||
|
|
||||||
options_widget: WidgetLayout | undefined;
|
optionsWidget: WidgetLayout = defaultWidgetLayout();
|
||||||
|
layoutTarget: unknown = undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
export type RadioEntryData = {
|
export type RadioEntryData = {
|
||||||
|
|||||||
Reference in New Issue
Block a user