diff --git a/web/i18n/en/button.json b/web/i18n/en/button.json index f066049e..e75ac3d1 100644 --- a/web/i18n/en/button.json +++ b/web/i18n/en/button.json @@ -17,5 +17,7 @@ "export": "export", "yes": "yes", "no": "no", - "clear": "clear" + "clear": "clear", + "show_input": "show input", + "hide_input": "hide input" } diff --git a/web/src/components/settings/SettingsInput.svelte b/web/src/components/settings/SettingsInput.svelte index 35197979..9bf90a47 100644 --- a/web/src/components/settings/SettingsInput.svelte +++ b/web/src/components/settings/SettingsInput.svelte @@ -15,17 +15,18 @@ import IconX from "@tabler/icons-svelte/IconX.svelte"; import IconCheck from "@tabler/icons-svelte/IconCheck.svelte"; + import IconEye from "@tabler/icons-svelte/IconEye.svelte"; + import IconEyeClosed from "@tabler/icons-svelte/IconEyeClosed.svelte"; + export let settingId: Id; export let settingContext: Context; export let placeholder: string; export let altText: string; export let type: "url" | "uuid" = "url"; - export let isPassword = false; + export let sensitive = false; export let showInstanceWarning = false; - let inputType = isPassword ? "password" : "text"; - const regex = { url: "https?:\\/\\/[a-z0-9.\\-]+(:\\d+)?/?", uuid: "^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$", @@ -36,6 +37,10 @@ let inputFocused = false; let validInput = false; + let inputHidden = true; + + $: inputType = sensitive && inputHidden ? "password" : "text"; + const writeToSettings = (value: string, type: "url" | "uuid" | "text") => { updateSetting({ [settingContext]: { @@ -62,13 +67,20 @@
-
+
0} + aria-hidden="false" + > (validInput = input.checkValidity())} - on:input={() => (inputFocused = true)} + on:input={() => { + validInput = input.checkValidity(); + inputFocused = true; + }} on:focus={() => (inputFocused = true)} on:blur={() => (inputFocused = false)} spellcheck="false" @@ -78,8 +90,7 @@ pattern={regex[type]} aria-label={altText} aria-hidden="false" - - { ...{ type: inputType } } + {...{ type: inputType }} /> {#if inputValue.length === 0} @@ -87,6 +98,22 @@ {placeholder} {/if} + + {#if sensitive && inputValue.length > 0} + + {/if}
@@ -117,7 +144,7 @@ } #input-container { - padding: 0 18px; + padding: 0 16px; border-radius: var(--border-radius); color: var(--secondary); background-color: var(--button); @@ -129,6 +156,10 @@ overflow: hidden; } + #input-container.extra-button { + padding-right: 4px; + } + #input-container, #input-box { font-size: 13.5px; @@ -182,11 +213,30 @@ .settings-input-button :global(svg) { height: 21px; width: 21px; - stroke-width: 1.5px; + stroke-width: 1.8px; } .settings-input-button[disabled] { opacity: 0.5; pointer-events: none; } + + .input-inner-button { + height: 34px; + width: 34px; + padding: 0; + box-shadow: none; + /* 4px is padding outside of the button */ + border-radius: calc(var(--border-radius) - 4px); + } + + .input-inner-button :global(svg) { + height: 18px; + width: 18px; + stroke-width: 1.8px; + } + + :global(svg) { + will-change: transform; + } diff --git a/web/src/routes/settings/instances/+page.svelte b/web/src/routes/settings/instances/+page.svelte index fc252b96..cd1a2f1b 100644 --- a/web/src/routes/settings/instances/+page.svelte +++ b/web/src/routes/settings/instances/+page.svelte @@ -50,7 +50,7 @@ placeholder="00000000-0000-0000-0000-000000000000" altText={$t("settings.processing.access_key.input.alt_text")} type="uuid" - isPassword + sensitive /> {/if}