Skip to content

Commit b9eae53

Browse files
committed
feat: update playground layout
1 parent ee66ac7 commit b9eae53

File tree

2 files changed

+71
-47
lines changed

2 files changed

+71
-47
lines changed

playground/src/app/layout.tsx

Lines changed: 63 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,11 @@ import type { Metadata } from 'next';
22
import { Geist, Geist_Mono } from 'next/font/google';
33
import '../css/globals.css';
44
import Link from 'next/link';
5+
import { ThemeProvider } from 'next-themes';
56
import { ButtonIcon, Card, Icon, Popover, Sonner } from 'soybean-react-ui';
67

78
import ThemeCustomize from '../components/ThemeCustomize';
9+
import ThemeSchemaToggler from '../components/ThemeSchemaToggler';
810
import config from '../config';
911

1012
const 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
);

playground/src/config.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
class Config {
2-
private _githubUrl = 'https://github.com/Ohh-889/soybean-react-ui';
3-
4-
get githubUrl() {
5-
return this._githubUrl;
1+
const config = {
2+
githubUrl: 'https://github.com/Ohh-889/soybean-react-ui',
3+
// eslint-disable-next-line n/prefer-global/process
4+
isDev: process.env.NODE_ENV === 'development',
5+
META_THEME_COLORS: {
6+
dark: '#030712',
7+
light: '#fafafa'
68
}
7-
}
8-
9-
const config = new Config();
9+
} as const;
1010

1111
export default config;

0 commit comments

Comments
 (0)