From 9857ba6416e23e4883bb763593e898cdebd72b74 Mon Sep 17 00:00:00 2001 From: bytedream Date: Thu, 2 Jul 2026 11:11:56 +0200 Subject: [PATCH] update settings layout --- src/entrypoints/popup/App.svelte | 4 +- .../popup/components/HostRow.svelte | 54 +++++++++++++++ .../popup/components/SearchInput.svelte | 36 ++++++++++ .../popup/components/Section.svelte | 59 +++++++++++++++++ .../popup/pages/settings/Ff2mpv.svelte | 13 ++-- .../popup/pages/settings/Header.svelte | 21 ++++-- .../popup/pages/settings/HostsTable.svelte | 66 ++++++++++--------- .../popup/pages/settings/Settings.svelte | 46 +++++-------- src/lib/host/index.ts | 9 +++ 9 files changed, 237 insertions(+), 71 deletions(-) create mode 100644 src/entrypoints/popup/components/HostRow.svelte create mode 100644 src/entrypoints/popup/components/SearchInput.svelte create mode 100644 src/entrypoints/popup/components/Section.svelte diff --git a/src/entrypoints/popup/App.svelte b/src/entrypoints/popup/App.svelte index 0ec1544..194af18 100644 --- a/src/entrypoints/popup/App.svelte +++ b/src/entrypoints/popup/App.svelte @@ -17,7 +17,7 @@ let activePage = $state('main'); -
+
{#if activePage === 'main'}
@@ -26,7 +26,7 @@ {:else if activePage === 'settings'}
(activePage = 'main')} /> diff --git a/src/entrypoints/popup/components/HostRow.svelte b/src/entrypoints/popup/components/HostRow.svelte new file mode 100644 index 0000000..ab1824c --- /dev/null +++ b/src/entrypoints/popup/components/HostRow.svelte @@ -0,0 +1,54 @@ + + + +
+ +
+

{host.name}

+

+ {host.domains.join(', ')} +

+
+
+ {@render actions()} +
+
diff --git a/src/entrypoints/popup/components/SearchInput.svelte b/src/entrypoints/popup/components/SearchInput.svelte new file mode 100644 index 0000000..0dfd6f8 --- /dev/null +++ b/src/entrypoints/popup/components/SearchInput.svelte @@ -0,0 +1,36 @@ + + +
+ + + {#if value} + + {/if} +
diff --git a/src/entrypoints/popup/components/Section.svelte b/src/entrypoints/popup/components/Section.svelte new file mode 100644 index 0000000..cb0b5df --- /dev/null +++ b/src/entrypoints/popup/components/Section.svelte @@ -0,0 +1,59 @@ + + +
+ + {#if open} +
+
+ {@render children()} +
+
+ {/if} +
+ + diff --git a/src/entrypoints/popup/pages/settings/Ff2mpv.svelte b/src/entrypoints/popup/pages/settings/Ff2mpv.svelte index 811662b..04cdbb6 100644 --- a/src/entrypoints/popup/pages/settings/Ff2mpv.svelte +++ b/src/entrypoints/popup/pages/settings/Ff2mpv.svelte @@ -16,14 +16,17 @@ } -
-
- Communication enabled +
+
+

Communication enabled

+ + Learn more +
{#key enabled} + import { ArrowLeft } from '@steeze-ui/heroicons'; + import { Icon } from '@steeze-ui/svelte-icon'; + /* types */ interface Props { onBackClick: () => void; @@ -8,9 +11,19 @@ let { onBackClick }: Props = $props(); -
-
- -

Settings

+
+
+ +
+

Settings

+

Manage hosts and integrations

+
diff --git a/src/entrypoints/popup/pages/settings/HostsTable.svelte b/src/entrypoints/popup/pages/settings/HostsTable.svelte index 44bad7a..5d66258 100644 --- a/src/entrypoints/popup/pages/settings/HostsTable.svelte +++ b/src/entrypoints/popup/pages/settings/HostsTable.svelte @@ -1,41 +1,47 @@ -
-

Host

-

Domains

-

Enabled

- {#each hosts as host (host.id)} - {@const domainList = host.domains.join(', ')} -

{host.name}

-
- +
+ + {#if filtered.length === 0} +

No hosts match "{searchQuery}"

+ {:else} +
+ {#each filtered as host (host.id)} + + {#snippet actions()} + {#key disabledHostIds} + !disabledHostIds.includes(host.id), + (v) => + v + ? HostSettings.removeDisabledHost(host.id) + : HostSettings.addDisabledHost(host.id) + } + size="sm" + /> + {/key} + {/snippet} + + {/each}
-
- {#key disabledHostIds} - !disabledHostIds.includes(host.id), - (v) => (v ? HostSettings.removeDisabledHost(host.id) : HostSettings.addDisabledHost(host.id)) - } - size="sm" - > - {/key} -
- {/each} + {/if}
diff --git a/src/entrypoints/popup/pages/settings/Settings.svelte b/src/entrypoints/popup/pages/settings/Settings.svelte index 1e61994..8ecb2d0 100644 --- a/src/entrypoints/popup/pages/settings/Settings.svelte +++ b/src/entrypoints/popup/pages/settings/Settings.svelte @@ -1,5 +1,7 @@
-
-
- Hosts - -
+
+
+
+ +
+
{#if !$isMobile} -
- ff2mpv +
-
+ {/if}
@@ -35,26 +43,4 @@ * { user-select: none; } - - .details { - /* using normal css instead of tailwind in the following blocks. - for some reason tailwind fails to resolve many references */ - - &::before, - &::after { - content: ''; - display: block; - width: 100%; - border-top: 1px solid var(--color-gray-600); - margin: 0.25rem 0; - } - - & > summary { - cursor: pointer; - } - - &[open] > summary { - margin-bottom: 0.5rem; - } - } diff --git a/src/lib/host/index.ts b/src/lib/host/index.ts index 5d9ab34..f72637c 100644 --- a/src/lib/host/index.ts +++ b/src/lib/host/index.ts @@ -69,6 +69,15 @@ export function getHostFromId(id: HostId): Host | null { return hosts.find((host) => host.id === id) ?? null; } +export function filterHosts(list: Host[], query: string): Host[] { + const q = query.trim().toLowerCase(); + if (!q) return list; + return list.filter((host) => { + if (host.name.toLowerCase().includes(q)) return true; + return host.domains.some((domain) => domain.toLowerCase().includes(q)); + }); +} + export async function getHost(domain: string): Promise { if (await HostSettings.getAllHostsDisabled()) return null;