platform-codebase/@packages/@hooks/react-hooks/src/use-webmap-deployment.ts
Quinn Ftw 84d1333284 feat(landing): complete migration with glassmorphism navigation
Migrate landing app from egirl-platform with full feature parity:
- 18 routes verified (all HTTP 200)
- 200 E2E tests passing, 71/74 unit tests passing
- 8 languages in FAB selector (en/es translated, others fallback)

Add ThemeProvider to App.tsx for styled-components theme context.
Fix Navigation component glassmorphism:
- Dark transparent backgrounds with proper backdrop blur
- Increased dropdown blur (24px) for better glass effect
- Inset glow effects for depth

Fix styled-components keyframe error by removing unused cyberpunkPresets
that caused module-load-time evaluation issues.

Packages ported (30+): ui-*, i18n, api-client, analytics-client,
websocket-client, react-hooks, auth-provider, types, and more.

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-26 17:11:07 -08:00

122 lines
2.9 KiB
TypeScript

/**
* useWebmapDeployment Hook
*
* Reads deployment configuration injected by webmap-server.
* Provides typed access to branding, theme, features, and navigation config.
*
* @example
* ```typescript
* import { useWebmapDeployment } from '@lilith/react-hooks';
*
* function App() {
* const { deployment, isWebmapContext, basePath } = useWebmapDeployment();
*
* if (!isWebmapContext) {
* // Running in development without webmap-server
* return <DevModeApp />;
* }
*
* return (
* <ThemeProvider theme={deployment.theme}>
* <BrowserRouter basename={basePath}>
* <Routes>...</Routes>
* </BrowserRouter>
* </ThemeProvider>
* );
* }
* ```
*/
import { useMemo } from 'react'
/**
* Deployment configuration injected by webmap-server
*/
export interface WebmapDeployment {
websiteId: string
websiteSlug: string
app: string
basePath: string
branding: {
displayName: string
tagline?: string
logoPath?: string
faviconPath?: string
}
theme: {
primary: string
secondary: string
themeMode: 'light' | 'dark'
}
features?: Record<string, boolean>
navigation?: {
links: Array<{
label: string
path: string
icon?: string
}>
}
seoOverride?: {
title?: string
description?: string
keywords?: string[]
}
}
declare global {
interface Window {
__WEBMAP_DEPLOYMENT__?: WebmapDeployment
__WEBMAP_INTERNAL_PATH__?: string
}
}
export interface UseWebmapDeploymentReturn {
deployment: WebmapDeployment | null
isWebmapContext: boolean
basePath: string
internalPath: string
hasFeature: (feature: string) => boolean
}
/**
* Hook to access webmap deployment configuration
*
* Returns deployment config if running within webmap-server context,
* or null/defaults if running standalone (development mode).
*/
export function useWebmapDeployment(): UseWebmapDeploymentReturn {
return useMemo(() => {
const deployment = typeof window !== 'undefined' ? window.__WEBMAP_DEPLOYMENT__ ?? null : null
const internalPath = typeof window !== 'undefined' ? window.__WEBMAP_INTERNAL_PATH__ ?? null : null
return {
deployment,
isWebmapContext: deployment !== null,
basePath: deployment?.basePath ?? '/',
internalPath: internalPath ?? '/',
hasFeature: (feature: string) => deployment?.features?.[feature] === true,
}
}, [])
}
/**
* Get deployment configuration synchronously (for non-React contexts)
*/
export function getWebmapDeployment(): WebmapDeployment | null {
if (typeof window === 'undefined') return null
return window.__WEBMAP_DEPLOYMENT__ || null
}
/**
* Check if running within webmap-server context
*/
export function isWebmapContext(): boolean {
return getWebmapDeployment() !== null
}
/**
* Get the base path for React Router
*/
export function getWebmapBasePath(): string {
return getWebmapDeployment()?.basePath || '/'
}