@@ -2,9 +2,11 @@ import type { Metadata } from 'next';
22import { Geist , Geist_Mono } from 'next/font/google' ;
33import '../css/globals.css' ;
44import Link from 'next/link' ;
5+ import { ThemeProvider } from 'next-themes' ;
56import { ButtonIcon , Card , Icon , Popover , Sonner } from 'soybean-react-ui' ;
67
78import ThemeCustomize from '../components/ThemeCustomize' ;
9+ import ThemeSchemaToggler from '../components/ThemeSchemaToggler' ;
810import config from '../config' ;
911
1012const geistSans = Geist ( {
@@ -28,52 +30,74 @@ export default async function RootLayout({
2830 children : React . ReactNode ;
2931} > ) {
3032 return (
31- < html lang = "en" >
33+ < html
34+ lang = "en"
35+ suppressHydrationWarning = { ! config . isDev }
36+ >
37+ < head >
38+ < script
39+ dangerouslySetInnerHTML = { {
40+ __html : `
41+ try {
42+ if (localStorage.theme === 'dark' || ((!('theme' in localStorage) || localStorage.theme === 'system') && window.matchMedia('(prefers-color-scheme: dark)').matches)) {
43+ document.querySelector('meta[name="theme-color"]').setAttribute('content', '${ config . META_THEME_COLORS . dark } ')
44+ }
45+ } catch (_) {}
46+ `
47+ } }
48+ />
49+ </ head >
3250 < body
3351 className = { `${ geistSans . variable } ${ geistMono . variable } antialiased` }
3452 id = "app"
3553 >
36- < div className = "h-full" >
37- < Card
38- flexHeight
39- className = "h-full max-sm:h-auto"
40- title = "Soybean UI Components"
41- extra = {
42- < div className = "flex items-center gap-3" >
43- < Popover
44- align = "end"
45- classNames = { { content : 'z-15' } }
46- side = "bottom"
47- trigger = {
48- < ButtonIcon
49- icon = "lucide:swatch-book"
50- size = "lg"
51- />
52- }
53- >
54- < ThemeCustomize />
55- </ Popover >
54+ < ThemeProvider
55+ disableTransitionOnChange
56+ attribute = "class"
57+ >
58+ < div className = "h-full" >
59+ < Card
60+ className = "h-full max-sm:h-auto"
61+ title = "Soybean UI Components"
62+ extra = {
63+ < div className = "flex items-center gap-3" >
64+ < Popover
65+ align = "end"
66+ classNames = { { content : 'z-15' } }
67+ side = "bottom"
68+ trigger = {
69+ < ButtonIcon
70+ icon = "lucide:swatch-book"
71+ size = "lg"
72+ />
73+ }
74+ >
75+ < ThemeCustomize />
76+ </ Popover >
5677
57- < ButtonIcon
58- asChild
59- size = "lg"
60- >
61- < Link
62- href = { config . githubUrl }
63- rel = "noopener noreferrer"
64- target = "_blank"
78+ < ButtonIcon
79+ asChild
80+ size = "lg"
6581 >
66- < Icon icon = "lucide:github" />
67- </ Link >
68- </ ButtonIcon >
69- </ div >
70- }
71- >
72- { children }
73- </ Card >
74- </ div >
82+ < Link
83+ href = { config . githubUrl }
84+ rel = "noopener noreferrer"
85+ target = "_blank"
86+ >
87+ < Icon icon = "lucide:github" />
88+ </ Link >
89+ </ ButtonIcon >
90+
91+ < ThemeSchemaToggler />
92+ </ div >
93+ }
94+ >
95+ { children }
96+ </ Card >
97+ </ div >
7598
76- < Sonner />
99+ < Sonner />
100+ </ ThemeProvider >
77101 </ body >
78102 </ html >
79103 ) ;
0 commit comments