mirror of
https://github.com/hanzoai/ui.git
synced 2026-11-21 13:51:19 +00:00
* @hanzo/ui 8.30.0: every word the package authors is the reader's language
- The consumer installs every peer of the train it pins
- @hanzo/ui 8.30.0: every word the package authors is the reader's language
- i18n: one English fallback, the footer's doors through t, and a typed header cell
- agents: the elements i18n touched draw with gui props, not style
- i18n: @hanzo/ui/product/pure still depends on nothing
- i18n: the framework's collections, records and media say their words in the reader's language
- i18n: one English fallback for the pure modules that build a sentence
- i18n: the builder workspace says its words in the reader's language
- i18n: settings, the catalogue shelf and the backdrop presets
- i18n: the masthead's tree is marked for translation and drawn through t
- i18n: the product layer says its words in the reader's language
- i18n: mockups and market widgets say their words in the reader's language
- i18n: the gui controls say their words in the reader's language
- picker: each choosable option wears the field's own ink
- consent: the bar's fit width is a gui prop
- i18n: onboarding, chat, the model picker, sign-in, consent and the corner speak the reader's language
- i18n: @hanzo/ui peer-depends on @hanzo/i18n
* feat(i18n): localize built-in UI copy and the docs site
English stays the default. A locale on Hanzo or LocaleProvider switches
built-in labels, chat copy, and dates, and Arabic sets dir=rtl. Missing
keys render in English. The docs site adds a language switcher, prefixed
routes, hreflang, and a localized sitemap.
Co-authored-by: z <[email protected]>
* docs: translate every page into the 16 target locales
Each English doc now has a locale file under data/i18n. Code fences,
previews, links, and product names stay as written. A missing file still
falls back to English.
Co-authored-by: z <[email protected]>
* Unfinished: these files still contain <<<<<<< / ======= / >>>>>>> conflict markers on origin/agent/i18n-locales-0366: pk…
Run: sess_498ba60a49b5870a63d042e97f565728
* No conflict markers remain. Now: pull origin agent/i18n-locales-0366 (merge), run pnpm install --frozen-lockfile (if it…
Run: sess_0a7901763139b331895f48f02df95b94
* CI on agent/i18n-locales-0366 head 362214f fails @hanzo/ui tests 1-8, ui browser/vite/webpack. Concrete errors: (a) pkg/…
Run: sess_79bff23928c2986ee61768a243fc6dfa
* fix(ui): Dial RING from look; drop duplicate useI18n in Masthead
Unblocks pkg/ui build on #266: RING lives in ./look (not ./ring); Masthead had a duplicate const { t } = useI18n() after the #254/#287 merge.
* fix(ui): rtl.test ALLOWED counts for Masthead/DiffViewer/SlideOver
Align ALLOWED physical-side budgets with current source after the i18n merge: Masthead 2, DiffViewer 5, SlideOver 1.
* fix(ui): RepoSelect test expects default note + troubleshoot
Co-authored-by: Hanzo Dev <[email protected]>
---------
Co-authored-by: Cursor Agent <[email protected]>
Co-authored-by: z <[email protected]>
Co-authored-by: hanzo-agent <[email protected]>
Co-authored-by: Hanzo Dev <[email protected]>
Co-authored-by: hanzo-platform[bot] <201622097+hanzo-platform[bot]@users.noreply.github.com>
116 lines
4.8 KiB
TypeScript
116 lines
4.8 KiB
TypeScript
import { useEffect, useState, type ReactNode } from 'react'
|
|
import { Button, Text, TooltipSimple, View, XStack, YStack } from '@hanzo/gui'
|
|
import { useTranslate } from '@hanzo/ui'
|
|
import { Github, Menu, Search } from '@hanzogui/lucide-icons-2'
|
|
import { brand } from '~/brand'
|
|
import type { Href } from 'one'
|
|
import { Link } from 'one'
|
|
|
|
import { Appearance } from './appearance'
|
|
import { HEADER, useMenu, WIDTH } from './docs'
|
|
import { LanguageSwitch, LocaleLink, useBarePath, useLocalHref } from './locale'
|
|
import { ThemeToggle } from './theme'
|
|
|
|
/** The 60px bar: mark and name, the sections, and the page's controls. A
|
|
* hairline and a blur arrive once the page has scrolled under it. */
|
|
export function Header() {
|
|
const t = useTranslate()
|
|
const local = useLocalHref()
|
|
const [scrolled, setScrolled] = useState(false)
|
|
const path = useBarePath()
|
|
const { setOpen, focus } = useMenu()
|
|
|
|
useEffect(() => {
|
|
const on = () => setScrolled(window.scrollY > 30)
|
|
on()
|
|
window.addEventListener('scroll', on, { passive: true })
|
|
return () => window.removeEventListener('scroll', on)
|
|
}, [])
|
|
|
|
return (
|
|
<XStack render="header" position="sticky" t={0} z={100} width="100%" justify="center" borderBottomWidth={1} borderColor={scrolled ? '$borderColor' : 'transparent'}>
|
|
<YStack position="absolute" inset={0} bg="$background" opacity={scrolled ? 0.85 : 0} backdropFilter={scrolled ? 'blur(16px)' : undefined} pointerEvents="none" />
|
|
<XStack width="100%" maxW={WIDTH} height={HEADER} px="$4" items="center" gap="$4" position="relative">
|
|
<LocaleLink href="/" aria-label={t('Homepage')} style={{ textDecorationLine: 'none' }}>
|
|
<XStack items="center" gap="$2">
|
|
<brand.mark size={22} />
|
|
<Text fontWeight="600" fontSize={15} color="$color12">
|
|
{brand.name}
|
|
</Text>
|
|
</XStack>
|
|
</LocaleLink>
|
|
|
|
<View flex={1} />
|
|
|
|
<XStack render="nav" items="center" gap="$1" display="none" $lg={{ display: 'flex' }}>
|
|
<NavLink href={local('/docs')} active={path.startsWith('/docs')}>
|
|
{t('Docs')}
|
|
</NavLink>
|
|
<NavLink href={local('/ui')} active={path.startsWith('/ui')}>
|
|
{t('Components')}
|
|
</NavLink>
|
|
<NavLink href={local('/blocks')} active={path.startsWith('/blocks')}>
|
|
{t('Blocks')}
|
|
</NavLink>
|
|
<NavLink href={local('/product')} active={path.startsWith('/product')}>
|
|
{t('Product')}
|
|
</NavLink>
|
|
<NavLink href={local('/chat')} active={path.startsWith('/chat')}>
|
|
{t('Chat')}
|
|
</NavLink>
|
|
<NavLink href={local('/agents')} active={path.startsWith('/agents')}>
|
|
{t('Agents')}
|
|
</NavLink>
|
|
<NavLink href={local('/settings')} active={path.startsWith('/settings')}>
|
|
{t('Settings')}
|
|
</NavLink>
|
|
<NavLink href={local('/catalog')} active={path.startsWith('/catalog')}>
|
|
{t('Catalog')}
|
|
</NavLink>
|
|
{brand.framework ? <NavLink href={brand.framework.url}>{t('Framework')}</NavLink> : null}
|
|
</XStack>
|
|
|
|
<XStack items="center" gap="$1">
|
|
<LocaleLink href={brand.github} target="_blank" aria-label={t('GitHub')} style={{ textDecorationLine: 'none' }}>
|
|
<XStack width={36} height={36} items="center" justify="center" rounded="$10" opacity={0.8} hoverStyle={{ opacity: 1, bg: '$color2' }}>
|
|
<Github size={18} />
|
|
</XStack>
|
|
</LocaleLink>
|
|
<ThemeToggle />
|
|
<LanguageSwitch />
|
|
<TooltipSimple label={t('Search')}>
|
|
<Button
|
|
size="$2"
|
|
rounded="$10"
|
|
aria-label={t('Search the catalog')}
|
|
icon={<Search size={14} />}
|
|
iconAfter={
|
|
<Text fontSize={11} opacity={0.4} display="none" $md={{ display: 'flex' }}>
|
|
⌘K
|
|
</Text>
|
|
}
|
|
onPress={focus}
|
|
/>
|
|
</TooltipSimple>
|
|
<Appearance />
|
|
<View $lg={{ display: 'none' }}>
|
|
<Button size="$3" circular chromeless aria-label={t('Menu')} icon={<Menu size={20} />} onPress={() => setOpen(true)} />
|
|
</View>
|
|
</XStack>
|
|
</XStack>
|
|
</XStack>
|
|
)
|
|
}
|
|
|
|
/** 13px, semibold, quiet until hovered; another host opens in a new tab. */
|
|
function NavLink({ href, active, children }: { href: string; active?: boolean; children: ReactNode }) {
|
|
const external = href.startsWith('http')
|
|
return (
|
|
<Link href={href as Href} {...(external && { target: '_blank' })} style={{ textDecorationLine: 'none' }}>
|
|
<Text fontSize={13} fontWeight="600" px="$3" py="$2" rounded="$3" color={active ? '$color12' : '$color11'} hoverStyle={{ color: '$color12', bg: '$color2' }} pressStyle={{ opacity: 0.5 }}>
|
|
{children}
|
|
</Text>
|
|
</Link>
|
|
)
|
|
}
|