update
This commit is contained in:
1 parent
740d0812ee
commit
97033dfabd
68 files changed
+2608
-328
No files matched your search
@@ -8,22 +8,25 @@ export function Panel({
|
||||
className = "",
|
||||
tone = "plain",
|
||||
}: {
|
||||
title: string;
|
||||
title?: string;
|
||||
eyebrow?: string;
|
||||
children: ReactNode;
|
||||
action?: ReactNode;
|
||||
className?: string;
|
||||
tone?: "plain" | "surface";
|
||||
}) {
|
||||
const hasHeader = Boolean(title || eyebrow || action);
|
||||
return (
|
||||
<section className={`space-y-4 ${className}`}>
|
||||
<div className={`flex items-end justify-between gap-4 ${tone === "surface" ? "border-b border-border pb-3" : ""}`}>
|
||||
<div>
|
||||
{eyebrow ? <div className="mb-1 text-[11px] font-semibold uppercase tracking-[0.08em] text-primary">{eyebrow}</div> : null}
|
||||
<h2 className="text-[20px] font-bold tracking-[-0.025em] text-foreground">{title}</h2>
|
||||
{hasHeader ? (
|
||||
<div className={`flex items-end justify-between gap-4 ${tone === "surface" ? "border-b border-border pb-3" : ""}`}>
|
||||
<div>
|
||||
{eyebrow ? <div className="mb-1 text-[11px] font-semibold uppercase tracking-[0.08em] text-primary">{eyebrow}</div> : null}
|
||||
{title ? <h2 className="text-[15px] font-semibold tracking-[-0.01em] text-foreground">{title}</h2> : null}
|
||||
</div>
|
||||
{action}
|
||||
</div>
|
||||
{action}
|
||||
</div>
|
||||
) : null}
|
||||
<div>{children}</div>
|
||||
</section>
|
||||
);
|
||||
|
||||
@@ -97,20 +97,48 @@ export function ListRow({
|
||||
children,
|
||||
className = "",
|
||||
onClick,
|
||||
ariaLabel,
|
||||
}: {
|
||||
children: ReactNode;
|
||||
className?: string;
|
||||
onClick?: () => void;
|
||||
/**
|
||||
* Optional accessible name for the row. Required whenever the row's visible
|
||||
* children don't already include readable text (e.g. icon-only or graphic
|
||||
* rows). Omit when children already provide a textual label.
|
||||
*/
|
||||
ariaLabel?: string;
|
||||
}) {
|
||||
if (onClick) {
|
||||
// Use role="button" on a div (instead of a native <button>) so callers can
|
||||
// nest real <button> elements inside for per-action controls (edit, delete,
|
||||
// status pills). Nested <button> inside <button> is invalid HTML.
|
||||
//
|
||||
// `has-[[data-row-action]:hover]:bg-transparent` suppresses the row's
|
||||
// hover bg when the pointer is actually over an inner action cluster
|
||||
// (marked with `data-row-action`). This way hover tells the user where
|
||||
// the click lands: on the row, or on the action — never both at once.
|
||||
return (
|
||||
<button
|
||||
type="button"
|
||||
className={`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 block w-full border-b border-border px-5 py-4 text-left last:border-b-0 ${className}`}
|
||||
<div
|
||||
role="button"
|
||||
tabIndex={0}
|
||||
aria-label={ariaLabel}
|
||||
className={`block w-full cursor-pointer border-b border-border px-5 py-4 text-left transition-colors last:border-b-0 hover:bg-muted/50 has-[[data-row-action]:hover]:bg-transparent focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-inset ${className}`}
|
||||
onClick={onClick}
|
||||
onKeyDown={(event) => {
|
||||
// Only handle keys that originated on the row itself. Without this
|
||||
// guard, Space/Enter dispatched from a nested <button> (e.g. an
|
||||
// action pill) would bubble up, get preventDefault'd, and trigger
|
||||
// the row's onClick — swallowing the inner button's own activation.
|
||||
if (event.target !== event.currentTarget) return;
|
||||
if (event.key === "Enter" || event.key === " ") {
|
||||
event.preventDefault();
|
||||
onClick();
|
||||
}
|
||||
}}
|
||||
>
|
||||
{children}
|
||||
</button>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
return <div className={`border-b border-border px-5 py-4 last:border-b-0 ${className}`}>{children}</div>;
|
||||
|
||||
Reference in new issue
Block a user