import type { ElementType, ReactNode } from "react"; import { motion } from "framer-motion"; import { ArrowRight } from "@phosphor-icons/react"; const ATTENTION_STAGGER_MAX = 8; const ATTENTION_STAGGER_STEP = 0.04; export type AttentionTone = "warn" | "danger" | "info" | "neutral"; export interface AttentionRowProps { icon: ElementType; tone?: AttentionTone; title: ReactNode; subtitle?: ReactNode; onClick?: () => void; index?: number; rightMeta?: ReactNode; iconColor?: string; iconTileBg?: string; rowBgClass?: string; borderAccentClass?: string; showArrow?: boolean; iconWeight?: "fill" | "bold" | "regular"; } const toneIconClass: Record = { warn: "text-warning", danger: "text-destructive", info: "text-primary", neutral: "text-muted-foreground", }; const toneBgClass: Record = { warn: "bg-warning-muted", danger: "bg-destructive-muted", info: "bg-accent", neutral: "bg-muted", }; export function AttentionRow({ icon: Icon, tone = "neutral", title, subtitle, onClick, index = 0, rightMeta, iconColor, iconTileBg, rowBgClass, borderAccentClass, showArrow = true, iconWeight, }: AttentionRowProps) { const iconClass = iconColor ? "" : toneIconClass[tone]; const bgClass = rowBgClass ?? toneBgClass[tone]; const delay = Math.min(index, ATTENTION_STAGGER_MAX) * ATTENTION_STAGGER_STEP; const borderClass = borderAccentClass ?? "border-[color:var(--destructive)] border-opacity-20 hover:border-opacity-40"; const isButton = typeof onClick === "function"; const commonClass = `focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 flex w-full items-center gap-3 rounded-lg border ${borderClass} ${bgClass} px-4 py-3 text-left transition`; const iconElement = iconTileBg ? (
) : ( ); const inner = ( <> {iconElement}
{title}
{subtitle ?
{subtitle}
: null}
{rightMeta} {showArrow ? : null} ); if (isButton) { return ( {inner} ); } return ( {inner} ); }