The Coline design system: accessible React components for Coline Apps, themed live by the host workspace, and for Coline Sites in light and dark. Tailwind v4 stylesheet included. MIT.
| 5 | import { cn } from "../lib/utils"; |
| 6 | import { staggerDelay, transitions } from "../lib/motion"; |
| 7 |
| 8 | export interface TimelineItem { |
| 9 | id: string; |
| 10 | title: React.ReactNode; |
| 11 | description?: React.ReactNode; |
| 12 | time?: React.ReactNode; |
| 13 | icon?: React.ReactNode; |
| 14 | tone?: "default" | "positive" | "attention" | "risk" | "info"; |
| 15 | } |
| 16 |
| 17 | const DOT = { |
| 18 | default: "bg-muted-foreground/40", |
| 19 | positive: "bg-positive", |
| 20 | attention: "bg-attention", |
| 21 | risk: "bg-risk", |
| 22 | info: "bg-action", |
| 23 | } as const; |
| 24 |
| 25 | /** An activity feed: who did what, when, newest first. */ |
| 26 | export function Timeline({ items, className }: { items: TimelineItem[]; className?: string }) { |
| 27 | return ( |
| 28 | <ol className={cn("relative flex flex-col", className)}> |
| 29 | {items.map((item, index) => ( |
| 30 | <motion.li |
| 31 | key={item.id} |
| 32 | initial={{ opacity: 0, x: -4 }} |
| 33 | animate={{ opacity: 1, x: 0 }} |
| 34 | transition={{ ...transitions.enter, delay: staggerDelay(index) }} |
| 35 | className="relative flex gap-3 pb-5 last:pb-0" |
| 36 | > |
| 37 | {index < items.length - 1 ? ( |
| 38 | <span aria-hidden="true" className="absolute top-6 bottom-0 left-[11px] w-px bg-border" /> |
| 39 | ) : null} |
| 40 | <span className="relative flex size-6 shrink-0 items-center justify-center"> |
| 41 | {item.icon ? ( |
| 42 | <span className="flex size-6 items-center justify-center rounded-full bg-muted text-muted-foreground [&_svg]:size-3.5"> |
| 43 | {item.icon} |
| 44 | </span> |
| 45 | ) : ( |
| 46 | <span className={cn("size-2 rounded-full ring-4 ring-background", DOT[item.tone ?? "default"])} /> |
| 47 | )} |
| 48 | </span> |
| 49 | <div className="min-w-0 flex-1 pt-0.5"> |
| 50 | <div className="flex items-baseline justify-between gap-3"> |
| 51 | <p className="min-w-0 text-sm text-foreground">{item.title}</p> |
| 52 | {item.time ? <span className="shrink-0 text-xs text-muted-foreground tabular-nums">{item.time}</span> : null} |
| 53 | </div> |
| 54 | {item.description ? <div className="mt-0.5 text-sm text-muted-foreground">{item.description}</div> : null} |
| 55 | </div> |
| 56 | </motion.li> |
| 57 | ))} |
| 58 | </ol> |
| 59 | ); |
| 60 | } |
| 61 |