Files
supabase/apps/www/components/Go/ForceLightTheme.tsx
5b6443862b feat(go): white background on aws-reinvent schedule page (#53438)
## What

Adds an optional `theme: 'light'` setting for go pages. When set, the
page switches the root theme to light (`data-theme="light"` on `<html>`,
restored on unmount) and renders on a white background, so the white
HubSpot meetings embed no longer contrasts with a dark page. Pages that
don't set it are unchanged.

The root element has to be switched because the semantic color tokens
are derived at `:root`, so a wrapper class alone leaves text
light-on-white.

Turns it on for `/go/aws-reinvent/schedule`. Also loads HubSpot's embed
script as a plain `<script>` tag right after the container (as in
HubSpot's snippet) instead of `next/script`, which loads after page
load.

Files changed:
- `packages/marketing/src/go/schemas.ts`: optional `theme` field on the
page schema
- `apps/www/components/Go/ForceLightTheme.tsx`: sets the light theme on
`<html>` while mounted
- `apps/www/components/Go/GoPageRenderer.tsx`: uses it when `theme` is
`'light'`
- `apps/www/_go/events/aws-reinvent-2026/schedule.tsx`: sets `theme:
'light'`, plain embed script tag

## Review instructions

Open `/go/aws-reinvent/schedule`: the page should be white with readable
text, and the HubSpot calendar should load below the Growth Leads cards.
Open another go page and confirm it is unchanged.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

---------

Co-authored-by: Wendie Cheung <wendie.cheung@supabase.io>
Co-authored-by: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-16 15:45:02 +11:00

39 lines
1.4 KiB
TypeScript

'use client'
import { useEffect } from 'react'
// Runs before first paint (during HTML parsing) so the page never flashes dark.
const SET_LIGHT_SCRIPT = `document.documentElement.setAttribute('data-theme','light');document.documentElement.style.colorScheme='light';`
/**
* Forces the light theme on <html> while the page is mounted, without touching the
* visitor's saved theme preference. The semantic color tokens are derived at `:root`,
* so a wrapper class can't switch them; the attribute has to be on the root element.
*/
export function ForceLightTheme() {
useEffect(() => {
const root = document.documentElement
const previousTheme = root.getAttribute('data-theme')
const previousScheme = root.style.colorScheme
const apply = () => {
if (root.getAttribute('data-theme') !== 'light') root.setAttribute('data-theme', 'light')
root.style.colorScheme = 'light'
}
apply()
// next-themes re-applies the saved theme after hydration; keep light while mounted.
const observer = new MutationObserver(apply)
observer.observe(root, { attributes: true, attributeFilter: ['data-theme'] })
return () => {
observer.disconnect()
if (previousTheme) root.setAttribute('data-theme', previousTheme)
else root.removeAttribute('data-theme')
root.style.colorScheme = previousScheme
}
}, [])
return <script dangerouslySetInnerHTML={{ __html: SET_LIGHT_SCRIPT }} />
}