From c6de68c4c4bda3edcf6cf012bd98adea3baf866b Mon Sep 17 00:00:00 2001
From: ManeraKai <manerakai@protonmail.com>
Date: Thu, 25 Jul 2024 15:17:57 +0300
Subject: Migrating popup to svelte

---
 src/pages/components/Row.svelte | 12 ++++++++++++
 1 file changed, 12 insertions(+)
 create mode 100644 src/pages/components/Row.svelte

(limited to 'src/pages/components/Row.svelte')

diff --git a/src/pages/components/Row.svelte b/src/pages/components/Row.svelte
new file mode 100644
index 00000000..68b528e3
--- /dev/null
+++ b/src/pages/components/Row.svelte
@@ -0,0 +1,12 @@
+<div {...$$props} on:click>
+  <slot></slot>
+</div>
+
+<style>
+  div {
+    justify-content: space-between;
+    display: flex;
+    align-items: center;
+    margin: 20px 0;
+  }
+</style>
-- 
cgit 1.4.1


From ed0c90ec3de1fa5fa8f7ebc138d62174eb07b363 Mon Sep 17 00:00:00 2001
From: ManeraKai <manerakai@protonmail.com>
Date: Sat, 27 Jul 2024 12:11:54 +0300
Subject: Cleaned code

---
 src/pages/components/Button.svelte                 |  2 +-
 src/pages/components/Input.svelte                  |  2 +-
 src/pages/components/Row.svelte                    |  2 +-
 src/pages/options_src/General/General.svelte       |  6 ++--
 .../options_src/General/SettingsButtons.svelte     | 34 +++++++---------------
 src/pages/options_src/Sidebar.svelte               |  6 ++--
 6 files changed, 18 insertions(+), 34 deletions(-)

(limited to 'src/pages/components/Row.svelte')

diff --git a/src/pages/components/Button.svelte b/src/pages/components/Button.svelte
index 3405c2ea..8836b47e 100644
--- a/src/pages/components/Button.svelte
+++ b/src/pages/components/Button.svelte
@@ -1,4 +1,4 @@
-<button on:click {...$$props}>
+<button {...$$restProps} on:click {...$$props}>
   <slot></slot>
 </button>
 
diff --git a/src/pages/components/Input.svelte b/src/pages/components/Input.svelte
index 97a47e6d..59e584db 100644
--- a/src/pages/components/Input.svelte
+++ b/src/pages/components/Input.svelte
@@ -3,7 +3,7 @@
 </script>
 
 <input
-  {...$$props}
+  {...$$restProps}
   bind:value
   on:blur
   on:change
diff --git a/src/pages/components/Row.svelte b/src/pages/components/Row.svelte
index 68b528e3..09246d98 100644
--- a/src/pages/components/Row.svelte
+++ b/src/pages/components/Row.svelte
@@ -1,4 +1,4 @@
-<div {...$$props} on:click>
+<div {...$$restProps} on:click>
   <slot></slot>
 </div>
 
diff --git a/src/pages/options_src/General/General.svelte b/src/pages/options_src/General/General.svelte
index 732ad83b..37c38a0a 100644
--- a/src/pages/options_src/General/General.svelte
+++ b/src/pages/options_src/General/General.svelte
@@ -38,7 +38,6 @@
         _options.theme = e.target.options[e.target.options.selectedIndex].value
         options.set(_options)
       }}
-      ariaLabel="select theme"
     />
   </Row>
 
@@ -55,7 +54,6 @@
         _options.fetchInstances = e.target.options[e.target.options.selectedIndex].value
         options.set(_options)
       }}
-      ariaLabel={"Select fetch public instances"}
     />
   </Row>
 
@@ -75,7 +73,7 @@
     <Checkbox bind:checked={bookmarksPermission} />
   </Row>
 
-  <Exceptions opts={_options} />
+  <Exceptions />
 
-  <SettingsButtons opts={_options} />
+  <SettingsButtons />
 </div>
diff --git a/src/pages/options_src/General/SettingsButtons.svelte b/src/pages/options_src/General/SettingsButtons.svelte
index 3ea46a2d..2f574199 100644
--- a/src/pages/options_src/General/SettingsButtons.svelte
+++ b/src/pages/options_src/General/SettingsButtons.svelte
@@ -14,24 +14,18 @@
   const unsubscribe = options.subscribe(val => (_options = val))
   onDestroy(unsubscribe)
 
