mirror of
https://github.com/ClipFusion-org/clipfusion.git
synced 2025-08-03 16:55:08 +00:00
ui: fixed ThemeProvider
component
This commit is contained in:
parent
acda651d82
commit
7078330605
@ -4,9 +4,9 @@ import { ComponentProps, ReactNode } from "react";
|
|||||||
|
|
||||||
const ThemeProvider = (props: ComponentProps<typeof NextThemeProvider>): ReactNode => {
|
const ThemeProvider = (props: ComponentProps<typeof NextThemeProvider>): ReactNode => {
|
||||||
return (
|
return (
|
||||||
<ThemeProvider {...props} attribute="class" defaultTheme="system" enableSystem disableTransitionOnChange>
|
<NextThemeProvider {...props} attribute="class" defaultTheme="system" enableSystem disableTransitionOnChange>
|
||||||
{props.children}
|
{props.children}
|
||||||
</ThemeProvider>
|
</NextThemeProvider>
|
||||||
)
|
)
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
"use client";
|
||||||
import { useTheme } from "next-themes";
|
import { useTheme } from "next-themes";
|
||||||
import { ReactNode, useCallback, useEffect, useState } from "react";
|
import { ReactNode, useCallback, useEffect, useState } from "react";
|
||||||
import { Toggle } from "../ui/toggle";
|
import { Toggle } from "../ui/toggle";
|
||||||
@ -15,11 +16,11 @@ export const ThemeSwitcher = ({
|
|||||||
const onThemeChange = useCallback(() => {
|
const onThemeChange = useCallback(() => {
|
||||||
setTheme(theme == "dark" ? "light" : "dark");
|
setTheme(theme == "dark" ? "light" : "dark");
|
||||||
setDark(!dark);
|
setDark(!dark);
|
||||||
}, [theme, dark, setTheme]);
|
}, [theme, dark]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
setDark(theme == "dark");
|
setDark(theme == "dark");
|
||||||
});
|
}, []);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Toggle pressed={dark} onPressedChange={onThemeChange}>
|
<Toggle pressed={dark} onPressedChange={onThemeChange}>
|
||||||
|
Loading…
Reference in New Issue
Block a user