Skip to content

Commit 0a0d979

Browse files
committed
Remove theme toggle keybind, add Storybook theme variants
- Remove Cmd+Option+T / Ctrl+Alt+T keybind for theme toggle - Keep theme toggle as command palette action only - Add Storybook global theme switcher in toolbar - All stories now support both light and dark theme preview - Theme switcher appears as sun/moon icons in Storybook toolbar
1 parent 853885e commit 0a0d979

File tree

4 files changed

+31
-16
lines changed

4 files changed

+31
-16
lines changed

.storybook/preview.tsx

Lines changed: 29 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,37 @@
11
import type { Preview } from "@storybook/react-vite";
2+
import { useEffect } from "react";
23
import "../src/browser/styles/globals.css";
34

45
const preview: Preview = {
6+
globalTypes: {
7+
theme: {
8+
description: "Global theme for components",
9+
defaultValue: "dark",
10+
toolbar: {
11+
title: "Theme",
12+
icon: "circlehollow",
13+
items: [
14+
{ value: "light", title: "Light", icon: "sun" },
15+
{ value: "dark", title: "Dark", icon: "moon" },
16+
],
17+
dynamicTitle: true,
18+
},
19+
},
20+
},
521
decorators: [
6-
(Story) => (
7-
<>
8-
<Story />
9-
</>
10-
),
22+
(Story, context) => {
23+
const theme = context.globals.theme || "dark";
24+
25+
useEffect(() => {
26+
document.documentElement.dataset.theme = theme;
27+
}, [theme]);
28+
29+
return (
30+
<>
31+
<Story />
32+
</>
33+
);
34+
},
1135
],
1236
parameters: {
1337
controls: {

src/browser/App.tsx

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -390,7 +390,7 @@ function AppInner() {
390390
setSidebarCollapsed((prev) => !prev);
391391
}, [setSidebarCollapsed]);
392392

393-
const toggleTheme = useCallback(() => {
393+
const toggleThemeFromPalette = useCallback(() => {
394394
setTheme((prev) => (prev === "dark" ? "light" : "dark"));
395395
}, [setTheme]);
396396

@@ -415,7 +415,7 @@ function AppInner() {
415415
onAddProject: addProjectFromPalette,
416416
onRemoveProject: removeProjectFromPalette,
417417
onToggleSidebar: toggleSidebarFromPalette,
418-
onToggleTheme: toggleTheme,
418+
onToggleTheme: toggleThemeFromPalette,
419419
onNavigateWorkspace: navigateWorkspaceFromPalette,
420420
onOpenWorkspaceInTerminal: openWorkspaceInTerminal,
421421
};
@@ -463,9 +463,6 @@ function AppInner() {
463463
} else if (matchesKeybind(e, KEYBINDS.TOGGLE_SIDEBAR)) {
464464
e.preventDefault();
465465
setSidebarCollapsed((prev) => !prev);
466-
} else if (matchesKeybind(e, KEYBINDS.TOGGLE_THEME)) {
467-
e.preventDefault();
468-
toggleTheme();
469466
}
470467
};
471468

@@ -474,7 +471,6 @@ function AppInner() {
474471
}, [
475472
handleNavigateWorkspace,
476473
setSidebarCollapsed,
477-
toggleTheme,
478474
isCommandPaletteOpen,
479475
closeCommandPalette,
480476
openCommandPalette,

src/browser/utils/commands/sources.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -308,7 +308,6 @@ export function buildCoreSources(p: BuildSourcesParams): Array<() => CommandActi
308308
id: CommandIds.navToggleTheme(),
309309
title: "Toggle Theme",
310310
section: section.navigation,
311-
shortcutHint: formatKeybind(KEYBINDS.TOGGLE_THEME),
312311
run: () => p.onToggleTheme(),
313312
},
314313
]);

src/browser/utils/ui/keybinds.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -249,10 +249,6 @@ export const KEYBINDS = {
249249
// macOS: Cmd+Shift+T, Win/Linux: Ctrl+Shift+T
250250
TOGGLE_THINKING: { key: "T", ctrl: true, shift: true },
251251

252-
/** Toggle theme between light and dark */
253-
// macOS: Cmd+Option+T, Win/Linux: Ctrl+Alt+T
254-
TOGGLE_THEME: { key: "T", ctrl: true, alt: true },
255-
256252
/** Focus chat input from anywhere */
257253
// Works even when focus is already in an input field
258254
// macOS: Cmd+I, Win/Linux: Ctrl+I

0 commit comments

Comments
 (0)