From 7771e2618d3bffbcaebc23a21d2e34fe4012d89a Mon Sep 17 00:00:00 2001 From: Fuwn Date: Tue, 6 May 2025 06:04:52 -0700 Subject: feat: Add command palette --- src/lib/CommandPalette/CommandPalette.svelte | 161 +++++++++++++++++++++++++++ src/lib/CommandPalette/actions.ts | 34 ++++++ src/lib/Tools/tools.ts | 15 +++ 3 files changed, 210 insertions(+) create mode 100644 src/lib/CommandPalette/CommandPalette.svelte create mode 100644 src/lib/CommandPalette/actions.ts (limited to 'src/lib') diff --git a/src/lib/CommandPalette/CommandPalette.svelte b/src/lib/CommandPalette/CommandPalette.svelte new file mode 100644 index 00000000..36c97a91 --- /dev/null +++ b/src/lib/CommandPalette/CommandPalette.svelte @@ -0,0 +1,161 @@ + + + + +{#if open} + +{/if} + + diff --git a/src/lib/CommandPalette/actions.ts b/src/lib/CommandPalette/actions.ts new file mode 100644 index 00000000..73128a2c --- /dev/null +++ b/src/lib/CommandPalette/actions.ts @@ -0,0 +1,34 @@ +export const defaultActions = [ + { + name: 'Home', + url: '/' + }, + { + name: 'Completed', + url: '/completed' + }, + { + name: 'Subtitle Schedule', + url: '/schedule' + }, + { + name: 'hololive Schedule', + url: '/hololive' + }, + { + name: 'Character Birthdays', + url: '/birthdays' + }, + { + name: 'New Releases', + url: '/releases' + }, + { + name: 'Settings', + url: '/settings' + }, + { + name: 'My Profile', + url: '/user' + } +]; diff --git a/src/lib/Tools/tools.ts b/src/lib/Tools/tools.ts index 9f9234c9..82ffef96 100644 --- a/src/lib/Tools/tools.ts +++ b/src/lib/Tools/tools.ts @@ -1,6 +1,21 @@ import locale from '$stores/locale'; import { get } from 'svelte/store'; +interface CommandPaletteItem { + name: string; + url: string; + onClick?: () => void; + preventDefault?: boolean; +} + +export const toolsAsCommandPaletteItemSet = () => + Object.entries(tools) + .filter(([id, tool]) => id !== 'default' && !tool.hidden) + .map(([id, tool]) => ({ + name: tool.name(), + url: `/tools/${id}` + })); + export const tools: { [key: string]: { name: () => string; -- cgit v1.2.3