Skip to content

Commit 9f6013d

Browse files
fix: generate primary-hover color tokens from provided app config (#239)
1 parent aad6915 commit 9f6013d

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

app/layout.tsx

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { Public_Sans } from 'next/font/google';
22
import localFont from 'next/font/local';
33
import { headers } from 'next/headers';
4+
import { APP_CONFIG_DEFAULTS } from '@/app-config';
45
import { ApplyThemeScript, ThemeToggle } from '@/components/theme-toggle';
56
import { getAppConfig } from '@/lib/utils';
67
import './globals.css';
@@ -44,9 +45,15 @@ export default async function RootLayout({ children }: RootLayoutProps) {
4445
const hdrs = await headers();
4546
const { accent, accentDark, pageTitle, pageDescription } = await getAppConfig(hdrs);
4647

48+
// check provided accent colors against defaults, and apply styles if they differ (or in development mode)
49+
// generate a hover color for the accent color by mixing it with 20% black
4750
const styles = [
48-
accent ? `:root { --primary: ${accent}; }` : '',
49-
accentDark ? `.dark { --primary: ${accentDark}; }` : '',
51+
process.env.NODE_ENV === 'development' || accent !== APP_CONFIG_DEFAULTS.accent
52+
? `:root { --primary: ${accent}; --primary-hover: color-mix(in srgb, ${accent} 80%, #000); }`
53+
: '',
54+
process.env.NODE_ENV === 'development' || accentDark !== APP_CONFIG_DEFAULTS.accentDark
55+
? `.dark { --primary: ${accentDark}; --primary-hover: color-mix(in srgb, ${accentDark} 80%, #000); }`
56+
: '',
5057
]
5158
.filter(Boolean)
5259
.join('\n');

0 commit comments

Comments
 (0)