Skip to content

Commit 19f9a31

Browse files
saidMounaimclaude
andcommitted
feat: add quick theme toggle in sidebar header
Add a theme toggle icon button near the T3 Code logo for quick access to theme switching. The toggle shows a sun/moon icon based on the current resolved theme and opens a dropdown with System, Light, and Dark options. - Uses existing useTheme hook for state management - Syncs automatically with Settings page theme selector - Works on both web and desktop (Electron) builds Co-Authored-By: Claude Opus 4.5 <[email protected]>
1 parent 82a50da commit 19f9a31

1 file changed

Lines changed: 35 additions & 1 deletion

File tree

‎apps/web/src/components/Sidebar.tsx‎

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,12 @@ import {
33
ChevronRightIcon,
44
FolderIcon,
55
GitPullRequestIcon,
6+
MoonIcon,
67
PlusIcon,
78
RocketIcon,
89
SettingsIcon,
910
SquarePenIcon,
11+
SunIcon,
1012
TerminalIcon,
1113
TriangleAlertIcon,
1214
} from "lucide-react";
@@ -64,6 +66,7 @@ import {
6466
import { Alert, AlertAction, AlertDescription, AlertTitle } from "./ui/alert";
6567
import { Button } from "./ui/button";
6668
import { Collapsible, CollapsibleContent } from "./ui/collapsible";
69+
import { Menu, MenuTrigger, MenuPopup, MenuRadioGroup, MenuRadioItem } from "./ui/menu";
6770
import { Tooltip, TooltipPopup, TooltipTrigger } from "./ui/tooltip";
6871
import {
6972
SidebarContent,
@@ -81,6 +84,7 @@ import {
8184
SidebarTrigger,
8285
} from "./ui/sidebar";
8386
import { useThreadSelectionStore } from "../threadSelectionStore";
87+
import { useTheme } from "../hooks/useTheme";
8488
import { formatWorktreePathForDisplay, getOrphanedWorktreePathForThread } from "../worktreeCleanup";
8589
import { isNonEmpty as isNonEmptyString } from "effect/String";
8690
import { resolveThreadStatusPill, shouldClearThreadSelectionOnMouseDown } from "./Sidebar.logic";
@@ -276,6 +280,7 @@ export default function Sidebar() {
276280
const navigate = useNavigate();
277281
const isOnSettings = useLocation({ select: (loc) => loc.pathname === "/settings" });
278282
const { settings: appSettings } = useAppSettings();
283+
const { theme, setTheme, resolvedTheme } = useTheme();
279284
const routeThreadId = useParams({
280285
strict: false,
281286
select: (params) => (params.threadId ? ThreadId.makeUnsafe(params.threadId) : null),
@@ -1259,12 +1264,38 @@ export default function Sidebar() {
12591264
</div>
12601265
);
12611266

1267+
const ThemeIcon = resolvedTheme === "dark" ? MoonIcon : SunIcon;
1268+
1269+
const themeDropdown = (
1270+
<Menu>
1271+
<MenuTrigger
1272+
render={
1273+
<button
1274+
type="button"
1275+
aria-label="Toggle theme"
1276+
className="ml-auto inline-flex size-7 items-center justify-center rounded-md text-muted-foreground/70 transition-colors hover:bg-accent hover:text-foreground"
1277+
/>
1278+
}
1279+
>
1280+
<ThemeIcon className="size-4" />
1281+
</MenuTrigger>
1282+
<MenuPopup align="end" side="bottom" className="min-w-[120px]">
1283+
<MenuRadioGroup value={theme} onValueChange={setTheme}>
1284+
<MenuRadioItem value="system">System</MenuRadioItem>
1285+
<MenuRadioItem value="light">Light</MenuRadioItem>
1286+
<MenuRadioItem value="dark">Dark</MenuRadioItem>
1287+
</MenuRadioGroup>
1288+
</MenuPopup>
1289+
</Menu>
1290+
);
1291+
12621292
return (
12631293
<>
12641294
{isElectron ? (
12651295
<>
12661296
<SidebarHeader className="drag-region h-[52px] flex-row items-center gap-2 px-4 py-0 pl-[90px]">
12671297
{wordmark}
1298+
{themeDropdown}
12681299
{showDesktopUpdateButton && (
12691300
<Tooltip>
12701301
<TooltipTrigger
@@ -1288,7 +1319,10 @@ export default function Sidebar() {
12881319
</>
12891320
) : (
12901321
<SidebarHeader className="gap-3 px-3 py-2 sm:gap-2.5 sm:px-4 sm:py-3">
1291-
{wordmark}
1322+
<div className="flex items-center gap-2 w-full">
1323+
{wordmark}
1324+
{themeDropdown}
1325+
</div>
12921326
</SidebarHeader>
12931327
)}
12941328

0 commit comments

Comments
 (0)