banner · minimal · 灵感来源:GOV.UK notification banner / USWDS alert
Notification Banner · 极简提示条 · 提示条 / Minimal
做一个 Notification Banner(极简提示条):
- 同一份 props 与 role 分配
- 平底 + 一条语义色发丝边,零模糊零 inset 零阴影
- 圆角 rounded-md,关闭按钮方角
- 语义与结构同玻璃提示条
用这些 CSS 变量:--color-info-bd --color-info-bg --color-info-fg --color-success-bd --color-success-bg --color-success-fg --color-text --color-text-muted --color-text-subtle --color-warning-bd --color-warning-bg --color-warning-fg
灵感参考:GOV.UK notification banner / USWDS alert--color-info-bd --color-info-bg --color-info-fg --color-success-bd --color-success-bg --color-success-fg --color-text --color-text-muted --color-text-subtle --color-warning-bd --color-warning-bg --color-warning-fg
(无必缺状态)
(尚未接进整页场景)
/r/banner--minimal.json
免外壳的 markdown 版:/llms/components/banner--minimal.mdrole 分配、结构三段),见玻璃那支的 notesrounded-md,关闭按钮从圆形改成方角import { useState, type ReactNode } from 'react';
import { CircleCheck, Info, TriangleAlert, X } from 'lucide-react';
import { Icon } from '~/components/Icon';
interface Props {
/** 严重度:错误与警告共用一支琥珀色(和输入框的错误描边同色) */
tone?: 'info' | 'success' | 'warning';
title: string;
description?: ReactNode;
/** 一个动作:链接或按钮,放正文之后 */
action?: ReactNode;
/** 可关:常驻不等于不能收,但绝不自动消失(决策 17) */
dismissible?: boolean;
className?: string;
}
const TONE = {
info: {
icon: Info,
role: 'status' as const,
fg: 'text-[var(--color-info-fg)]',
box: 'bg-[var(--color-info-bg)] border-[var(--color-info-bd)]',
},
success: {
icon: CircleCheck,
role: 'status' as const,
fg: 'text-[var(--color-success-fg)]',
box: 'bg-[var(--color-success-bg)] border-[var(--color-success-bd)]',
},
warning: {
icon: TriangleAlert,
role: 'alert' as const,
fg: 'text-[var(--color-warning-fg)]',
box: 'bg-[var(--color-warning-bg)] border-[var(--color-warning-bd)]',
},
};
/** 极简提示条:平底 + 一条语义色发丝边,零模糊零 inset;层级靠字号,不靠阴影 */
export function MinimalBanner({
tone = 'info',
title,
description,
action,
dismissible = false,
className = '',
}: Props) {
const [hidden, setHidden] = useState(false);
const t = TONE[tone];
if (hidden) return null;
return (
<div role={t.role} className={`flex items-start gap-3 px-4 py-3.5 rounded-md border ${t.box} ${className}`}>
<Icon icon={t.icon} size={16} className={`shrink-0 mt-0.5 ${t.fg}`} />
<div className="min-w-0 flex-1">
<p className={`text-sm font-semibold ${t.fg}`}>{title}</p>
{(description || action) && (
<div className="mt-1 text-sm text-[var(--color-text-muted)] leading-relaxed">
{description}
{action && <span className="mt-2 block">{action}</span>}
</div>
)}
</div>
{dismissible && (
<button
type="button"
onClick={() => setHidden(true)}
aria-label={`关闭提示:${title}`}
className="press-feedback shrink-0 grid place-items-center size-6 -mr-1 rounded
text-[var(--color-text-subtle)] hover:text-[var(--color-text)] cursor-pointer"
>
<Icon icon={X} size={14} />
</button>
)}
</div>
);
}
src/components/banner/minimal/