mirror of
https://github.com/hanzoai/gui.git
synced 2026-11-03 00:13:54 +00:00
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]>
76 lines
2.1 KiB
TypeScript
76 lines
2.1 KiB
TypeScript
import type { ComponentType } from 'react'
|
|
import { useParams } from 'one'
|
|
import { YStack, H2, Theme, Paragraph } from '@hanzo/gui'
|
|
import * as Demos from '~/features/docs/demos'
|
|
|
|
// Type for demo components (exclude lazyDemo helper function)
|
|
type DemoExports = {
|
|
[K in keyof typeof Demos]: (typeof Demos)[K] extends () => React.ReactNode ? K : never
|
|
}[keyof typeof Demos]
|
|
|
|
// Get all demo names for static generation (exclude lazyDemo helper)
|
|
const demoNames = Object.keys(Demos)
|
|
.filter((key) => key.endsWith('Demo') && key !== 'lazyDemo')
|
|
.map((key) => key.replace(/Demo$/, '').toLowerCase())
|
|
|
|
export function generateStaticParams() {
|
|
return demoNames.map((name) => ({ name }))
|
|
}
|
|
|
|
export default function DemoPage() {
|
|
const params = useParams<{ name: string }>()
|
|
const demoName = params.name
|
|
|
|
if (!demoName) {
|
|
return (
|
|
<Theme name="light">
|
|
<YStack flex={1} items="center" justify="center" p="$6" bg="$background">
|
|
<H2>No demo specified</H2>
|
|
<Paragraph color="$color10" mt="$2">
|
|
Try /demo/Menu or /demo/Button
|
|
</Paragraph>
|
|
</YStack>
|
|
</Theme>
|
|
)
|
|
}
|
|
|
|
// Capitalize first letter and add "Demo" suffix
|
|
const componentName =
|
|
`${demoName.charAt(0).toUpperCase()}${demoName.slice(1)}Demo` as DemoExports
|
|
const DemoComponent = Demos[componentName] as ComponentType
|
|
|
|
if (!DemoComponent) {
|
|
return (
|
|
<Theme name="light">
|
|
<YStack flex={1} items="center" justify="center" p="$6" bg="$background">
|
|
<H2>Demo not found</H2>
|
|
<Paragraph color="$color10" mt="$2">
|
|
Could not find {componentName}
|
|
</Paragraph>
|
|
<Paragraph color="$color9" mt="$2">
|
|
Try /demo/Menu or /demo/Button
|
|
</Paragraph>
|
|
</YStack>
|
|
</Theme>
|
|
)
|
|
}
|
|
|
|
return (
|
|
<Theme name="light">
|
|
<YStack
|
|
flex={1}
|
|
items="center"
|
|
justify="center"
|
|
p="$6"
|
|
bg="$background"
|
|
minH="100vh"
|
|
>
|
|
<YStack width="100%" maxW={1200}>
|
|
<H2 mb="$4">{componentName}</H2>
|
|
<DemoComponent />
|
|
</YStack>
|
|
</YStack>
|
|
</Theme>
|
|
)
|
|
}
|