aboutsummaryrefslogtreecommitdiff
path: root/src/lib/CommandPalette/toggleActions.ts
diff options
context:
space:
mode:
authorFuwn <[email protected]>2026-04-26 12:40:27 +0000
committerFuwn <[email protected]>2026-04-26 12:40:27 +0000
commit5accc4e512e9bbff8d4303cb732edccaccd9b5a3 (patch)
tree3c51680e1cabb45941a7716cb769d04b8cb56c06 /src/lib/CommandPalette/toggleActions.ts
parentfix(tooltip): park off-screen on create, enable glide after first placement (diff)
downloaddue.moe-5accc4e512e9bbff8d4303cb732edccaccd9b5a3.tar.xz
due.moe-5accc4e512e9bbff8d4303cb732edccaccd9b5a3.zip
feat(command-palette): add quick toggles, sync, and auth actions
Adds 13 reactive quick toggles (24h time, animations, blur adult, cover modes, hover cover, schedule list, reverse sort, data saver, notifications, language, title format cycle, outbound link target cycle), three sync actions (push/pull/disable), and login/logout entries gated on auth state. Names reflect current state so the palette doubles as a status surface.
Diffstat (limited to 'src/lib/CommandPalette/toggleActions.ts')
-rw-r--r--src/lib/CommandPalette/toggleActions.ts160
1 files changed, 160 insertions, 0 deletions
diff --git a/src/lib/CommandPalette/toggleActions.ts b/src/lib/CommandPalette/toggleActions.ts
new file mode 100644
index 00000000..b93b5626
--- /dev/null
+++ b/src/lib/CommandPalette/toggleActions.ts
@@ -0,0 +1,160 @@
+import settings, { type Settings } from "$stores/settings";
+import type { CommandPaletteAction } from "./actions";
+
+const TITLE_FORMATS: Settings["displayTitleFormat"][] = [
+ "english",
+ "romaji",
+ "native",
+];
+
+const OUTBOUND_TARGETS: Settings["displayOutboundLinksTo"][] = [
+ "anilist",
+ "livechartme",
+ "animeschedule",
+ "myanimelist",
+];
+
+const OUTBOUND_LABELS: Record<Settings["displayOutboundLinksTo"], string> = {
+ anilist: "AniList",
+ livechartme: "LiveChart",
+ animeschedule: "AnimeSchedule",
+ myanimelist: "MyAnimeList",
+};
+
+type BooleanKey = NonNullable<
+ {
+ [K in keyof Settings]: Settings[K] extends boolean ? K : never;
+ }[keyof Settings]
+>;
+
+const boolToggle = (
+ current: boolean,
+ key: BooleanKey,
+ enableLabel: string,
+ disableLabel: string,
+ tags: string[],
+): CommandPaletteAction => ({
+ name: current ? disableLabel : enableLabel,
+ url: "#",
+ preventDefault: true,
+ tags,
+ onClick: () => settings.setKey(key, !current),
+});
+
+export const toggleActions = (current: Settings): CommandPaletteAction[] => {
+ const titleIndex = TITLE_FORMATS.indexOf(current.displayTitleFormat);
+ const nextTitle = TITLE_FORMATS[(titleIndex + 1) % TITLE_FORMATS.length];
+
+ const outboundIndex = OUTBOUND_TARGETS.indexOf(current.displayOutboundLinksTo);
+ const nextOutbound =
+ OUTBOUND_TARGETS[(outboundIndex + 1) % OUTBOUND_TARGETS.length];
+
+ return [
+ boolToggle(
+ current.display24HourTime,
+ "display24HourTime",
+ "Switch to 24-hour time",
+ "Switch to 12-hour time",
+ ["time", "clock", "24h", "12h", "format"],
+ ),
+ boolToggle(
+ current.displayDisableAnimations,
+ "displayDisableAnimations",
+ "Disable animations",
+ "Enable animations",
+ ["motion", "animation", "accessibility"],
+ ),
+ boolToggle(
+ current.displayBlurAdultContent,
+ "displayBlurAdultContent",
+ "Blur adult content",
+ "Show adult content unblurred",
+ ["nsfw", "adult", "blur", "censor"],
+ ),
+ boolToggle(
+ current.displayCoverModeAnime,
+ "displayCoverModeAnime",
+ "Show anime covers",
+ "Hide anime covers",
+ ["cover", "image", "anime", "display"],
+ ),
+ boolToggle(
+ current.displayCoverModeManga,
+ "displayCoverModeManga",
+ "Show manga covers",
+ "Hide manga covers",
+ ["cover", "image", "manga", "novels", "display"],
+ ),
+ boolToggle(
+ current.displayHoverCover,
+ "displayHoverCover",
+ "Enable hover cover preview",
+ "Disable hover cover preview",
+ ["cover", "hover", "preview"],
+ ),
+ boolToggle(
+ current.displayScheduleListMode,
+ "displayScheduleListMode",
+ "Schedule: list mode",
+ "Schedule: grid mode",
+ ["schedule", "list", "grid", "view"],
+ ),
+ boolToggle(
+ current.displayReverseSort,
+ "displayReverseSort",
+ "Reverse sort order",
+ "Restore default sort order",
+ ["sort", "reverse", "order"],
+ ),
+ boolToggle(
+ current.displayDataSaver,
+ "displayDataSaver",
+ "Enable data saver",
+ "Disable data saver",
+ ["data", "bandwidth", "saver", "performance"],
+ ),
+ boolToggle(
+ current.displayDisableNotifications,
+ "displayDisableNotifications",
+ "Disable in-app notifications",
+ "Enable in-app notifications",
+ ["notifications", "alerts", "toast"],
+ ),
+ {
+ name:
+ current.displayLanguage === "en"
+ ? "Switch language to 日本語"
+ : "Switch language to English",
+ url: "#",
+ preventDefault: true,
+ tags: ["language", "locale", "translate", "japanese", "english"],
+ onClick: () =>
+ settings.setKey(
+ "displayLanguage",
+ current.displayLanguage === "en" ? "ja" : "en",
+ ),
+ },
+ {
+ name: `Title format: ${current.displayTitleFormat} → ${nextTitle}`,
+ url: "#",
+ preventDefault: true,
+ tags: ["title", "format", "english", "romaji", "native"],
+ onClick: () => settings.setKey("displayTitleFormat", nextTitle),
+ },
+ {
+ name: `Outbound links: ${OUTBOUND_LABELS[current.displayOutboundLinksTo]} → ${OUTBOUND_LABELS[nextOutbound]}`,
+ url: "#",
+ preventDefault: true,
+ tags: [
+ "outbound",
+ "links",
+ "anilist",
+ "livechart",
+ "animeschedule",
+ "myanimelist",
+ "mal",
+ ],
+ onClick: () => settings.setKey("displayOutboundLinksTo", nextOutbound),
+ },
+ ];
+};