Files
gui/apps/gui.hanzo.ai/features/studio/theme/StudioThemeBuilderSettingsDropdown.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

161 lines
3.9 KiB
TypeScript

import { Check, LogOut, Menu } from '@hanzogui/lucide-icons-2'
import {
Button,
Checkbox,
H6,
Label,
ListItem,
Paragraph,
Popover,
YGroup,
YStack,
} from '@hanzo/gui'
import type { ThemeBuilderStore } from '~/features/studio/theme/store/ThemeBuilderStore'
import { useThemeBuilderStore } from '~/features/studio/theme/store/ThemeBuilderStore'
import { weakKey } from '~/helpers/weakKey'
import type { WritableKeysOf } from './types'
export const StudioThemeBuilderSettingsDropdown = () => {
return (
<Popover
size="$5"
allowFlip
placement="bottom"
stayInFrame={{
padding: 10,
}}
>
<Popover.Trigger asChild>
<Button size="$2" scaleIcon={1.5} chromeless circular icon={Menu}></Button>
</Popover.Trigger>
<Popover.Content
borderWidth="$0.5"
borderColor="$borderColor"
p={0}
trapFocus={false}
enterStyle={{ y: -10, opacity: 0 }}
exitStyle={{ y: -10, opacity: 0 }}
elevate
maxW={400}
transition={[
'quickest',
{
opacity: {
overshootClamping: true,
},
},
]}
>
<Popover.ScrollView>
<YGroup self="center" width={320} size="$4">
<H6 size="$1" lineHeight={10} pt="$3" pb="$2" px="$3">
Quick Settings
</H6>
{menuItems.settings.map((item) => {
return <MenuItem key={weakKey(item)} item={item} />
})}
<H6 size="$1" lineHeight={10} pt="$3" pb="$2" px="$3">
Menu
</H6>
{menuItems.items.map((item) => {
return <MenuItem key={weakKey(item)} item={item} />
})}
</YGroup>
</Popover.ScrollView>
<Popover.Arrow borderWidth={1} style={{ zIndex: 1 }} borderColor="$borderColor" />
</Popover.Content>
</Popover>
)
}
const MenuItem = ({ item }: { item: MenuItem }) => {
const store = useThemeBuilderStore()
return (
<YGroup.Item>
<ListItem
icon={item.icon}
justify="flex-start"
size="$4"
title={item.title}
onPress={item.onPress as any}
{...(!item.title && {
p: 0,
})}
>
{Boolean(item.label || item.description) && (
<Label flex={1} p="$3" gap="$4" htmlFor={weakKey(item)}>
{item.type === 'toggle' && (
<Checkbox
checked={!!store[item.toggleProperty]}
onCheckedChange={(val) => {
store[item.toggleProperty as any] = !!val
}}
id={weakKey(item)}
>
<Checkbox.Indicator>
<Check />
</Checkbox.Indicator>
</Checkbox>
)}
<YStack flex={1}>
<Paragraph>{item.label}</Paragraph>
{!!item.description && (
<Paragraph color="$color10" size="$2">
{item.description}
</Paragraph>
)}
</YStack>
</Label>
)}
</ListItem>
</YGroup.Item>
)
}
type MenuItemBase = {
title?: string
label?: string
description?: string
icon?: any
onPress?: Function
}
type MenuItemToggle = MenuItemBase & {
type: 'toggle'
toggleProperty: WritableKeysOf<ThemeBuilderStore>
}
type MenuItemItem = MenuItemBase & {
type: 'item'
}
type MenuItem = MenuItemItem | MenuItemToggle
const menuItems = {
settings: [
{
type: 'toggle',
label: 'Explanations',
toggleProperty: 'showExplanationSteps',
description: 'Show steps explaining themes in depth',
},
],
items: [
{
type: 'item',
title: 'Logout',
icon: LogOut,
async onPress() {
// TODO
alert('todo')
// await getAuth()?.signOut()
window.location.reload()
},
},
],
} satisfies Record<'settings' | 'items', MenuItem[]>