fix: mantine dark mode
This commit is contained in:
+5
-2
@@ -22,7 +22,7 @@ import {
|
||||
import { getColorScheme } from "~/lib/get-color-scheme"
|
||||
|
||||
import { ColorSchemeInjector } from "./ColorSchemeInjector"
|
||||
import Providers, { mantineTheme } from "./providers"
|
||||
import Providers, { mantineDefaultColorScheme, mantineTheme } from "./providers"
|
||||
|
||||
export const metadata: Metadata = {
|
||||
title: `${APP_NAME} - ${APP_SLOGAN}`,
|
||||
@@ -118,7 +118,10 @@ export default function RootLayout({
|
||||
<ColorSchemeScript />
|
||||
</head>
|
||||
<body>
|
||||
<MantineProvider theme={mantineTheme}>
|
||||
<MantineProvider
|
||||
theme={mantineTheme}
|
||||
defaultColorScheme={mantineDefaultColorScheme}
|
||||
>
|
||||
<Providers lang={lang}>
|
||||
{modal}
|
||||
{children}
|
||||
|
||||
@@ -41,6 +41,17 @@ export const mantineTheme = createTheme({
|
||||
fontFamily: "var(--font-fans)",
|
||||
})
|
||||
|
||||
let mantineDefaultColorSchemeT = "auto"
|
||||
if (localStorage.getItem(DARK_MODE_STORAGE_KEY) === "light") {
|
||||
mantineDefaultColorSchemeT = "light"
|
||||
} else if (localStorage.getItem(DARK_MODE_STORAGE_KEY) === "dark") {
|
||||
mantineDefaultColorSchemeT = "dark"
|
||||
}
|
||||
export const mantineDefaultColorScheme = mantineDefaultColorSchemeT as
|
||||
| "auto"
|
||||
| "light"
|
||||
| "dark"
|
||||
|
||||
const createQueryClient = () => new QueryClient()
|
||||
export default function Providers({
|
||||
children,
|
||||
|
||||
@@ -3,6 +3,8 @@
|
||||
import { useTheme } from "next-themes"
|
||||
import { MouseEvent } from "react"
|
||||
|
||||
import { useMantineColorScheme } from "@mantine/core"
|
||||
|
||||
import { useIsClient } from "~/hooks/useClient"
|
||||
import { cn } from "~/lib/utils"
|
||||
|
||||
@@ -33,11 +35,13 @@ const ThemeIndicator = () => {
|
||||
|
||||
const ThemeSwitcher = () => {
|
||||
const { setTheme } = useTheme()
|
||||
const { setColorScheme } = useMantineColorScheme()
|
||||
|
||||
const buildThemeTransition = (
|
||||
e: MouseEvent,
|
||||
theme: "light" | "dark" | "system",
|
||||
) => {
|
||||
setColorScheme(theme === "system" ? "auto" : theme)
|
||||
return setTheme(theme)
|
||||
// disable in https://github.com/Crossbell-Box/xLog/commit/06713c901e90b57de6f5f5a0252d2c9dd874335f
|
||||
if (
|
||||
|
||||
@@ -4,8 +4,8 @@
|
||||
|
||||
@layer base {
|
||||
body {
|
||||
@apply text-zinc-800;
|
||||
@apply fill-zinc-800;
|
||||
@apply !text-zinc-800;
|
||||
@apply !fill-zinc-800;
|
||||
font-family: var(--font-fans);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user