From 2c009d734f6ca8e0e8db47a408755d88577defdd Mon Sep 17 00:00:00 2001 From: Ronald Moesbergen Date: Thu, 9 May 2024 19:03:26 +0200 Subject: [PATCH 1/8] fix: require a filename for save as dialog --- src/lib/components/core/header/Header.svelte | 1 + src/lib/components/core/popups/popups/Prompt.svelte | 10 +++++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/lib/components/core/header/Header.svelte b/src/lib/components/core/header/Header.svelte index d8390f1..c829c3b 100644 --- a/src/lib/components/core/header/Header.svelte +++ b/src/lib/components/core/header/Header.svelte @@ -100,6 +100,7 @@ async function saveProjectAs() { name: "SAVEAS", placeholder: "GIVE_FILENAME", confirm: "SAVE", + requireValue: true, }, allowInteraction: false, }); diff --git a/src/lib/components/core/popups/popups/Prompt.svelte b/src/lib/components/core/popups/popups/Prompt.svelte index 5776dca..ee8852f 100644 --- a/src/lib/components/core/popups/popups/Prompt.svelte +++ b/src/lib/components/core/popups/popups/Prompt.svelte @@ -11,8 +11,15 @@ interface Props { placeholder: string; confirm: string; value?: string; + requireValue: boolean; } -let { name, placeholder, confirm, value = $bindable("") }: Props = $props(); +let { + name, + placeholder, + confirm, + value = $bindable(""), + requireValue = false, +}: Props = $props(); const popupState = getContext>("state"); function cancel() { @@ -20,6 +27,7 @@ function cancel() { } function save() { + if (requireValue && !value) return; popups.close($popupState.id, value); } From 90bffb60a51cf874655e5783dca931fc4e4c8890 Mon Sep 17 00:00:00 2001 From: Ronald Moesbergen Date: Fri, 10 May 2024 09:38:56 +0200 Subject: [PATCH 2/8] fix: add required attribute to input when prompt requires a value --- src/lib/components/core/popups/popups/Prompt.svelte | 3 ++- src/lib/components/ui/TextInput.svelte | 3 +++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/lib/components/core/popups/popups/Prompt.svelte b/src/lib/components/core/popups/popups/Prompt.svelte index ee8852f..067a6ea 100644 --- a/src/lib/components/core/popups/popups/Prompt.svelte +++ b/src/lib/components/core/popups/popups/Prompt.svelte @@ -11,7 +11,7 @@ interface Props { placeholder: string; confirm: string; value?: string; - requireValue: boolean; + requireValue?: boolean; } let { name, @@ -45,6 +45,7 @@ function onsubmit(event: SubmitEvent) { mode={"secondary"} rounded={true} focus={true} + required={requireValue} />
diff --git a/src/lib/components/ui/Button.svelte b/src/lib/components/ui/Button.svelte index f766cbc..2208974 100644 --- a/src/lib/components/ui/Button.svelte +++ b/src/lib/components/ui/Button.svelte @@ -1,7 +1,6 @@ -
+

{$_(name)}

Date: Sat, 11 May 2024 15:50:18 +0200 Subject: [PATCH 8/8] chore: reformat button --- src/lib/components/ui/Button.svelte | 122 +++++++++++++++------------- 1 file changed, 64 insertions(+), 58 deletions(-) diff --git a/src/lib/components/ui/Button.svelte b/src/lib/components/ui/Button.svelte index 86d97c1..366fd63 100644 --- a/src/lib/components/ui/Button.svelte +++ b/src/lib/components/ui/Button.svelte @@ -15,6 +15,7 @@ interface Props { bold?: boolean; type?: "button" | "submit"; } + const { name, mode, @@ -29,6 +30,7 @@ const { let btn: HTMLButtonElement = $state(); const open = writable(false); + function onContext() { if (!context) return; @@ -37,70 +39,74 @@ function onContext() { {#if $open} - + {/if}