mirror of
https://github.com/rowboatlabs/rowboat.git
synced 2026-06-06 19:35:44 +02:00
Merge pull request #94 from takshakmudgal/ui/theme-persistence
fix(theme): add persistence & update icon
This commit is contained in:
commit
739b7caa46
2 changed files with 18 additions and 5 deletions
|
|
@ -13,6 +13,7 @@ import {
|
||||||
ChevronLeftIcon,
|
ChevronLeftIcon,
|
||||||
ChevronRightIcon,
|
ChevronRightIcon,
|
||||||
Moon,
|
Moon,
|
||||||
|
Sun,
|
||||||
HelpCircle
|
HelpCircle
|
||||||
} from "lucide-react";
|
} from "lucide-react";
|
||||||
import { getProjectConfig } from "@/app/actions/project_actions";
|
import { getProjectConfig } from "@/app/actions/project_actions";
|
||||||
|
|
@ -213,7 +214,7 @@ export default function Sidebar({ projectId, useRag, useAuth, collapsed = false,
|
||||||
text-zinc-600 dark:text-zinc-400
|
text-zinc-600 dark:text-zinc-400
|
||||||
`}
|
`}
|
||||||
>
|
>
|
||||||
<Moon size={COLLAPSED_ICON_SIZE} />
|
{ theme == "light" ? <Moon size={COLLAPSED_ICON_SIZE} /> : <Sun size={COLLAPSED_ICON_SIZE} /> }
|
||||||
{!collapsed && <span>Appearance</span>}
|
{!collapsed && <span>Appearance</span>}
|
||||||
</button>
|
</button>
|
||||||
</Tooltip>
|
</Tooltip>
|
||||||
|
|
|
||||||
|
|
@ -23,13 +23,25 @@ export function ThemeProvider({
|
||||||
const [theme, setTheme] = useState<Theme>(defaultTheme)
|
const [theme, setTheme] = useState<Theme>(defaultTheme)
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const root = window.document.documentElement
|
const root = document.documentElement
|
||||||
|
const storedTheme = localStorage.getItem("theme")
|
||||||
|
|
||||||
|
if (storedTheme === 'dark' || storedTheme === 'light') {
|
||||||
|
setTheme(storedTheme)
|
||||||
|
}
|
||||||
|
|
||||||
root.classList.remove('light', 'dark')
|
root.classList.remove('light', 'dark')
|
||||||
root.classList.add(theme)
|
root.classList.add(theme)
|
||||||
}, [theme])
|
}, [theme])
|
||||||
|
|
||||||
const toggleTheme = () => {
|
const toggleTheme = () => {
|
||||||
setTheme(theme === 'light' ? 'dark' : 'light')
|
setTheme((prevTheme) => {
|
||||||
|
const newTheme = prevTheme === 'light' ? 'dark' : 'light'
|
||||||
|
if (typeof window !== 'undefined') {
|
||||||
|
localStorage.setItem("theme", newTheme)
|
||||||
|
}
|
||||||
|
return newTheme
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue