From 063f5d1806ce40f8a52ca692e328fcc0e7f9105e Mon Sep 17 00:00:00 2001 From: wukko Date: Fri, 30 Aug 2024 21:31:02 +0600 Subject: [PATCH] web/CustomInstanceInput: proper style --- web/i18n/en/settings.json | 6 +- .../settings/CustomInstanceInput.svelte | 167 +++++++++++++----- .../routes/settings/instances/+page.svelte | 34 +++- 3 files changed, 153 insertions(+), 54 deletions(-) diff --git a/web/i18n/en/settings.json b/web/i18n/en/settings.json index 3c380a82..943749da 100644 --- a/web/i18n/en/settings.json +++ b/web/i18n/en/settings.json @@ -111,11 +111,13 @@ "advanced.export": "export", "processing.override": "default instance override", - "processing.override.title": "use instance-provided processing server", + "processing.override.title": "use the instance-provided processing server", "processing.override.description": "if web instance provides its own default processing server, you can choose to use it over the main processing server. make sure it's a server by someone you trust.", "processing.community": "community instances", "processing.enable_custom.title": "use a custom processing server", - "processing.enable_custom.description": "cobalt will use a custom processing server if you choose to. even though cobalt has some security measures in place, we are not responsible for any damage done via a community instance, as we have no control over them.\n\nplease be mindful of what instances you use and make sure they're hosted by people you trust." + "processing.enable_custom.description": "cobalt will use a custom processing server if you choose to. even though cobalt has some security measures in place, we are not responsible for any damage done via a community instance, as we have no control over them.\n\nplease be mindful of what instances you use and make sure they're hosted by people you trust.", + + "processing.custom.placeholder": "custom instance domain" } diff --git a/web/src/components/settings/CustomInstanceInput.svelte b/web/src/components/settings/CustomInstanceInput.svelte index d7bec607..d3528eab 100644 --- a/web/src/components/settings/CustomInstanceInput.svelte +++ b/web/src/components/settings/CustomInstanceInput.svelte @@ -5,15 +5,18 @@ import settings, { updateSetting } from "$lib/state/settings"; import { customInstanceWarning } from "$lib/api/safety-warning"; + import IconX from "@tabler/icons-svelte/IconX.svelte"; + import IconCheck from "@tabler/icons-svelte/IconCheck.svelte"; + let inputValue = get(settings).processing.customInstanceURL; + let inputFocused = false; let url: string; let validUrl: boolean; const checkUrl = () => { try { - let test = /^https:/i.test(new URL(inputValue).protocol); - if (test) url = new URL(inputValue).origin.toString(); + url = new URL(inputValue).origin.toString(); validUrl = true; } catch { validUrl = false; @@ -36,50 +39,128 @@ }; - { - checkUrl(); - }} - spellcheck="false" - autocomplete="off" - autocapitalize="off" - maxlength="128" - placeholder="instance url" -/> +
+
+ { + checkUrl(); + inputFocused = true; + }} + on:input={() => (inputFocused = true)} + on:focus={() => (inputFocused = true)} + on:blur={() => (inputFocused = false)} + spellcheck="false" + autocomplete="off" + autocapitalize="off" + maxlength="64" + placeholder={$t("settings.processing.custom.placeholder")} + /> +
+
+ - - -{#if $settings.processing.customInstanceURL.length > 0} - -{/if} + +
+