-  let disableButtons = false
-
   let importSettingsInput
   let importSettingsFiles
   $: if (importSettingsFiles) {
-    disableButtons = true
     const reader = new FileReader()
     reader.readAsText(importSettingsFiles[0])
     reader.onload = async () => {
       const data = JSON.parse(reader.result)
       if ("theme" in data && data.version == browser.runtime.getManifest().version) {
         browser.storage.local.clear(async () => {
-          console.log("clearing")
           options.set(data)
-          disableButtons = false
         })
       } else {
-        console.log("incompatible settings")
         alert("Incompatible settings")
       }
     }
@@ -42,26 +36,21 @@
   }
 
   async function exportSettings() {
-    disableButtons = true
     _options.version = browser.runtime.getManifest().version
     const resultString = JSON.stringify(_options, null, "  ")
     const anchor = document.createElement("a")
     anchor.href = "data:application/json;base64," + btoa(resultString)
     anchor.download = `libredirect-settings-v${_options.version}.json`
     anchor.click()
-    disableButtons = false
   }
 
   async function exportSettingsSync() {
-    disableButtons = true
     _options.version = browser.runtime.getManifest().version
     await servicesHelper.initDefaults()
     browser.storage.sync.set({ options: _options })
-    disableButtons = false
   }
 
   async function importSettingsSync() {
-    disableButtons = true
     browser.storage.sync.get({ options }, r => {
       const optionsSync = r.options
       if (optionsSync.version == browser.runtime.getManifest().version) {
@@ -69,24 +58,21 @@
       } else {
         alert("Error")
       }
-      disableButtons = false
     })
   }
 
   async function resetSettings() {
-    disableButtons = true
     browser.storage.local.clear(async () => {
       await servicesHelper.initDefaults()
       options.set(await utils.getOptions())
-      disableButtons = false
     })
   }
 </script>
 
 <div class="buttons">
-  <Button on:click={() => importSettingsInput.click()} disabled={disableButtons}>
+  <Button on:click={() => importSettingsInput.click()}>
     <ImportIcon class="margin margin_{document.body.dir}" />
-    <x data-localise="__MSG_importSettings__">{browser.i18n.getMessage("importSettings") || "Import Settings"}</x>
+    {browser.i18n.getMessage("importSettings") || "Import Settings"}
   </Button>
   <input
     type="file"
@@ -96,24 +82,24 @@
     bind:files={importSettingsFiles}
   />
 
-  <Button on:click={exportSettings} disabled={disableButtons}>
+  <Button on:click={exportSettings}>
     <ExportIcon class="margin margin_{document.body.dir}" />
-    <x data-localise="__MSG_exportSettings__">{browser.i18n.getMessage("exportSettings") || "Export Settings"}</x>
+    {browser.i18n.getMessage("exportSettings") || "Export Settings"}
   </Button>
 
-  <Button on:click={exportSettingsSync} disabled={disableButtons}>
+  <Button on:click={exportSettingsSync}>
     <ExportIcon class="margin margin_{document.body.dir}" />
-    <x>Export Settings to Sync</x>
+    {browser.i18n.getMessage("exportSettingsToSync") || "Export Settings to Sync"}
   </Button>
 
-  <Button on:click={importSettingsSync} disabled={disableButtons}>
+  <Button on:click={importSettingsSync}>
     <ImportIcon class="margin margin_{document.body.dir}" />
-    <x>{browser.i18n.getMessage("importSettingsFromSync") || "Import Settings from Sync"}</x>
+    {browser.i18n.getMessage("importSettingsFromSync") || "Import Settings from Sync"}
   </Button>
 
-  <Button on:click={resetSettings} disabled={disableButtons}>
+  <Button on:click={resetSettings}>
     <ResetIcon class="margin margin_{document.body.dir}" />
-    <x>{browser.i18n.getMessage("resetSettings") || "Reset Settings"}</x>
+    {browser.i18n.getMessage("resetSettings") || "Reset Settings"}
   </Button>
 </div>
 
diff --git a/src/pages/options_src/Sidebar.svelte b/src/pages/options_src/Sidebar.svelte
index fb515f53..97780b15 100644
--- a/src/pages/options_src/Sidebar.svelte
+++ b/src/pages/options_src/Sidebar.svelte
@@ -10,15 +10,15 @@
 <div>
   <a href="#general" on:click={() => page.set("general")} style={$page == "general" && "color: var(--active);"}>
     <GeneralIcon class="margin margin_{document.body.dir}" />
-    <span data-localise="__MSG_general__">{browser.i18n.getMessage("general") || "General"}</span>
+    {browser.i18n.getMessage("general") || "General"}
   </a>
   <a href="#services" on:click={() => page.set("services")} style={$page == "services" && "color: var(--active);"}>
     <ServicesIcon class="margin margin_{document.body.dir}" />
-    <span data-localise="__MSG_services__">{browser.i18n.getMessage("general") || "Services"}</span>
+    {browser.i18n.getMessage("general") || "Services"}
   </a>
   <a href="https://libredirect.github.io" target="_blank" rel="noopener noreferrer">
     <AboutIcon class="margin margin_{document.body.dir}" />
-    <span data-localise="__MSG_about__">{browser.i18n.getMessage("about") || "About"}</span>
+    {browser.i18n.getMessage("about") || "About"}
   </a>
 </div>
 
-- 
cgit 1.4.1

