Skip to content

Commit 6210e9c

Browse files
feat(settings): move theme toggle and logout into settings dialog
- add Appearance section to SettingsModal with light/dark toggle - add Sign out button in dialog footer (left-aligned, destructive style) - remove standalone theme toggle and logout from sidebar footer
1 parent 1c8bfb3 commit 6210e9c

2 files changed

Lines changed: 41 additions & 15 deletions

File tree

apps/tracker/app/components/home/SettingsModal.tsx

Lines changed: 41 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { useState, useEffect } from "react";
2-
import { useFetcher } from "react-router";
2+
import { useFetcher, Form } from "react-router";
33
import { Button } from "../ui/button";
44
import {
55
Dialog,
@@ -13,7 +13,8 @@ import {
1313
import { Input } from "../ui/input";
1414
import { Label } from "../ui/label";
1515
import { RuleList } from "./RuleList";
16-
import { Settings, Loader2, CheckCircle2, XCircle } from "lucide-react";
16+
import { Settings, Loader2, CheckCircle2, XCircle, Sun, Moon, LogOut } from "lucide-react";
17+
import { useTheme } from "../../hooks/useTheme";
1718
import type { AutoStopRuleData } from "./types";
1819

1920
type SettingsModalProps = {
@@ -26,6 +27,7 @@ type SettingsModalProps = {
2627
export function SettingsModal({ rules: initialRules, userTimezone, apiKey, googleConnected }: SettingsModalProps) {
2728
const [open, setOpen] = useState(false);
2829
const fetcher = useFetcher();
30+
const { theme, toggle: toggleTheme } = useTheme();
2931
const [localRules, setLocalRules] = useState<AutoStopRuleData[]>(initialRules);
3032
const isSaving = fetcher.state !== "idle";
3133

@@ -126,6 +128,31 @@ export function SettingsModal({ rules: initialRules, userTimezone, apiKey, googl
126128
</div>
127129
</div>
128130

131+
<div className="border-t pt-4">
132+
<h4 className="text-sm font-medium mb-3">Appearance</h4>
133+
<div className="flex items-center justify-between">
134+
<div>
135+
<p className="text-sm">Theme</p>
136+
<p className="text-xs text-muted-foreground mt-0.5">
137+
{theme === "dark" ? "Dark mode" : "Light mode"}
138+
</p>
139+
</div>
140+
<Button
141+
type="button"
142+
variant="outline"
143+
size="sm"
144+
onClick={toggleTheme}
145+
className="gap-2"
146+
>
147+
{theme === "dark" ? (
148+
<><Sun className="size-3.5" /> Light</>
149+
) : (
150+
<><Moon className="size-3.5" /> Dark</>
151+
)}
152+
</Button>
153+
</div>
154+
</div>
155+
129156
<div className="border-t pt-4">
130157
<h4 className="text-sm font-medium mb-3">Google Integration</h4>
131158
<div className="space-y-3">
@@ -174,7 +201,18 @@ export function SettingsModal({ rules: initialRules, userTimezone, apiKey, googl
174201
</div>
175202
</div>
176203
</div>
177-
<DialogFooter>
204+
<DialogFooter className="flex-row items-center">
205+
<Form method="post" action="/auth/logout" className="mr-auto">
206+
<Button
207+
type="submit"
208+
variant="ghost"
209+
size="sm"
210+
className="gap-2 text-muted-foreground hover:text-destructive"
211+
>
212+
<LogOut className="size-3.5" />
213+
Sign out
214+
</Button>
215+
</Form>
178216
<Button type="button" variant="outline" onClick={() => setOpen(false)} disabled={isSaving}>
179217
Cancel
180218
</Button>

apps/tracker/app/routes/home.tsx

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,6 @@ import {
5555
ChevronRight,
5656
CheckCircle2,
5757
ArrowRight,
58-
LogOut,
5958
History,
6059
} from "lucide-react";
6160

@@ -464,17 +463,6 @@ export default function Home({ loaderData }: Route.ComponentProps) {
464463
apiKey={user.apiKey}
465464
googleConnected={googleConnected}
466465
/>
467-
<Form method="post" action="/auth/logout">
468-
<Button
469-
type="submit"
470-
variant="ghost"
471-
size="icon"
472-
className="size-8 text-muted-foreground hover:text-destructive"
473-
title="Logout"
474-
>
475-
<LogOut className="size-4" />
476-
</Button>
477-
</Form>
478466
</div>
479467
</SidebarMenuButton>
480468
</SidebarMenuItem>

0 commit comments

Comments
 (0)