mirror of
https://github.com/luxfi/design.git
synced 2026-10-30 16:58:57 +00:00
Swapping the forked token layer for the inherited one silently orphaned two names. The fork declared --border-hairline (a solid #262626) and --border-card; the substrate draws every one of those boundaries with a single alpha --border, and explains at length why alpha beats a solid hex there — a solid edge reads on the page and vanishes the moment it lands on a lifted surface. Nineteen shipped files still asked for the old names: Card, Avatar, Badge, Table, Accordion, Dialog, DropdownMenu, Sheet, Toaster, seven specimen cards, and the generation prompts. An undefined custom property in `border:1px solid var(--gone)` does not fail. The declaration is invalid at computed-value time, border-color falls back to currentColor, and every one of those surfaces draws its edge in the INK colour — a stark near-white hairline on black that reads as a bold design choice rather than as nineteen broken files. They are not re-declared as aliases. Both mapped to the substrate's --border, so keeping them would be two names for one thing — exactly the duplication this package exists to remove. The components now speak the substrate's vocabulary. check-tokens gains the check that would have caught it. Check 4 proves the STYLESHEET is internally consistent and says nothing about the components, kits, specimen cards and prompts shipped beside it — which are the files a consumer actually renders. Now every var() in all 78 of them must resolve against the sheet. Mutation-proven: pointing one card back at --border-hairline fails the build. Co-authored-by: Hanzo Dev <[email protected]>
50 lines
2.0 KiB
React
50 lines
2.0 KiB
React
import React from 'react'
|
|
|
|
const listeners = new Set()
|
|
let seq = 0
|
|
|
|
/** sonner-style imperative API: toast.success('Agent started'). */
|
|
export const toast = Object.assign(
|
|
(message, opts) => emit({ message, ...opts }),
|
|
{
|
|
success: (message, opts) => emit({ message, tone: 'success', ...opts }),
|
|
error: (message, opts) => emit({ message, tone: 'error', ...opts }),
|
|
}
|
|
)
|
|
function emit(t) {
|
|
const item = { id: ++seq, tone: 'default', ...t }
|
|
listeners.forEach((l) => l(item))
|
|
return item.id
|
|
}
|
|
|
|
export function Toaster({ duration = 3500, position = 'bottom-right' }) {
|
|
const [items, setItems] = React.useState([])
|
|
React.useEffect(() => {
|
|
const add = (item) => {
|
|
setItems((cur) => [...cur, item])
|
|
setTimeout(() => setItems((cur) => cur.filter((i) => i.id !== item.id)), duration)
|
|
}
|
|
listeners.add(add)
|
|
return () => listeners.delete(add)
|
|
}, [duration])
|
|
const anchor = position === 'top-right' ? { top: 24, right: 24 } : { bottom: 24, right: 24 }
|
|
return (
|
|
<div style={{position:'fixed',zIndex:90,display:'flex',flexDirection:'column',gap:8,...anchor}}>
|
|
{items.map((i) => (
|
|
<div key={i.id} style={{
|
|
minWidth:260,maxWidth:380,padding:'12px 14px',display:'flex',alignItems:'flex-start',gap:10,
|
|
background:'var(--surface-overlay)',border:'1px solid ' + (i.tone === 'error' ? 'var(--state-error)' : 'var(--border)'),
|
|
borderRadius:'var(--radius-lg)',boxShadow:'var(--shadow-floating)',backdropFilter:'blur(16px)',
|
|
fontSize:'var(--text-sm)',color:'var(--neutral-100)',animation:'lux-slide-up-fade var(--duration-base) var(--ease-out)',
|
|
}}>
|
|
{i.tone === 'success' && <span style={{width:6,height:6,marginTop:6,borderRadius:'var(--radius-full)',background:'var(--state-online)',flexShrink:0}} />}
|
|
<span>
|
|
{i.message}
|
|
{i.description && <span style={{display:'block',marginTop:2,fontSize:'var(--text-xs)',color:'var(--neutral-500)'}}>{i.description}</span>}
|
|
</span>
|
|
</div>
|
|
))}
|
|
</div>
|
|
)
|
|
}
|