Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 2 additions & 16 deletions apps/website/app/layout.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
/* eslint-disable @next/next/next-script-for-ga */
/* eslint-disable @next/next/no-page-custom-font */
'use client';
import {
Inter,
Roboto,
Expand All @@ -9,10 +6,8 @@ import {
Space_Mono,
} from 'next/font/google';
import './globals.css';
import { GluestackUIProvider } from '@/components/ui/gluestack-ui-provider';
import { useContext } from 'react';
import { ThemeContext, ThemeProvider } from '@/utils/context/theme-context';
import CanonicalLink from '@/components/custom/canonical/CanonicalLink';
import Provider from './provider';

// Configure fonts with local fallbacks and optimized loading
const inter = Inter({
Expand Down Expand Up @@ -104,22 +99,15 @@ const spaceMono = Space_Mono({
adjustFontFallback: true,
});

function ThemeWrapper({ children }: { children: React.ReactNode }) {
const { colorMode } = useContext(ThemeContext);
return <GluestackUIProvider mode={colorMode}>{children}</GluestackUIProvider>;
}

export default function RootLayout({
children,
}: Readonly<{
children: React.ReactNode;
}>) {
const { colorMode } = useContext(ThemeContext);
return (
<html
lang="en"
className={`${plusJakartaSans.variable} ${roboto.variable} ${sourceCodePro.variable} ${inter.className} ${spaceMono.variable}`}
data-theme-id={colorMode}
>
<head>
{/* Preconnect to Google Fonts domains with higher priority */}
Expand Down Expand Up @@ -159,9 +147,7 @@ export default function RootLayout({
{/* End Google Tag Manager */}
</head>
<body className={inter.className}>
<ThemeProvider>
<ThemeWrapper>{children}</ThemeWrapper>
</ThemeProvider>
<Provider>{children}</Provider>
</body>
</html>
);
Expand Down
52 changes: 11 additions & 41 deletions apps/website/app/provider.tsx
Original file line number Diff line number Diff line change
@@ -1,50 +1,20 @@
'use client';
import React, { useEffect, useState, useContext } from 'react';
import { GluestackUIProvider } from '@/components/ui/gluestack-ui-provider';
import { ThemeContext } from '@/utils/context/theme-context';
import { Plus_Jakarta_Sans, Roboto, Source_Code_Pro } from 'next/font/google';
import StyledJsxRegistry from '@/app/registry';
import StyledJsxRegistry from './registry';
import { ThemeContext, ThemeProvider } from '@/utils/context/theme-context';
import { useContext } from 'react';

const plusJakartaSans = Plus_Jakarta_Sans({
subsets: ['latin'],
variable: '--plus-jakarta-sans',
weight: ['200', '300', '400', '500', '700', '800'],
});

const roboto = Roboto({
subsets: ['latin'],
variable: '--roboto',
weight: ['100', '300', '400', '500', '700', '900'],
});
const sourceCodePro = Source_Code_Pro({
subsets: ['latin'],
variable: '--source-code-pro',
weight: ['300', '400', '500', '700', '900'],
});

export const Provider = ({ children }: any) => {
function ProviderWithTheme({ children }: { children: React.ReactNode }) {
const { colorMode } = useContext(ThemeContext);
return <GluestackUIProvider mode={colorMode}>{children}</GluestackUIProvider>;
}

export default function Provider({ children }: { children: React.ReactNode }) {
return (
<body
className={`${plusJakartaSans.variable} ${roboto.variable} ${sourceCodePro.variable} ${colorMode}`}
style={{
display: 'flex',
backgroundColor: 'rgb(var(--color-background-0))',
}}
data-theme-id={colorMode}
>
<noscript>
<iframe
src={`https://www.googletagmanager.com/ns.html?id=${process.env.NEXT_PUBLIC_GOOGLE_TAG_MANAGER_ID}`}
height="0"
width="0"
style={{ display: 'none', visibility: 'hidden' }}
/>
</noscript>
<ThemeProvider>
<StyledJsxRegistry>
<GluestackUIProvider mode={colorMode}>{children}</GluestackUIProvider>
<ProviderWithTheme>{children}</ProviderWithTheme>
</StyledJsxRegistry>
</body>
</ThemeProvider>
);
};
}
29 changes: 10 additions & 19 deletions apps/website/app/registry.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,10 @@
'use client';

import React, { useRef, useState } from 'react';
import { useServerInsertedHTML } from 'next/navigation';
import { StyleRegistry, createStyleRegistry } from 'styled-jsx';
// eslint-disable-next-line @next/next/no-document-import-in-page
import { Main } from 'next/document';
// @ts-ignore
import { AppRegistry } from 'react-native-web';
import { flush as themeFlush } from '@/components/utils/flush';
import { flush } from '@gluestack-ui/nativewind-utils/flush';
"use client";
import React, { useRef, useState } from "react";
import { useServerInsertedHTML } from "next/navigation";
import { StyleRegistry, createStyleRegistry } from "styled-jsx";
// @ts-expect-error : AppRegistry is defined in react-native-web but its type is not defined
import { AppRegistry } from "react-native-web";
import { flush } from "@gluestack-ui/utils/nativewind-utils";

export default function StyledJsxRegistry({
children,
Expand All @@ -21,16 +17,11 @@ export default function StyledJsxRegistry({
const isServerInserted = useRef(false);

useServerInsertedHTML(() => {
AppRegistry.registerComponent('Main', () => Main);
const { getStyleElement } = AppRegistry.getApplication('Main');
AppRegistry.registerComponent("Main", () => "main");
const { getStyleElement } = AppRegistry.getApplication("Main");
if (!isServerInserted.current) {
isServerInserted.current = true;
const styles = [
getStyleElement(),
jsxStyleRegistry.styles(),
flush(),
themeFlush(),
];
const styles = [getStyleElement(), jsxStyleRegistry.styles(), flush()];
jsxStyleRegistry.flush();
return <>{styles}</>;
}
Expand Down
7 changes: 6 additions & 1 deletion apps/website/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -490,11 +490,16 @@
"@babel/plugin-transform-modules-commonjs" "^7.27.1"
"@babel/plugin-transform-typescript" "^7.27.1"

"@babel/runtime@^7.18.6", "@babel/runtime@^7.25.0", "@babel/runtime@^7.27.1", "@babel/runtime@^7.6.2", "@babel/runtime@^7.8.7":
"@babel/runtime@^7.18.6", "@babel/runtime@^7.25.0", "@babel/runtime@^7.6.2", "@babel/runtime@^7.8.7":
version "7.28.2"
resolved "https://registry.npmjs.org/@babel/runtime/-/runtime-7.28.2.tgz#2ae5a9d51cc583bd1f5673b3bb70d6d819682473"
integrity sha512-KHp2IflsnGywDjBWDkR9iEqiWSpc8GIi0lgTT3mOElT0PP1tG26P4tmFI2YvAdzgq9RGyoHZQEIEdZy6Ec5xCA==

"@babel/runtime@^7.27.1":
version "7.28.3"
resolved "https://registry.npmjs.org/@babel/runtime/-/runtime-7.28.3.tgz#75c5034b55ba868121668be5d5bb31cc64e6e61a"
integrity sha512-9uIQ10o0WGdpP6GDhXcdOJPJuDgFtIDtN/9+ArJQ2NAfAmiuhTQdzkaTGR33v43GYS2UrSA0eX2pPPHoFVvpxA==

"@babel/template@^7.25.0", "@babel/template@^7.27.2", "@babel/template@^7.3.3":
version "7.27.2"
resolved "https://registry.npmjs.org/@babel/template/-/template-7.27.2.tgz#fa78ceed3c4e7b63ebf6cb39e5852fca45f6809d"
Expand Down
Loading