Fixed an issue where the screen flickers when reloading the page.
- Add theme detection based on cookies across layouts
This commit is contained in:
@@ -5,20 +5,25 @@ import Nav from "@/components/Navbar/Nav";
|
|||||||
import Footer from "@/components/Home/Footer/Footer";
|
import Footer from "@/components/Home/Footer/Footer";
|
||||||
import {ThemeProvider} from "@/components/provider/ThemeProvider";
|
import {ThemeProvider} from "@/components/provider/ThemeProvider";
|
||||||
import React from "react";
|
import React from "react";
|
||||||
|
import {cookies} from "next/headers";
|
||||||
|
|
||||||
export const metadata: Metadata = {
|
export const metadata: Metadata = {
|
||||||
title: "Rhein Software",
|
title: "Rhein Software",
|
||||||
description: "Rhein Software Development",
|
description: "Rhein Software Development",
|
||||||
};
|
};
|
||||||
|
|
||||||
export default function RootLayout({
|
export default async function RootLayout({
|
||||||
children,
|
children,
|
||||||
}: Readonly<{
|
}: Readonly<{
|
||||||
children: React.ReactNode;
|
children: React.ReactNode;
|
||||||
}>) {
|
}>) {
|
||||||
|
const cookieStore = await cookies();
|
||||||
|
const theme = cookieStore.get("theme")?.value === "dark" ? "dark" : "light";
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<html lang="de">
|
<html lang="de" data-theme={theme}>
|
||||||
<body className={'${font.className} antialiased'} style={{backgroundColor: "var(--primary-bg)"}}>
|
<head/>
|
||||||
|
<body className="antialiased" style={{backgroundColor: "var(--primary-bg)"}}>
|
||||||
<ThemeProvider>
|
<ThemeProvider>
|
||||||
<Nav/>
|
<Nav/>
|
||||||
{children}
|
{children}
|
||||||
|
|||||||
@@ -1,24 +1,29 @@
|
|||||||
import type {Metadata} from "next";
|
import type {Metadata} from "next";
|
||||||
import '../(root)/globals.css';
|
import "../(root)/globals.css";
|
||||||
|
|
||||||
import Nav from "@/components/Navbar/Nav";
|
import Nav from "@/components/Navbar/Nav";
|
||||||
import Footer from "@/components/Home/Footer/Footer";
|
import Footer from "@/components/Home/Footer/Footer";
|
||||||
import {ThemeProvider} from "@/components/provider/ThemeProvider";
|
import {ThemeProvider} from "@/components/provider/ThemeProvider";
|
||||||
import React from "react";
|
import React from "react";
|
||||||
|
import {cookies} from "next/headers";
|
||||||
|
|
||||||
export const metadata: Metadata = {
|
export const metadata: Metadata = {
|
||||||
title: "Rhein Software",
|
title: "Rhein Software",
|
||||||
description: "Rhein Software Development",
|
description: "Rhein Software Development",
|
||||||
};
|
};
|
||||||
|
|
||||||
export default function RootLayout({
|
export default async function RootLayout({
|
||||||
children,
|
children,
|
||||||
}: Readonly<{
|
}: Readonly<{
|
||||||
children: React.ReactNode;
|
children: React.ReactNode;
|
||||||
}>) {
|
}>) {
|
||||||
|
const cookieStore = await cookies();
|
||||||
|
const theme = cookieStore.get("theme")?.value === "dark" ? "dark" : "light";
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<html lang="de">
|
<html lang="de" data-theme={theme}>
|
||||||
<body className={'${font.className} antialiased'} style={{backgroundColor: "var(--primary-bg)"}}>
|
<head/>
|
||||||
|
<body className="antialiased" style={{backgroundColor: "var(--primary-bg)"}}>
|
||||||
<ThemeProvider>
|
<ThemeProvider>
|
||||||
<Nav/>
|
<Nav/>
|
||||||
{children}
|
{children}
|
||||||
|
|||||||
@@ -1,24 +1,29 @@
|
|||||||
import type {Metadata} from "next";
|
import type {Metadata} from "next";
|
||||||
import '../(root)/globals.css';
|
import "../(root)/globals.css";
|
||||||
|
|
||||||
import Nav from "@/components/Navbar/Nav";
|
import Nav from "@/components/Navbar/Nav";
|
||||||
import Footer from "@/components/Home/Footer/Footer";
|
import Footer from "@/components/Home/Footer/Footer";
|
||||||
import {ThemeProvider} from "@/components/provider/ThemeProvider";
|
import {ThemeProvider} from "@/components/provider/ThemeProvider";
|
||||||
import React from "react";
|
import React from "react";
|
||||||
|
import {cookies} from "next/headers";
|
||||||
|
|
||||||
export const metadata: Metadata = {
|
export const metadata: Metadata = {
|
||||||
title: "Rhein Software",
|
title: "Rhein Software",
|
||||||
description: "Rhein Software Development",
|
description: "Rhein Software Development",
|
||||||
};
|
};
|
||||||
|
|
||||||
export default function RootLayout({
|
export default async function RootLayout({
|
||||||
children,
|
children,
|
||||||
}: Readonly<{
|
}: Readonly<{
|
||||||
children: React.ReactNode;
|
children: React.ReactNode;
|
||||||
}>) {
|
}>) {
|
||||||
|
const cookieStore = await cookies();
|
||||||
|
const theme = cookieStore.get("theme")?.value === "dark" ? "dark" : "light";
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<html lang="de">
|
<html lang="de" data-theme={theme}>
|
||||||
<body className={'${font.className} antialiased'} style={{backgroundColor: "var(--primary-bg)"}}>
|
<head/>
|
||||||
|
<body className="antialiased" style={{backgroundColor: "var(--primary-bg)"}}>
|
||||||
<ThemeProvider>
|
<ThemeProvider>
|
||||||
<Nav/>
|
<Nav/>
|
||||||
{children}
|
{children}
|
||||||
|
|||||||
Reference in New Issue
Block a user