Skip to content

Commit

Permalink
update mode toggle to change on click (no dropdown)
Browse files Browse the repository at this point in the history
  • Loading branch information
ligsnf committed Dec 5, 2024
1 parent 76e24e1 commit a190dc3
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 39 deletions.
37 changes: 0 additions & 37 deletions src/components/mode-toggle.tsx

This file was deleted.

2 changes: 1 addition & 1 deletion src/components/site-header.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Link } from '@tanstack/react-router'
import { ModeToggle } from "@/components/mode-toggle"
import { ModeToggle } from "@/components/theme/mode-toggle"
import { Icons } from "@/components/icons"
import { Button } from "@/components/ui/button"
import { GraduationCap, Menu } from "lucide-react"
Expand Down
19 changes: 19 additions & 0 deletions src/components/theme/mode-toggle.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { Moon, Sun } from "lucide-react"
import { Button } from "@/components/ui/button"
import { useTheme } from "@/components/theme/theme-provider"

export function ModeToggle() {
const { theme, setTheme } = useTheme()

const toggleTheme = () => {
setTheme(theme === "dark" ? "light" : "dark")
}

return (
<Button variant="outline" size="icon" onClick={toggleTheme}>
<Sun className="h-[1.2rem] w-[1.2rem] rotate-0 scale-100 transition-all dark:-rotate-90 dark:scale-0" />
<Moon className="absolute h-[1.2rem] w-[1.2rem] rotate-90 scale-0 transition-all dark:rotate-0 dark:scale-100" />
<span className="sr-only">Toggle theme</span>
</Button>
)
}
File renamed without changes.
2 changes: 1 addition & 1 deletion src/main.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { StrictMode } from 'react'
import ReactDOM from 'react-dom/client'
import './index.css'
import { RouterProvider, createRouter } from '@tanstack/react-router'
import { ThemeProvider } from "@/components/theme-provider"
import { ThemeProvider } from "@/components/theme/theme-provider"

// Import the generated route tree
import { routeTree } from './routeTree.gen'
Expand Down

0 comments on commit a190dc3

Please sign in to comment.