Skip to content

Commit 5d84b0a

Browse files
committed
feat: enhance ModeToggle component with system theme option and improve button styling
1 parent c8899ce commit 5d84b0a

File tree

3 files changed

+34
-11
lines changed

3 files changed

+34
-11
lines changed

src/components/ModeToggle.tsx

Lines changed: 32 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,45 @@
1-
import { Moon, Sun } from 'lucide-react';
1+
import { cn } from '@/lib/utils';
2+
import { Monitor, Moon, Sun } from 'lucide-react';
23
import { useTheme } from '@/components/themeProvider';
34
import { Button } from '@/components/ui/button';
45

56
export function ModeToggle() {
6-
const { setTheme } = useTheme();
7+
const { theme, setTheme } = useTheme();
78

89
return (
9-
<div>
10-
<Button onClick={() => setTheme('light')}>
10+
<div className="rounded-full border p-1">
11+
<Button
12+
variant={'link'}
13+
size={'none'}
14+
className={cn(
15+
'text-foreground hover:bg-muted border p-1',
16+
theme === 'dark' ? 'border' : 'border-transparent'
17+
)}
18+
onClick={() => setTheme('dark')}
19+
>
1120
<Moon />
12-
Light
1321
</Button>
14-
<Button onClick={() => setTheme('dark')}>
22+
<Button
23+
variant={'link'}
24+
size={'none'}
25+
className={cn(
26+
'text-foreground hover:bg-muted border p-1',
27+
theme === 'light' ? 'border' : 'border-transparent'
28+
)}
29+
onClick={() => setTheme('light')}
30+
>
1531
<Sun />
16-
Dark
1732
</Button>
18-
<Button onClick={() => setTheme('system')}>
19-
<Sun />
20-
System
33+
<Button
34+
variant={'link'}
35+
size={'none'}
36+
className={cn(
37+
'text-foreground hover:bg-muted border p-1',
38+
theme === 'system' ? 'border' : 'border-transparent'
39+
)}
40+
onClick={() => setTheme('system')}
41+
>
42+
<Monitor />
2143
</Button>
2244
</div>
2345
);

src/components/navbar/NavBar.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ export function Navbar() {
3232
<span className="border-secondary border-l" />
3333
</div>
3434
)}
35-
<div className="content hidden md:flex">
35+
<div className="content hidden gap-4 md:flex">
3636
<ModeToggle />
3737
<ChainSelector />
3838
</div>

src/components/ui/button.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ const buttonVariants = cva(
2929
default: 'h-9 px-4 py-2 has-[>svg]:px-3 rounded-full',
3030
lg: 'h-11 rounded-full px-6 has-[>svg]:px-4 text-md',
3131
icon: 'size-9 rounded-md',
32+
none: 'p-0 rounded-full',
3233
},
3334
},
3435
defaultVariants: {

0 commit comments

Comments
 (0)