mirror of
https://github.com/hanzoai/design.git
synced 2026-10-30 14:58:37 +00:00
Controls came off the neutral ladder and stopped shouting. --border-control was --neutral-500: a 1px #737373 box around every field, four times heavier than the hairline beside it, which is what made a form read as a debug overlay rather than a surface. It is now rgb(255 255 255 / .15) — the reference's own --input-border — and --border-focus (.22) and --input follow it onto the alpha ladder, so the whole control surface is one quiet system. --border-selected (.30) names the rung that was missing: the CHOSEN thing. The 3:1 gate that forced the grey is gone from --border-control and kept on --ring, which is the only boundary that earns it. A resting edge is an affordance you can hunt for; a focus ring is a position you navigate by. On the alpha ladder --ring still clears the floor (3.67:1 dark, 3.85:1 light) BECAUSE it composites — on a lifted surface the ring lifts with it, which a fixed grey cannot do. Then the part that was actually missing: light. You cannot cast a shadow onto black, so elevation here is an edge, an inset top HIGHLIGHT and a wide dark drop, composed at the use site. The highlight is the piece that turns a coloured rectangle into a surface. --bloom is where "alive" comes from in a brand with no hue, --sheen-edge dissolves a top hairline before it reaches either corner, and --ease-emphasis lands a panel decided rather than drifting. Surfaces were not surfaces. --surface-card composited to #101010 on a #0a0a0a page — six levels above it — so three cards read as one flat field with rules across it; --surface-overlay was the page at 95% of the page, so nothing floated. Recut from #262626 they land on 14/18/1f, and a panel is a panel. Every state now moves. --secondary-hover resolved to its own resting value, --primary-hover dropped 16% and read as the button going disabled under the cursor, an unfilled button's hover stepped its edge .15 -> .16 and a hovered field did the same — states nobody could see, which is dead code with a stylesheet around it. --destructive was #666666, indistinguishable from a disabled control; it is --state-error now, because "delete everything" and "you cannot click this" must not be the same colour, and the invalid-field state was already spending that token. Verified by looking: the kit rendered in Chromium at 390/768/1280 in both themes, no overflow, tap targets and field sizes hold, and :focus-visible confirmed from a real Tab rather than a programmatic focus(). Co-authored-by: Hanzo Dev <[email protected]>
59 lines
3.0 KiB
React
59 lines
3.0 KiB
React
import React from 'react'
|
|
|
|
const Ctx = React.createContext({ value: null, setValue: () => {} })
|
|
|
|
export function Tabs({ defaultValue, value, onValueChange, style, children, ...rest }) {
|
|
const [inner, setInner] = React.useState(defaultValue)
|
|
const v = value === undefined ? inner : value
|
|
const setValue = (n) => { if (value === undefined) setInner(n); onValueChange && onValueChange(n) }
|
|
return (
|
|
<Ctx.Provider value={{ value: v, setValue }}>
|
|
<div style={{display:'flex',flexDirection:'column',gap:16,...style}} {...rest}>{children}</div>
|
|
</Ctx.Provider>
|
|
)
|
|
}
|
|
|
|
export function TabsList({ style, children, ...rest }) {
|
|
return (
|
|
// alignSelf: a segmented control is as wide as its segments. Without it the
|
|
// list is a flex ITEM of the Tabs column and stretches to the full row,
|
|
// which turns a compact control into a full-width bar.
|
|
<div role="tablist" style={{display:'inline-flex',alignSelf:'flex-start',maxWidth:'100%',overflowX:'auto',alignItems:'center',gap:2,padding:3,borderRadius:'var(--radius-lg)',background:'var(--surface-2)',border:'1px solid var(--border)',...style}} {...rest}>{children}</div>
|
|
)
|
|
}
|
|
|
|
export function TabsTrigger({ value, style, children, ...rest }) {
|
|
const { value: active, setValue } = React.useContext(Ctx)
|
|
const [hover, setHover] = React.useState(false)
|
|
const on = active === value
|
|
return (
|
|
<button
|
|
role="tab" aria-selected={on} onClick={() => setValue(value)}
|
|
onMouseEnter={() => setHover(true)} onMouseLeave={() => setHover(false)}
|
|
style={{
|
|
display:'inline-flex',alignItems:'center',gap:8,height:30,padding:'0 14px',
|
|
fontFamily:'var(--font-sans)',fontSize:'var(--text-sm)',fontWeight:'var(--weight-medium)',
|
|
letterSpacing:'var(--tracking-tight)',
|
|
color: on ? 'var(--text-primary)' : hover ? 'var(--text-secondary)' : 'var(--text-helper)',
|
|
// The selected tab is a surface that has RISEN out of the track: it
|
|
// lifts a rung, catches the light on its top edge and casts a small
|
|
// drop. A selected tab that only changes colour reads as a link that
|
|
// happens to be a different grey.
|
|
background: on ? 'var(--surface-3)' : 'transparent',
|
|
border:'1px solid ' + (on ? 'var(--border-strong)' : 'transparent'),
|
|
boxShadow: on ? 'var(--edge-highlight), var(--shadow-sm)' : 'none',
|
|
borderRadius:'calc(var(--radius-lg) - 3px)',cursor:'pointer',whiteSpace:'nowrap',
|
|
transition:'color var(--duration-fast) var(--ease-out), background-color var(--duration-fast) var(--ease-out), border-color var(--duration-fast) var(--ease-out), box-shadow var(--duration-fast) var(--ease-out), transform var(--duration-press) var(--ease-out)',
|
|
...style,
|
|
}}
|
|
{...rest}
|
|
>{children}</button>
|
|
)
|
|
}
|
|
|
|
export function TabsContent({ value, style, children, ...rest }) {
|
|
const { value: active } = React.useContext(Ctx)
|
|
if (active !== value) return null
|
|
return <div role="tabpanel" style={style} {...rest}>{children}</div>
|
|
}
|