CardFields.tsx 1.1 KB

1234567891011121314151617181920212223242526
  1. import type { CardProjection } from "@/lib/types";
  2. interface Props {
  3. card: CardProjection;
  4. className?: string;
  5. }
  6. /**
  7. * Shared business-card field hierarchy for both the canvas and mobile timeline.
  8. * The backend owns field selection and ordering; this component only renders it.
  9. */
  10. export function CardFields({ card, className = "" }: Props) {
  11. if (!card.primary && !card.secondary.length) return null;
  12. const classes = ["cardFields", className].filter(Boolean).join(" ");
  13. return <div className={classes}>
  14. {card.primary ? <CardField label={card.primary.label} value={card.primary.value} primary /> : null}
  15. {card.secondary.map((field) => <CardField key={field.key} label={field.label} value={field.value} tone={field.tone} />)}
  16. </div>;
  17. }
  18. function CardField({ label, value, primary = false, tone = "normal" }: { label?: string; value: string; primary?: boolean; tone?: "normal" | "success" | "warning" | "failure" }) {
  19. return <div className={`cardField ${primary ? "cardFieldPrimary" : "cardFieldSecondary"} tone-${tone}`}>
  20. {label ? <b>{label}</b> : null}
  21. <p>{value}</p>
  22. </div>;
  23. }