Skip to content

Commit

Permalink
added ThemeProvider to prevent user's default color scheme setting by…
Browse files Browse the repository at this point in the history
… their device
  • Loading branch information
AmirKakavand committed Aug 2, 2024
1 parent 805ac9d commit ad475a7
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 27 deletions.
18 changes: 0 additions & 18 deletions app/globals.css
Original file line number Diff line number Diff line change
Expand Up @@ -9,24 +9,6 @@
font-style: normal;
}

:root {
--background-color: #231F20;
--text-color: #F9F4DA; /* Light mode text */
}

@media (prefers-color-scheme: light) {
:root {
--background-color: #231F20; /* Dark mode background */
--text-color: #F9F4DA; /* Dark mode text */
}
}
@media (prefers-color-scheme: dark) {
:root {
--background-color: #231F20; /* Dark mode background */
--text-color: #F9F4DA; /* Dark mode text */
}
}

body {
/* color: rgb(var(--foreground-rgb)); */
background-color: #231F20;
Expand Down
29 changes: 20 additions & 9 deletions app/layout.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import type { Metadata } from "next";
import Head from "next/head"
import Head from "next/head";
import "./globals.css";

import { ThemeProvider } from "next-themes";

export const metadata: Metadata = {
title: "Rick & Morty Wiki",
description: "Explore all the different characters of the popular Rick and Morty Show",
description:
"Explore all the different characters of the popular Rick and Morty Show",
};

export default function RootLayout({
Expand All @@ -14,12 +15,22 @@ export default function RootLayout({
children: React.ReactNode;
}>) {
return (
<html lang="en">
<Head>
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link rel="icon" href="/favicon.ico" sizes="any" />
<ThemeProvider enableColorScheme={false} attribute="class">
<html lang="en">
<Head>
<meta
name="viewport"
content="width=device-width, initial-scale=1.0"
/>
<link rel="icon" href="/favicon.ico" sizes="any" />
</Head>
<body style={{fontFamily: "Wellfleet, sans-serif"}} className="max-w-screen">{children}</body>
</html>
<body
style={{ fontFamily: "Wellfleet, sans-serif" }}
className="max-w-screen"
>
{children}
</body>
</html>
</ThemeProvider>
);
}
11 changes: 11 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"@heroicons/react": "^2.1.5",
"@tailwindcss/forms": "^0.5.7",
"next": "14.2.5",
"next-themes": "^0.3.0",
"react": "^18",
"react-dom": "^18",
"swr": "^2.2.5"
Expand Down

0 comments on commit ad475a7

Please sign in to comment.