Skip to content

Commit

Permalink
chore: update app layout
Browse files Browse the repository at this point in the history
  • Loading branch information
hbjORbj committed Oct 15, 2024
1 parent 6360e73 commit 5a2048b
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 20 deletions.
58 changes: 40 additions & 18 deletions apps/web/app/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -70,15 +70,46 @@ export default async function RootLayout({ children }: { children: React.ReactNo
suppressHydrationWarning
data-nextjs-router="app">
<head nonce={nonce}>
{!!process.env.NEXT_PUBLIC_HEAD_SCRIPTS && (
<script
nonce={nonce}
id="injected-head-scripts"
dangerouslySetInnerHTML={{
__html: process.env.NEXT_PUBLIC_HEAD_SCRIPTS,
}}
/>
)}
<script
nonce={nonce}
id="headScript"
dangerouslySetInnerHTML={{
__html: `
window.calNewLocale = "${locale}";
(function applyTheme() {
try {
const appTheme = localStorage.getItem('app-theme');
if (!appTheme) return;
let bookingTheme, username;
for (let i = 0; i < localStorage.length; i++) {
const key = localStorage.key(i);
if (key.startsWith('booking-theme:')) {
bookingTheme = localStorage.getItem(key);
username = key.split("booking-theme:")[1];
break;
}
}
const onReady = () => {
const isBookingPage = username && window.location.pathname.slice(1).startsWith(username);
if (document.body) {
document.body.classList.add(isBookingPage ? bookingTheme : appTheme);
} else {
requestAnimationFrame(onReady);
}
};
requestAnimationFrame(onReady);
} catch (e) {
console.error('Error applying theme:', e);
}
})();
`,
}}
/>

<style>{`
:root {
--font-inter: ${interFont.style.fontFamily.replace(/\'/g, "")};
Expand All @@ -101,15 +132,6 @@ export default async function RootLayout({ children }: { children: React.ReactNo
}
: {}
}>
{!!process.env.NEXT_PUBLIC_BODY_SCRIPTS && (
<script
nonce={nonce}
id="injected-head-scripts"
dangerouslySetInnerHTML={{
__html: process.env.NEXT_PUBLIC_BODY_SCRIPTS,
}}
/>
)}
{children}
</body>
</html>
Expand Down
2 changes: 0 additions & 2 deletions turbo.json
Original file line number Diff line number Diff line change
Expand Up @@ -449,8 +449,6 @@
"EMBED_PUBLIC_WEBAPP_URL",
"EMBED_PUBLIC_VERCEL_URL",
"NEXT_PUBLIC_ENABLE_PROFILE_SWITCHER",
"NEXT_PUBLIC_HEAD_SCRIPTS",
"NEXT_PUBLIC_BODY_SCRIPTS",
"NEXT_PUBLIC_ORG_SELF_SERVE_ENABLED",
"NEXT_PUBLIC_API_V2_ROOT_URL",
"NEXT_PUBLIC_VAPID_PUBLIC_KEY",
Expand Down

0 comments on commit 5a2048b

Please sign in to comment.