From 233201807a6f55db159c121177890ea7142a7c2d Mon Sep 17 00:00:00 2001 From: WardPearce Date: Mon, 2 Mar 2026 19:10:50 +1300 Subject: [PATCH] Implemented Melt's tabs --- .../lib/components/settings/DeArrow.svelte | 4 +- .../lib/components/settings/Interface.svelte | 2 +- .../src/lib/components/settings/RYD.svelte | 2 +- .../lib/components/settings/Settings.svelte | 93 +++++++------------ .../components/settings/SponsorBlock.svelte | 2 +- 5 files changed, 40 insertions(+), 63 deletions(-) diff --git a/materialious/src/lib/components/settings/DeArrow.svelte b/materialious/src/lib/components/settings/DeArrow.svelte index f6e0adb1..0a06fe51 100644 --- a/materialious/src/lib/components/settings/DeArrow.svelte +++ b/materialious/src/lib/components/settings/DeArrow.svelte @@ -22,7 +22,7 @@ - @@ -35,7 +35,7 @@ - diff --git a/materialious/src/lib/components/settings/Interface.svelte b/materialious/src/lib/components/settings/Interface.svelte index 2939b39c..10939f72 100644 --- a/materialious/src/lib/components/settings/Interface.svelte +++ b/materialious/src/lib/components/settings/Interface.svelte @@ -166,7 +166,7 @@ > {/if} - diff --git a/materialious/src/lib/components/settings/RYD.svelte b/materialious/src/lib/components/settings/RYD.svelte index e8f8ae04..d7984e89 100644 --- a/materialious/src/lib/components/settings/RYD.svelte +++ b/materialious/src/lib/components/settings/RYD.svelte @@ -20,7 +20,7 @@ - diff --git a/materialious/src/lib/components/settings/Settings.svelte b/materialious/src/lib/components/settings/Settings.svelte index e8038828..7c36ad59 100644 --- a/materialious/src/lib/components/settings/Settings.svelte +++ b/materialious/src/lib/components/settings/Settings.svelte @@ -12,13 +12,29 @@ import { isUnrestrictedPlatform } from '$lib/misc'; import { isOwnBackend } from '$lib/shared'; import InternalAccount from './InternalAccount.svelte'; + import { Tabs } from 'melt/builders'; + import { mergeAttrs } from 'melt'; - let activeTab = $state('interface'); - const isActive = (id: string) => activeTab === id; + type TabCategories = + | 'interface' + | 'player' + | 'ryd' + | 'sponsorblock' + | 'dearrow' + | 'about' + | 'engine' + | 'account'; + + const tabCategories: Tabs = new Tabs({ + value: 'interface', + orientation: 'vertical' + }); + + const isActive = (id: string) => tabCategories.value === id; let mobileCategoriesButton: HTMLElement | undefined = $state(); - let tabs: { id: string; label: string; icon: string; component: Component }[] = $state([ + let tabs: { id: TabCategories; label: string; icon: string; component: Component }[] = $state([ { id: 'interface', label: $_('layout.interface'), icon: 'grid_view', component: Interface }, { id: 'player', label: $_('layout.player.title'), icon: 'smart_display', component: Player }, { id: 'ryd', label: 'Return YT Dislike', icon: 'thumb_down', component: Ryd }, @@ -71,41 +87,9 @@ } } - function onKeydown(event: KeyboardEvent, idx: number) { - const keys = ['ArrowRight', 'ArrowLeft', 'Home', 'End'] as const; - if (!keys.includes(event.key as (typeof keys)[number])) return; - - event.preventDefault(); - - let next = idx; - switch (event.key) { - case 'ArrowRight': - next = (idx + 1) % tabs.length; - break; - case 'ArrowLeft': - next = (idx - 1 + tabs.length) % tabs.length; - break; - case 'Home': - next = 0; - break; - case 'End': - next = tabs.length - 1; - break; - } - - activeTab = tabs[next].id; - - const els = document.querySelectorAll('[role="tab"]'); - els[next]?.focus(); - } - onMount(() => { checkWidth(); - addEventListener('resize', () => checkWidth()); - if ($isAndroidTvStore) { - document.getElementById(`tab-${activeTab}`)?.focus(); - } }); @@ -118,7 +102,7 @@