From e108d0a2d0e4b1144fb8273e06a943ded23c53e3 Mon Sep 17 00:00:00 2001 From: Bob Fanger Date: Sun, 16 Apr 2023 17:58:52 +0200 Subject: [PATCH] feat: SelectMenu component --- .../src/SelectMenu/Option.svelte | 42 ++++ .../src/SelectMenu/SelectMenu.story.svelte | 24 ++ .../src/SelectMenu/SelectMenu.svelte | 221 ++++++++++++++++++ packages/blender-elements/src/icons.ts | 12 + packages/pixi-panel/src/PropertiesArea.svelte | 1 + packages/pixi-panel/src/TextProperties.svelte | 66 +++++- 6 files changed, 363 insertions(+), 3 deletions(-) create mode 100644 packages/blender-elements/src/SelectMenu/Option.svelte create mode 100644 packages/blender-elements/src/SelectMenu/SelectMenu.story.svelte create mode 100644 packages/blender-elements/src/SelectMenu/SelectMenu.svelte diff --git a/packages/blender-elements/src/SelectMenu/Option.svelte b/packages/blender-elements/src/SelectMenu/Option.svelte new file mode 100644 index 0000000..a8d9e6c --- /dev/null +++ b/packages/blender-elements/src/SelectMenu/Option.svelte @@ -0,0 +1,42 @@ + + + + + diff --git a/packages/blender-elements/src/SelectMenu/SelectMenu.story.svelte b/packages/blender-elements/src/SelectMenu/SelectMenu.story.svelte new file mode 100644 index 0000000..16aea81 --- /dev/null +++ b/packages/blender-elements/src/SelectMenu/SelectMenu.story.svelte @@ -0,0 +1,24 @@ + + + + +
+ +
+ + + + +
diff --git a/packages/blender-elements/src/SelectMenu/SelectMenu.svelte b/packages/blender-elements/src/SelectMenu/SelectMenu.svelte new file mode 100644 index 0000000..de0c0f3 --- /dev/null +++ b/packages/blender-elements/src/SelectMenu/SelectMenu.svelte @@ -0,0 +1,221 @@ + + +
+ + {#if expanded} +
+
+ {/if} +
+ + diff --git a/packages/blender-elements/src/icons.ts b/packages/blender-elements/src/icons.ts index 2c20ed4..ddf8155 100644 --- a/packages/blender-elements/src/icons.ts +++ b/packages/blender-elements/src/icons.ts @@ -69,6 +69,18 @@ const svg = { `, "small-caps": ` +`, + "text-left": ` + +`, + "text-center": ` + +`, + "text-right": ` + +`, + "text-justify": ` + `, }; export type Icon = keyof typeof svg; diff --git a/packages/pixi-panel/src/PropertiesArea.svelte b/packages/pixi-panel/src/PropertiesArea.svelte index 23549ea..0c1b5b6 100644 --- a/packages/pixi-panel/src/PropertiesArea.svelte +++ b/packages/pixi-panel/src/PropertiesArea.svelte @@ -39,6 +39,7 @@ skewDimensions: true, visibility: true, font: true, + alignment: true, spacer: true, wordWrap: true, dropShadow: true, diff --git a/packages/pixi-panel/src/TextProperties.svelte b/packages/pixi-panel/src/TextProperties.svelte index 8153f9d..244bdee 100644 --- a/packages/pixi-panel/src/TextProperties.svelte +++ b/packages/pixi-panel/src/TextProperties.svelte @@ -7,6 +7,7 @@ import Property from "blender-elements/src/Property/Property.svelte"; import TextField from "blender-elements/src/TextField/TextField.svelte"; import Toggle from "blender-elements/src/Toggle/Toggle.svelte"; + import SelectMenu from "blender-elements/src/SelectMenu/SelectMenu.svelte"; export let props: NodeProperties; export let expanded: Record; @@ -18,9 +19,18 @@ typeof props.fontSize === "number" || typeof props.fontStyle === "string" || typeof props.fontVariant === "string"; + $: alignmentPanel = + typeof props.align === "string" || typeof props.textBaseline === "string"; $: spacingPanel = typeof props.letterSpacing === "number"; $: dropShadowPanel = typeof props.dropShadow === "boolean"; $: strokePanel = typeof props.stroke === "string"; + + const alignOptions = [ + { value: "left", label: "Left", icon: "text-left" }, + { value: "center", label: "Center", icon: "text-center" }, + { value: "right", label: "Right", icon: "text-right" }, + { value: "justify", label: "Justify", icon: "text-justify" }, + ]; {#if typeof props.text === "string"} @@ -118,8 +128,23 @@ {/if} {#if typeof props.fontWeight === "string"} - dispatch("change", { property: "fontWeight", value: e.detail })} /> @@ -127,6 +152,43 @@ {/if} {/if} +{#if alignmentPanel} + + {#if typeof props.align === "string"} + + + dispatch("change", { property: "align", value: e.detail })} + /> + + {/if} + {#if typeof props.textBaseline === "string"} + + + dispatch("change", { property: "textBaseline", value: e.detail })} + /> + + {/if} + +{/if} {#if spacingPanel} {#if typeof props.leading === "number"} @@ -383,8 +445,6 @@ {/if}