From c6de68c4c4bda3edcf6cf012bd98adea3baf866b Mon Sep 17 00:00:00 2001 From: ManeraKai Date: Thu, 25 Jul 2024 15:17:57 +0300 Subject: Migrating popup to svelte --- src/pages/components/Input.svelte | 41 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 src/pages/components/Input.svelte (limited to 'src/pages/components/Input.svelte') diff --git a/src/pages/components/Input.svelte b/src/pages/components/Input.svelte new file mode 100644 index 00000000..d963233c --- /dev/null +++ b/src/pages/components/Input.svelte @@ -0,0 +1,41 @@ + + + + + -- cgit 1.4.1 From 2cb60e91cd33ea63dc43b7afb2ce7a261bce6512 Mon Sep 17 00:00:00 2001 From: ManeraKai Date: Fri, 26 Jul 2024 17:39:22 +0300 Subject: Added mobile support in Svelte --- package.json | 2 +- src/assets/javascripts/utils.js | 8 -- src/pages/components/Input.svelte | 5 ++ src/pages/components/RowCheckbox.svelte | 14 ---- src/pages/components/RowSelect.svelte | 19 ----- src/pages/fonts/Inter-VariableFont_slnt,wght.ttf | Bin 0 -> 803384 bytes src/pages/fonts/Vazirmatn-VariableFont_wght.ttf | Bin 0 -> 285620 bytes src/pages/fonts/styles.css | 13 +++ src/pages/options/index.html | 1 + src/pages/options_src/App.svelte | 20 ++++- src/pages/options_src/General/General.svelte | 89 ++++++++++++--------- src/pages/options_src/Services/Instances.svelte | 5 +- src/pages/options_src/Services/RedirectType.svelte | 23 +++--- src/pages/options_src/Services/Services.svelte | 71 ++++++++-------- src/pages/options_src/Sidebar.svelte | 14 ++++ src/pages/popup/index.html | 2 +- .../stylesheets/Inter-VariableFont_slnt,wght.ttf | Bin 803384 -> 0 bytes .../stylesheets/Vazirmatn-VariableFont_wght.ttf | Bin 285620 -> 0 bytes src/pages/stylesheets/styles.css | 88 -------------------- 19 files changed, 157 insertions(+), 217 deletions(-) delete mode 100644 src/pages/components/RowCheckbox.svelte delete mode 100644 src/pages/components/RowSelect.svelte create mode 100644 src/pages/fonts/Inter-VariableFont_slnt,wght.ttf create mode 100644 src/pages/fonts/Vazirmatn-VariableFont_wght.ttf create mode 100644 src/pages/fonts/styles.css delete mode 100644 src/pages/stylesheets/Inter-VariableFont_slnt,wght.ttf delete mode 100644 src/pages/stylesheets/Vazirmatn-VariableFont_wght.ttf delete mode 100644 src/pages/stylesheets/styles.css (limited to 'src/pages/components/Input.svelte') diff --git a/package.json b/package.json index d0669a69..0f89cbdb 100644 --- a/package.json +++ b/package.json @@ -9,7 +9,7 @@ "scripts": { "start": "web-ext run", "nightly": "web-ext run --firefox=/home/esmail/software/firefox_nightly/firefox", - "android": "web-ext run -t firefox-android --adb-device emulator-5554 --firefox-apk org.mozilla.fenix", + "android": "web-ext run -t firefox-android --adb-device emulator-5554 --firefox-apk org.mozilla.fenix ", "build": "web-ext build", "test": "web-ext lint", "html": "rollup -c --config-popup && rollup -c --config-options" diff --git a/src/assets/javascripts/utils.js b/src/assets/javascripts/utils.js index 439826dd..18168e90 100644 --- a/src/assets/javascripts/utils.js +++ b/src/assets/javascripts/utils.js @@ -20,13 +20,6 @@ function getNextInstance(currentInstanceUrl, instances) { return instances[nextInstanceIndex] } -/** - * @param {string} str - */ -function camelCase(str) { - return str.charAt(0).toUpperCase() + str.slice(1) -} - /** * @param {URL} url */ @@ -178,7 +171,6 @@ export default { protocolHost, getList, getBlacklist, - camelCase, getConfig, getOptions, getPingCache, diff --git a/src/pages/components/Input.svelte b/src/pages/components/Input.svelte index d963233c..97a47e6d 100644 --- a/src/pages/components/Input.svelte +++ b/src/pages/components/Input.svelte @@ -38,4 +38,9 @@ input:focus { outline-color: var(--active); } + @media (max-width: 715px) { + input { + width: 200px; + } + } diff --git a/src/pages/components/RowCheckbox.svelte b/src/pages/components/RowCheckbox.svelte deleted file mode 100644 index b7ccab93..00000000 --- a/src/pages/components/RowCheckbox.svelte +++ /dev/null @@ -1,14 +0,0 @@ - - - - - - diff --git a/src/pages/components/RowSelect.svelte b/src/pages/components/RowSelect.svelte deleted file mode 100644 index d685803e..00000000 --- a/src/pages/components/RowSelect.svelte +++ /dev/null @@ -1,19 +0,0 @@ - - - - - { + _options.theme = e.target.options[e.target.options.selectedIndex].value + options.set(_options) + }} + ariaLabel="select theme" + /> + - { - _options["fetchInstances"] = e.target.options[e.target.options.selectedIndex].value - options.set(_options) - }} - ariaLabel="Select fetch public instances" - values={[ - { value: "github", name: "GitHub" }, - { value: "codeberg", name: "Codeberg" }, - { value: "disable", name: "Disable" }, - ]} - /> + + + { + serviceOptions.redirectType = e.target.options[e.target.options.selectedIndex].value + options.set(_options) + }} + {values} + /> + {#if serviceConf.frontends[frontendName].desktopApp && serviceOptions.redirectType != "main_frame"} diff --git a/src/pages/options_src/Services/Services.svelte b/src/pages/options_src/Services/Services.svelte index cb1efacb..9c4e6c97 100644 --- a/src/pages/options_src/Services/Services.svelte +++ b/src/pages/options_src/Services/Services.svelte @@ -1,6 +1,4 @@ diff --git a/src/pages/stylesheets/Inter-VariableFont_slnt,wght.ttf b/src/pages/stylesheets/Inter-VariableFont_slnt,wght.ttf deleted file mode 100644 index 969a990f..00000000 Binary files a/src/pages/stylesheets/Inter-VariableFont_slnt,wght.ttf and /dev/null differ diff --git a/src/pages/stylesheets/Vazirmatn-VariableFont_wght.ttf b/src/pages/stylesheets/Vazirmatn-VariableFont_wght.ttf deleted file mode 100644 index f4b97c01..00000000 Binary files a/src/pages/stylesheets/Vazirmatn-VariableFont_wght.ttf and /dev/null differ diff --git a/src/pages/stylesheets/styles.css b/src/pages/stylesheets/styles.css deleted file mode 100644 index 9e8fedb3..00000000 --- a/src/pages/stylesheets/styles.css +++ /dev/null @@ -1,88 +0,0 @@ -@font-face { - font-family: "Inter"; - src: url("Inter-VariableFont_slnt,wght.ttf"); - font-weight: normal; - font-style: normal; -} - -@font-face { - font-family: "Vazirmatn"; - src: url("Vazirmatn-VariableFont_wght.ttf"); - font-weight: normal; - font-style: normal; -} - -/* - -@media (max-width: 1250px) { - body.option { - flex-direction: column; - width: 95vw; - align-items: center; - padding: 40px 0px; - } - - section.links { - flex-direction: row; - width: 95vw; - padding: 0 55px; - } - - section.block-option { - width: 95vw; - } - - div.checklist div x { - overflow: hidden; - } -} - -html.mobile img, -html.mobile svg { - margin-right: 10px; - height: 30px; - width: 30px; - color: var(--text); -} - -html.mobile div.block { - padding: 0 15px; - justify-content: space-between; - display: flex; - align-items: center; - margin-top: 20px; - margin-bottom: 20px; -} - -html.mobile div.block input[type="checkbox"] { - width: 58px; - height: 30px; -} - -html.mobile div.block input[type="checkbox"]::before { - width: 24px; - height: 24px; - top: 3px; - left: 3.5px; -} - -html.mobile div.block input[type="checkbox"]:checked::before { - left: 30px; -} - -html.mobile body.option { - flex-direction: column; - width: 100%; - padding: 0; - align-items: center; -} - -html.mobile section.links { - flex-direction: row; - width: 100%; - padding: 0 55px; -} - -html.mobile section.block-option { - width: 100%; -} */ \ No newline at end of file -- cgit 1.4.1 From ed0c90ec3de1fa5fa8f7ebc138d62174eb07b363 Mon Sep 17 00:00:00 2001 From: ManeraKai 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/Input.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 @@ - 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 @@ +
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" />
@@ -55,7 +54,6 @@ _options.fetchInstances = e.target.options[e.target.options.selectedIndex].value options.set(_options) }} - ariaLabel={"Select fetch public instances"} /> @@ -75,7 +73,7 @@ - + - + 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 }) }
- - - - -
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 @@ -- cgit 1.4.1