error fix
This commit is contained in:
+3
-42
@@ -6,6 +6,7 @@ import i18nConfig from "../../i18nConfig";
|
||||
import initTranslations from '@/lib/i18n';
|
||||
import TranslationsProvider from "@/components/utils/TranslationsProdiver";
|
||||
import ToastContainer from "@/components/Toast";
|
||||
import { ThemeColorSetter } from "@/components/ThemeColorSetter";
|
||||
|
||||
export const metadata: Metadata = {
|
||||
title: 'Dashboard',
|
||||
@@ -42,48 +43,7 @@ export default async function RootLayout({
|
||||
dir='rtl'
|
||||
className="h-svh overflow-hidden"
|
||||
data-theme="light" >
|
||||
<head>
|
||||
<script
|
||||
dangerouslySetInnerHTML={{
|
||||
__html: `
|
||||
(function() {
|
||||
try {
|
||||
const savedColor = localStorage.getItem('theme-primary-color');
|
||||
if (savedColor) {
|
||||
const hex = savedColor.replace('#', '');
|
||||
const r = parseInt(hex.substring(0, 2), 16) / 255;
|
||||
const g = parseInt(hex.substring(2, 4), 16) / 255;
|
||||
const b = parseInt(hex.substring(4, 6), 16) / 255;
|
||||
|
||||
const lightness = 0.2126 * r + 0.7152 * g + 0.0722 * b;
|
||||
const max = Math.max(r, g, b);
|
||||
const min = Math.min(r, g, b);
|
||||
const chroma = (max - min) * 0.15;
|
||||
|
||||
let hue = 0;
|
||||
if (chroma !== 0) {
|
||||
if (max === r) {
|
||||
hue = ((g - b) / (max - min) + (g < b ? 6 : 0)) * 60;
|
||||
} else if (max === g) {
|
||||
hue = ((b - r) / (max - min) + 2) * 60;
|
||||
} else {
|
||||
hue = ((r - g) / (max - min) + 4) * 60;
|
||||
}
|
||||
}
|
||||
|
||||
const oklchColor = 'oklch(' + lightness.toFixed(3) + ' ' + chroma.toFixed(3) + ' ' + hue.toFixed(1) + ')';
|
||||
document.documentElement.style.setProperty('--primary', oklchColor);
|
||||
|
||||
const brightness = (r * 299 + g * 587 + b * 114) / 1000;
|
||||
const foregroundOklch = brightness > 0.5 ? 'oklch(0 0 0)' : 'oklch(1 0 0)';
|
||||
document.documentElement.style.setProperty('--primary-foreground', foregroundOklch);
|
||||
}
|
||||
} catch (e) {}
|
||||
})();
|
||||
`,
|
||||
}}
|
||||
/>
|
||||
</head>
|
||||
<head />
|
||||
<body
|
||||
|
||||
className={`antialiased bg-background h-svh overflow-hidden`}
|
||||
@@ -93,6 +53,7 @@ export default async function RootLayout({
|
||||
namespaces={i18nNamespaces}
|
||||
locale={locale}
|
||||
resources={resources}>
|
||||
<ThemeColorSetter />
|
||||
<div id="root" className="h-svh overflow-hidden">
|
||||
{children}
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user