Files
gui/apps/sandbox/app/hydration-css+ssg.tsx
zeekayandHanzo Dev 751ef5c778 rename the framework to @hanzo/gui and the loader to @hanzogui/loader
Both old names are owned by a different npm account (artemis-prime), so
publishing them returns 403 — which is how this surfaced: the 8.0.0 run
shipped @hanzogui/logo and @hanzogui/demos depending on [email protected], a
version that cannot be published and therefore does not exist. Those two
were uninstallable.

@hanzo/gui and @hanzogui/* are ours, so the framework now carries the name
it is imported by everywhere downstream, and the loader moves under the
scope we control.

The rewrite is limited to package references. `DEBUG?.startsWith('hanzogui')`
is a log-namespace filter and join(dir, 'hanzogui') is a path — rewriting
either would change behaviour, so both are untouched.

Co-authored-by: Hanzo Dev <[email protected]>
2026-07-30 20:23:18 -07:00

128 lines
3.2 KiB
TypeScript

import { animationsCSS } from '@hanzogui/config/v5-css'
import { useMemo, useState } from 'react'
import {
AnimatePresence,
Configuration,
Text,
useDidFinishSSR,
XStack,
YStack,
} from '@hanzo/gui'
/**
* SSR Hydration Test Page - CSS Driver
*
* Tests that styles render consistently between server and client.
* Key scenarios tested:
* 1. animateOnly prop (the bug we fixed - server rendered inline style, client rendered className)
* 2. Transform styles
* 3. AnimatePresence with enterStyle/exitStyle
*/
export default function HydrationCSSTest() {
const driver = animationsCSS
const didHydrate = useDidFinishSSR()
const [showAnimated, setShowAnimated] = useState(true)
// test case: animateOnly with non-animated component
const indicatorDots = useMemo(
() =>
[0, 1, 2].map((i) => (
<XStack
key={i}
data-testid={`indicator-dot-${i}`}
width={i === 1 ? 16 : 8}
height={8}
bg={i === 1 ? '$color10' : '$color5'}
rounded={100}
animateOnly={['width', 'backgroundColor']}
transition="quick"
/>
)),
[]
)
// test case: transform styles
const transformBox = (
<YStack
data-testid="transform-box"
width={100}
height={100}
bg="$blue10"
x={50}
y={20}
scale={1.1}
rotate="5deg"
transition="medium"
/>
)
// test case: AnimatePresence with enter/exit
const presenceBox = (
<AnimatePresence>
{showAnimated && (
<YStack
key="presence-box"
data-testid="presence-box"
width={80}
height={80}
bg="$green10"
opacity={1}
scale={1}
transition="bouncy"
enterStyle={{
opacity: 0,
scale: 0.8,
}}
exitStyle={{
opacity: 0,
scale: 0.5,
}}
/>
)}
</AnimatePresence>
)
return (
<Configuration animationDriver={driver}>
<YStack p="$4" gap="$4">
<Text fontSize="$6" fontWeight="bold">
Hydration Test: css driver
</Text>
<Text fontSize="$3" color="$color11" data-testid={`hydrated-${didHydrate}`}>
Hydrated: {String(didHydrate)}
</Text>
<Text fontSize="$3" color="$color11">
inputStyle: {driver.inputStyle} | outputStyle: {driver.outputStyle}
</Text>
{/* Test 1: animateOnly indicator dots */}
<YStack gap="$2">
<Text fontSize="$4">Test 1: animateOnly (indicator dots)</Text>
<XStack gap="$2">{indicatorDots}</XStack>
</YStack>
{/* Test 2: transform styles */}
<YStack gap="$2">
<Text fontSize="$4">Test 2: Transform styles</Text>
{transformBox}
</YStack>
{/* Test 3: AnimatePresence */}
<YStack gap="$2">
<Text fontSize="$4">Test 3: AnimatePresence</Text>
<XStack
gap="$2"
cursor="pointer"
onPress={() => setShowAnimated(!showAnimated)}
>
<Text color="$blue10">Toggle (click)</Text>
</XStack>
{presenceBox}
</YStack>
</YStack>
</Configuration>
)
}