agent: HeaderPill wraps Badge instead of a hand-styled pill
Badge already covers icon+label+value+onClick -- exactly HeaderPill's shape. mara, reviewing the first cut (a bespoke .header-pill matched to Badge's own CSS values): "cant we reuse the badge component". HeaderPill now renders <Badge> directly and only owns hiding at count 0 + the inbox/todos tone (amber/green on the count, same as before). Drops the now-unused .header-pill* CSS from agent.css entirely.
This commit is contained in:
parent
ad58894c25
commit
302778573d
2 changed files with 28 additions and 60 deletions
|
|
@ -1,10 +1,15 @@
|
|||
// <HeaderPill> — the inbox/todos flyout triggers in the header's right
|
||||
// cluster. Reuses agent.css's existing `.header-pill…` rules (loaded
|
||||
// globally), styled to match `@hive/shared`'s filled `Badge` pill —
|
||||
// every other chip in the same cluster is one — not the bordered
|
||||
// `.hive-pill` shape (mara: "inbox badge looks different from all the
|
||||
// other ones"). Hidden (renders nothing) at count 0, matching the old
|
||||
// page's `pill.hidden = count === 0`.
|
||||
// cluster. A thin wrapper over `@hive/shared`'s `Badge` (icon+label+
|
||||
// value+onClick already covers this shape exactly) rather than a
|
||||
// bespoke pill — mara, reviewing the first cut of this (a hand-styled
|
||||
// `.header-pill` matched to `Badge`'s own CSS values rather than the
|
||||
// component itself): "cant we reuse the badge component". Only two
|
||||
// things this wrapper still owns: hiding at count 0 (`pill.hidden =
|
||||
// count === 0` in the old page) and picking the inbox/todos tone so
|
||||
// the count reads amber/green like it always has (`Badge`'s `tone`
|
||||
// colours the value, which here is the count).
|
||||
import { Badge, type BadgeTone } from '@hive/shared/badge.js';
|
||||
|
||||
export interface HeaderPillProps {
|
||||
kind: 'inbox' | 'todos';
|
||||
icon: string;
|
||||
|
|
@ -13,15 +18,21 @@ export interface HeaderPillProps {
|
|||
onClick: () => void;
|
||||
}
|
||||
|
||||
const TONE: Record<HeaderPillProps['kind'], BadgeTone> = {
|
||||
inbox: 'warning',
|
||||
todos: 'positive',
|
||||
};
|
||||
|
||||
export function HeaderPill({ kind, icon, label, count, onClick }: HeaderPillProps) {
|
||||
if (count === 0) return null;
|
||||
return (
|
||||
<button type="button" class={`header-pill header-pill-${kind}`} onClick={onClick} title={`open ${label} flyout`}>
|
||||
<span class="header-pill-icon" aria-hidden="true">
|
||||
{icon}
|
||||
</span>
|
||||
<span class="header-pill-label">{label}</span>
|
||||
<span class="header-pill-count">{count}</span>
|
||||
</button>
|
||||
<Badge
|
||||
icon={icon}
|
||||
label={label}
|
||||
value={count}
|
||||
tone={TONE[kind]}
|
||||
onClick={onClick}
|
||||
title={`open ${label} flyout`}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue