diff --git a/packages/genui/a2ui-playground/rsbuild.config.ts b/packages/genui/a2ui-playground/rsbuild.config.ts index b36415e8a6..2c1e1ef837 100644 --- a/packages/genui/a2ui-playground/rsbuild.config.ts +++ b/packages/genui/a2ui-playground/rsbuild.config.ts @@ -43,6 +43,9 @@ export default defineConfig({ render: './src/render.tsx', }, }, + html: { + title: 'Lynx A2UI Playground', + }, output: { assetPrefix: process.env.ASSET_PREFIX, copy: [ diff --git a/packages/genui/a2ui-playground/src/App.tsx b/packages/genui/a2ui-playground/src/App.tsx index a17502a822..f3113de2ac 100644 --- a/packages/genui/a2ui-playground/src/App.tsx +++ b/packages/genui/a2ui-playground/src/App.tsx @@ -1,7 +1,7 @@ // Copyright 2026 The Lynx Authors. All rights reserved. // Licensed under the Apache License Version 2.0 that can be found in the // LICENSE file in the root directory of this source tree. -import { useCallback, useEffect, useState } from 'react'; +import { useCallback, useEffect, useLayoutEffect, useState } from 'react'; import { ProtocolSwitch } from './components/ProtocolSwitch.js'; import { AIChatPage } from './pages/AIChatPage.js'; @@ -33,11 +33,28 @@ function parseHash(hash: string): Route { return { tab: 'chat' }; } +type Theme = 'light' | 'dark'; + +function getSystemTheme(): Theme { + try { + return window.matchMedia?.('(prefers-color-scheme: dark)')?.matches + ? 'dark' + : 'light'; + } catch { + return 'light'; + } +} + export function App() { const [route, setRoute] = useState(() => parseHash(window.location.hash) ); const [protocol, setProtocol] = useState(DEFAULT_PROTOCOL); + const [theme, setTheme] = useState(getSystemTheme); + + useLayoutEffect(() => { + document.documentElement.setAttribute('data-theme', theme); + }, [theme]); useEffect(() => { const onHashChange = () => { @@ -71,7 +88,7 @@ export function App() { return (
- A2UI Playground + Lynx A2UI Playground
+ +
diff --git a/packages/genui/a2ui-playground/src/components/MobilePreview.tsx b/packages/genui/a2ui-playground/src/components/MobilePreview.tsx index 6b040ef1f4..2abb8849f4 100644 --- a/packages/genui/a2ui-playground/src/components/MobilePreview.tsx +++ b/packages/genui/a2ui-playground/src/components/MobilePreview.tsx @@ -5,15 +5,7 @@ export function MobilePreview(props: { src: string }) { return (
-
-
-
-
-