mirror of
https://github.com/Lumither/nocturne.git
synced 2026-10-17 18:36:21 +00:00
feat(theme) add ThemeSwitcher.tsx
This commit is contained in:
1 parent
0f415e7bf7
commit
83365be90b
7 files changed
+95
-25
No files matched your search
@@ -0,0 +1,3 @@
|
|||||||
|
@tailwind base;
|
||||||
|
@tailwind components;
|
||||||
|
@tailwind utilities;
|
||||||
+15
-9
@@ -1,22 +1,28 @@
|
|||||||
import type { Metadata } from "next";
|
import type { Metadata } from 'next';
|
||||||
import { Inter } from "next/font/google";
|
import { Inter } from 'next/font/google';
|
||||||
import "./globals.css";
|
import './globals.css';
|
||||||
|
import React from 'react';
|
||||||
|
import { ThemeProvider as NextThemesProvider } from 'next-themes';
|
||||||
|
|
||||||
const inter = Inter({ subsets: ["latin"] });
|
const inter = Inter({ subsets: [ 'latin' ] });
|
||||||
|
|
||||||
export const metadata: Metadata = {
|
export const metadata: Metadata = {
|
||||||
title: "Lumither's site",
|
title: 'Lumither\'s site',
|
||||||
description: "a small corner on internet",
|
description: 'a small corner on internet'
|
||||||
};
|
};
|
||||||
|
|
||||||
export default function RootLayout({
|
export default function RootLayout({
|
||||||
children,
|
children
|
||||||
}: Readonly<{
|
}: Readonly<{
|
||||||
children: React.ReactNode;
|
children: React.ReactNode;
|
||||||
}>) {
|
}>) {
|
||||||
return (
|
return (
|
||||||
<html lang="en">
|
<html lang="en" suppressHydrationWarning>
|
||||||
<body className={inter.className}>{children}</body>
|
<body className={ inter.className }>
|
||||||
|
<NextThemesProvider attribute="class" defaultTheme="dark">
|
||||||
|
{ children }
|
||||||
|
</NextThemesProvider>
|
||||||
|
</body>
|
||||||
</html>
|
</html>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
+3
-1
@@ -1,7 +1,9 @@
|
|||||||
|
import ThemeSwitcher from '@/components/ThemeSwitcher';
|
||||||
|
|
||||||
export default function Home() {
|
export default function Home() {
|
||||||
return (
|
return (
|
||||||
<main>
|
<main>
|
||||||
|
<ThemeSwitcher />
|
||||||
</main>
|
</main>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
'use client';
|
||||||
|
|
||||||
|
import { NextUIProvider } from '@nextui-org/react';
|
||||||
|
import React from 'react';
|
||||||
|
|
||||||
|
export function Providers({ children }: { children: React.ReactNode }) {
|
||||||
|
return (
|
||||||
|
<NextUIProvider>
|
||||||
|
{ children }
|
||||||
|
</NextUIProvider>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -0,0 +1,31 @@
|
|||||||
|
'use client';
|
||||||
|
|
||||||
|
import React, { useEffect, useState } from 'react';
|
||||||
|
import { useTheme } from 'next-themes';
|
||||||
|
import { Button } from '@nextui-org/react';
|
||||||
|
|
||||||
|
function ThemeSwitcher() {
|
||||||
|
const [ mounted, setMounted ] = useState(false);
|
||||||
|
const { theme, setTheme, themes } = useTheme();
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
setMounted(true);
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
if (!mounted) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div>
|
||||||
|
<Button onClick={ () => {
|
||||||
|
setTheme('light');
|
||||||
|
} }>Light Mode</Button>
|
||||||
|
<Button onClick={ () => {
|
||||||
|
setTheme('dark');
|
||||||
|
} }>Dark Mode</Button>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
export default ThemeSwitcher;
|
||||||
+5
-2
@@ -9,9 +9,12 @@
|
|||||||
"lint": "next lint"
|
"lint": "next lint"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
"@nextui-org/react": "^2.3.5",
|
||||||
|
"framer-motion": "^11.1.7",
|
||||||
|
"next": "14.2.2",
|
||||||
|
"next-themes": "^0.3.0",
|
||||||
"react": "^18",
|
"react": "^18",
|
||||||
"react-dom": "^18",
|
"react-dom": "^18"
|
||||||
"next": "14.2.2"
|
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"typescript": "^5",
|
"typescript": "^5",
|
||||||
|
|||||||
+26
-13
@@ -1,20 +1,33 @@
|
|||||||
import type { Config } from "tailwindcss";
|
import { nextui } from '@nextui-org/react';
|
||||||
|
|
||||||
|
import type { Config } from 'tailwindcss';
|
||||||
|
|
||||||
const config: Config = {
|
const config: Config = {
|
||||||
content: [
|
content: [
|
||||||
"./pages/**/*.{js,ts,jsx,tsx,mdx}",
|
'./pages/**/*.{js,ts,jsx,tsx,mdx}',
|
||||||
"./components/**/*.{js,ts,jsx,tsx,mdx}",
|
'./components/**/*.{js,ts,jsx,tsx,mdx}',
|
||||||
"./app/**/*.{js,ts,jsx,tsx,mdx}",
|
'./app/**/*.{js,ts,jsx,tsx,mdx}',
|
||||||
|
'./node_modules/@nextui-org/theme/dist/**/*.{js,ts,jsx,tsx}'
|
||||||
],
|
],
|
||||||
theme: {
|
// theme: {
|
||||||
extend: {
|
// extend: {}
|
||||||
backgroundImage: {
|
// },
|
||||||
"gradient-radial": "radial-gradient(var(--tw-gradient-stops))",
|
darkMode: 'class',
|
||||||
"gradient-conic":
|
plugins: [ nextui(
|
||||||
"conic-gradient(from 180deg at 50% 50%, var(--tw-gradient-stops))",
|
{
|
||||||
|
// defaultTheme: 'dark',
|
||||||
|
defaultExtendTheme: 'light',
|
||||||
|
themes: {
|
||||||
|
'light': {
|
||||||
|
layout: {},
|
||||||
|
colors: {}
|
||||||
},
|
},
|
||||||
},
|
'dark': {
|
||||||
},
|
layout: {},
|
||||||
plugins: [],
|
colors: {}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
) ]
|
||||||
};
|
};
|
||||||
export default config;
|
export default config;
|
||||||
Reference in new issue
Block a user