File tree Expand file tree Collapse file tree 3 files changed +67
-10
lines changed Expand file tree Collapse file tree 3 files changed +67
-10
lines changed Original file line number Diff line number Diff line change 1
- import './globals.css'
2
- import type { Metadata } from 'next'
3
- import { Inter } from 'next/font/google'
1
+ import { ThemeProvider } from "@/context/ThemeProvider" ;
2
+ import "./globals.css" ;
3
+ import type { Metadata } from "next" ;
4
+ import { Inter } from "next/font/google" ;
5
+ import Navbar from "@/components/Navbar" ;
4
6
5
- const inter = Inter ( { subsets : [ ' latin' ] } )
7
+ const inter = Inter ( { subsets : [ " latin" ] } ) ;
6
8
7
9
export const metadata : Metadata = {
8
- title : 'Create Next App' ,
9
- description : 'Generated by create next app' ,
10
- }
10
+ title : "Countries Info" ,
11
+ description :
12
+ "Its a website, containing all information about every nation on the planet." ,
13
+ } ;
11
14
12
15
export default function RootLayout ( {
13
16
children,
14
17
} : {
15
- children : React . ReactNode
18
+ children : React . ReactNode ;
16
19
} ) {
17
20
return (
18
21
< html lang = "en" >
19
- < body className = { inter . className } > { children } </ body >
22
+ < body className = { inter . className } >
23
+ < ThemeProvider attribute = "class" defaultTheme = "system" enableSystem >
24
+ < Navbar />
25
+ { children }
26
+ </ ThemeProvider >
27
+ </ body >
20
28
</ html >
21
- )
29
+ ) ;
22
30
}
Original file line number Diff line number Diff line change
1
+ "use client" ;
2
+
3
+ import * as React from "react" ;
4
+ import { MoonIcon , SunIcon } from "@radix-ui/react-icons" ;
5
+ import { useTheme } from "next-themes" ;
6
+
7
+ import { Button } from "@/components/ui/button" ;
8
+ import {
9
+ DropdownMenu ,
10
+ DropdownMenuContent ,
11
+ DropdownMenuItem ,
12
+ DropdownMenuTrigger ,
13
+ } from "@/components/ui/dropdown-menu" ;
14
+
15
+ export function ThemeToggle ( ) {
16
+ const { setTheme } = useTheme ( ) ;
17
+
18
+ return (
19
+ < DropdownMenu >
20
+ < DropdownMenuTrigger asChild >
21
+ < Button variant = "outline" size = "icon" >
22
+ < SunIcon className = "h-[1.2rem] w-[1.2rem] rotate-0 scale-100 transition-all dark:-rotate-90 dark:scale-0 duration-200" />
23
+ < MoonIcon className = "absolute h-[1.2rem] w-[1.2rem] rotate-90 scale-0 transition-all dark:rotate-0 dark:scale-100 duration-200" />
24
+ < span className = "sr-only" > Toggle theme</ span >
25
+ </ Button >
26
+ </ DropdownMenuTrigger >
27
+ < DropdownMenuContent align = "end" >
28
+ < DropdownMenuItem onClick = { ( ) => setTheme ( "light" ) } >
29
+ Light
30
+ </ DropdownMenuItem >
31
+ < DropdownMenuItem onClick = { ( ) => setTheme ( "dark" ) } >
32
+ Dark
33
+ </ DropdownMenuItem >
34
+ < DropdownMenuItem onClick = { ( ) => setTheme ( "system" ) } >
35
+ System
36
+ </ DropdownMenuItem >
37
+ </ DropdownMenuContent >
38
+ </ DropdownMenu >
39
+ ) ;
40
+ }
Original file line number Diff line number Diff line change
1
+ "use client" ;
2
+
3
+ import * as React from "react" ;
4
+ import { ThemeProvider as NextThemesProvider } from "next-themes" ;
5
+ import { type ThemeProviderProps } from "next-themes/dist/types" ;
6
+
7
+ export function ThemeProvider ( { children, ...props } : ThemeProviderProps ) {
8
+ return < NextThemesProvider { ...props } > { children } </ NextThemesProvider > ;
9
+ }
You can’t perform that action at this time.
0 commit comments