mirror of
https://github.com/Athou/commafeed.git
synced 2026-03-21 21:37:29 +00:00
use preferred color scheme as initial value
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
import { i18n } from "@lingui/core"
|
import { i18n } from "@lingui/core"
|
||||||
import { I18nProvider } from "@lingui/react"
|
import { I18nProvider } from "@lingui/react"
|
||||||
import { ColorScheme, ColorSchemeProvider, MantineProvider } from "@mantine/core"
|
import { ColorScheme, ColorSchemeProvider, MantineProvider } from "@mantine/core"
|
||||||
import { useLocalStorage } from "@mantine/hooks"
|
import { useColorScheme, useLocalStorage } from "@mantine/hooks"
|
||||||
import { ModalsProvider } from "@mantine/modals"
|
import { ModalsProvider } from "@mantine/modals"
|
||||||
import { NotificationsProvider } from "@mantine/notifications"
|
import { NotificationsProvider } from "@mantine/notifications"
|
||||||
import { Constants } from "app/constants"
|
import { Constants } from "app/constants"
|
||||||
@@ -30,9 +30,10 @@ import { HashRouter, Navigate, Route, Routes, useNavigate } from "react-router-d
|
|||||||
import Tinycon from "tinycon"
|
import Tinycon from "tinycon"
|
||||||
|
|
||||||
function Providers(props: { children: React.ReactNode }) {
|
function Providers(props: { children: React.ReactNode }) {
|
||||||
|
const preferredColorScheme = useColorScheme()
|
||||||
const [colorScheme, setColorScheme] = useLocalStorage<ColorScheme>({
|
const [colorScheme, setColorScheme] = useLocalStorage<ColorScheme>({
|
||||||
key: "color-scheme",
|
key: "color-scheme",
|
||||||
defaultValue: "light",
|
defaultValue: preferredColorScheme,
|
||||||
getInitialValueInEffect: true,
|
getInitialValueInEffect: true,
|
||||||
})
|
})
|
||||||
const toggleColorScheme = (value?: ColorScheme) => setColorScheme(value || (colorScheme === "dark" ? "light" : "dark"))
|
const toggleColorScheme = (value?: ColorScheme) => setColorScheme(value || (colorScheme === "dark" ? "light" : "dark"))
|
||||||
|
|||||||
Reference in New Issue
Block a user