Activity feed
A project’s recent activity as a timeline: days as Headings, each event on a vertical rail with an icon for its kind, an initials avatar, the actor, the action and a Link to what changed. A comment quotes into a Card, a push shows its diff in a Pre, and a Button loads the earlier day.
Activity
Tidewater mobile app · all branches
Merged pull request: Priya Natarajan merged #482 Offline sync for drafts into main
Commits: Tomás Oliveira pushed 2 commits to feature/offline-sync
src/sync/queue.ts- const retries = 3+ const retries = navigator.onLine ? 3 : Infinity+ await queue.persist()Comment: Ama Mensah commented on #477 Crash when rotating during upload
Reproduced on the Pixel 9 build. The upload task outlives the view; holding it in the queue fixes it.
Deployment: Release bot deployed build 2.8.1‑rc.2 to staging
Issue opened: Hannah Kim opened #481 Search ignores accented characters
Release: Priya Natarajan published v2.8.0 to the App Store and Play Store
Source · recipes/activity-feed.tsx
'use client'
import { Body, BodySmall, Button, Card, Code, Heading, Link, Pre, Stack, Text } from '@blocks/design-system'
import { CircleDot, GitCommitHorizontal, GitMerge, type LucideIcon, MessageSquare, Rocket, Tag } from 'lucide-react'
import { useEffect, useId, useRef, useState } from 'react'
import styles from './activity-feed.module.css'
type Kind = 'merge' | 'commit' | 'comment' | 'issue' | 'deploy' | 'release'
interface ActivityEvent {
id: string
kind: Kind
actor: string
action: string
target: { label: string; href: string }
detail?: string
/** ISO time for `<time dateTime>`; `ago` is how it reads at 12:30 UTC on December 2. */
time: string
ago: string
quote?: string
diff?: { file: string; lines: string[] }
}
interface Day {
label: string
date: string
events: ActivityEvent[]
}
const kinds: Record<Kind, { icon: LucideIcon; label: string }> = {
merge: { icon: GitMerge, label: 'Merged pull request' },
commit: { icon: GitCommitHorizontal, label: 'Commits' },
comment: { icon: MessageSquare, label: 'Comment' },
issue: { icon: CircleDot, label: 'Issue opened' },
deploy: { icon: Rocket, label: 'Deployment' },
release: { icon: Tag, label: 'Release' },
}
const recent: Day[] = [
{
label: 'Today',
date: '2026-12-02',
events: [
{
id: 'merge-482',
kind: 'merge',
actor: 'Priya Natarajan',
action: 'merged',
target: { label: '#482 Offline sync for drafts', href: '#pull-482' },
detail: 'into main',
time: '2026-12-02T11:43:00Z',
ago: '47 minutes ago',
},
{
id: 'commit-9f3c2e1',
kind: 'commit',
actor: 'Tomás Oliveira',
action: 'pushed 2 commits to',
target: { label: 'feature/offline-sync', href: '#branch-offline-sync' },
time: '2026-12-02T10:58:00Z',
ago: '1 hour ago',
diff: {
file: 'src/sync/queue.ts',
lines: ['- const retries = 3', '+ const retries = navigator.onLine ? 3 : Infinity', '+ await queue.persist()'],
},
},
{
id: 'comment-477',
kind: 'comment',
actor: 'Ama Mensah',
action: 'commented on',
target: { label: '#477 Crash when rotating during upload', href: '#issue-477' },
time: '2026-12-02T09:15:00Z',
ago: '3 hours ago',
quote: 'Reproduced on the Pixel 9 build. The upload task outlives the view; holding it in the queue fixes it.',
},
{
id: 'deploy-staging',
kind: 'deploy',
actor: 'Release bot',
action: 'deployed',
// A non-breaking hyphen (U+2011) keeps the version on one line.
target: { label: 'build 2.8.1‑rc.2', href: '#build-2-8-1-rc-2' },
detail: 'to staging',
time: '2026-12-02T08:30:00Z',
ago: '4 hours ago',
},
],
},
{
label: 'Yesterday',
date: '2026-12-01',
events: [
{
id: 'issue-481',
kind: 'issue',
actor: 'Hannah Kim',
action: 'opened',
target: { label: '#481 Search ignores accented characters', href: '#issue-481' },
time: '2026-12-01T17:22:00Z',
ago: 'Yesterday at 17:22',
},
{
id: 'release-2-8-0',
kind: 'release',
actor: 'Priya Natarajan',
action: 'published',
target: { label: 'v2.8.0', href: '#release-2-8-0' },
detail: 'to the App Store and Play Store',
time: '2026-12-01T15:04:00Z',
ago: 'Yesterday at 15:04',
},
],
},
]
const earlier: Day = {
label: 'Monday, November 30',
date: '2026-11-30',
events: [
{
id: 'comment-479',
kind: 'comment',
actor: 'Tomás Oliveira',
action: 'commented on',
target: { label: '#479 Draft autosave interval', href: '#pull-479' },
time: '2026-11-30T16:40:00Z',
ago: 'Nov 30 at 16:40',
quote: 'Five seconds felt jumpy on slow networks. Trying ten with a save on blur.',
},
{
id: 'merge-478',
kind: 'merge',
actor: 'Hannah Kim',
action: 'merged',
target: { label: '#478 Accessible labels for the composer', href: '#pull-478' },
detail: 'into main',
time: '2026-11-30T10:05:00Z',
ago: 'Nov 30 at 10:05',
},
],
}
function initials(name: string) {
return name
.split(' ')
.map((part) => part[0])
.join('')
}
export default function ActivityFeed() {
const [showEarlier, setShowEarlier] = useState(false)
const earlierHeading = useRef<HTMLHeadingElement>(null)
const id = useId()
const days = showEarlier ? [...recent, earlier] : recent
// The button goes away once everything is loaded, so focus moves to what it revealed.
useEffect(() => {
if (showEarlier) earlierHeading.current?.focus()
}, [showEarlier])
return (
<Stack as="section" gap="lg" aria-labelledby={`${id}-title`}>
<Stack gap="xxs">
<Heading as="h2" id={`${id}-title`} fontSize="xl">
Activity
</Heading>
<BodySmall color="text-muted" margin="none">
Tidewater mobile app · all branches
</BodySmall>
</Stack>
{days.map((day) => (
<Stack as="section" key={day.date} gap="md" aria-labelledby={`${id}-${day.date}`}>
<Heading
as="h3"
id={`${id}-${day.date}`}
ref={day === earlier ? earlierHeading : undefined}
tabIndex={day === earlier ? -1 : undefined}
fontSize="sm"
color="text-muted"
>
<time dateTime={day.date}>{day.label}</time>
</Heading>
<ol className={styles.timeline}>
{day.events.map((event) => {
const { icon: Icon, label } = kinds[event.kind]
return (
<li key={event.id} className={styles.event}>
<span className={styles.marker} data-kind={event.kind}>
<Icon aria-hidden size={14} />
</span>
<Stack gap="sm" dangerouslySetClassName={styles.body}>
<Stack direction="row" gap="md" align="start">
<span className={styles.avatar} aria-hidden>
{initials(event.actor)}
</span>
<Stack gap="xxs">
<Body margin="none" fontSize="sm">
<span className="visually-hidden">{label}: </span>
<Text fontSize="sm" fontWeight="semibold">
{event.actor}
</Text>{' '}
{event.action}{' '}
<Link href={event.target.href} fontSize="sm">
{event.target.label}
</Link>
{event.detail && ` ${event.detail}`}
</Body>
<BodySmall as="span" color="text-muted" margin="none" fontSize="xs">
<time dateTime={event.time}>{event.ago}</time>
</BodySmall>
</Stack>
</Stack>
{event.quote && (
<Card as="blockquote" margin="none" padding="md" backgroundColor="bg-subtle">
<BodySmall margin="none">{event.quote}</BodySmall>
</Card>
)}
{event.diff && (
<div className={styles.diff}>
<Code fontSize="xs" dangerouslySetClassName={styles.diffFile}>
{event.diff.file}
</Code>
<Pre tabIndex={0} aria-label={`Changes to ${event.diff.file}`} margin="none" dangerouslySetClassName={styles.diffBody}>
<code>
{event.diff.lines.map((line) => (
<span key={line} className={styles.line} data-change={line[0] === '+' ? 'added' : 'removed'}>
{line}
</span>
))}
</code>
</Pre>
</div>
)}
</Stack>
</li>
)
})}
</ol>
</Stack>
))}
{showEarlier ? (
<Stack align="center">
<BodySmall color="text-muted" margin="none">
That’s everything from the last three days.
</BodySmall>
</Stack>
) : (
<Button type="button" onClick={() => setShowEarlier(true)}>
Load earlier activity
</Button>
)}
</Stack>
)
}How it works
- Structure first. Each day is a section labelled by its heading, and each day’s events are an ordered list. Every time is a
<time dateTime>element, so “47 minutes ago” keeps its exact moment for machines and assistive technology. - Icons don’t carry meaning alone. The event-kind icon and the avatar are hidden from screen readers; a visually hidden prefix (“Merged pull request:”) states the kind, and the sentence names the actor.
- The diff is legible without color. Added and removed lines keep their
+and-signs, and the tints only reinforce them. The snippet scrolls sideways inside itself on a phone. - Loading moves focus. “Load earlier activity” disappears once everything is shown, so focus moves to the new day’s heading rather than falling back to the top of the page.
App-owned CSS
The rail, the event markers, the avatars and the diff block.
/* The rail: each event draws the line down to the next marker. */
.timeline {
display: flex;
flex-direction: column;
gap: var(--ds-space-lg);
margin: 0;
padding: 0;
list-style: none;
}
.event {
position: relative;
display: grid;
grid-template-columns: var(--ds-space-xl) minmax(0, 1fr);
gap: var(--ds-space-md);
&:not(:last-child)::before {
content: "";
position: absolute;
top: var(--ds-space-xl);
bottom: calc(var(--ds-space-lg) * -1);
left: calc(var(--ds-space-lg) - var(--ds-border-width-sm) / 2);
width: var(--ds-border-width-sm);
background-color: var(--ds-color-border-subtle);
}
}
.marker {
display: inline-flex;
align-items: center;
justify-content: center;
width: var(--ds-space-xl);
height: var(--ds-space-xl);
border: var(--ds-border-width-sm) solid var(--ds-color-border-subtle);
border-radius: var(--ds-border-radius-circle);
background-color: var(--ds-color-bg-subtle);
color: var(--ds-color-text-muted);
&[data-kind="merge"],
&[data-kind="release"] {
border-color: transparent;
background-color: var(--ds-color-accent-subtle);
color: var(--ds-color-accent-text);
}
&[data-kind="deploy"] {
border-color: transparent;
background-color: var(--ds-color-success-subtle);
color: var(--ds-color-success-text);
}
}
.body {
min-width: 0;
padding-top: var(--ds-space-xs);
}
.avatar {
display: inline-flex;
flex-shrink: 0;
align-items: center;
justify-content: center;
width: calc(var(--ds-space-lg) + var(--ds-space-md));
height: calc(var(--ds-space-lg) + var(--ds-space-md));
border-radius: var(--ds-border-radius-circle);
background-color: var(--ds-color-surface-active);
color: var(--ds-color-text);
font-size: var(--ds-font-size-xxs);
font-weight: var(--ds-font-weight-semibold);
}
.diff {
overflow: hidden;
border: var(--ds-border-width-sm) solid var(--ds-color-border-subtle);
border-radius: var(--ds-border-radius-md);
}
.diffFile {
display: block;
padding: var(--ds-space-sm) var(--ds-space-md);
border-bottom: var(--ds-border-width-sm) solid var(--ds-color-border-subtle);
background-color: var(--ds-color-bg-subtle);
color: var(--ds-color-text-muted);
}
.diffBody {
padding: var(--ds-space-sm) 0;
font-family: var(--ds-font-monospace);
font-size: var(--ds-font-size-xs);
line-height: var(--ds-line-height-body);
& code {
display: block;
}
}
/* The +/- sign stays in the text, so the tint is never the only signal. */
/* Long lines wrap with a hanging indent, so nothing is cut off on a phone. */
.line {
display: block;
padding-inline: calc(var(--ds-space-md) + 1ch) var(--ds-space-md);
text-indent: -1ch;
white-space: pre-wrap;
overflow-wrap: anywhere;
&[data-change="added"] {
background-color: var(--ds-color-success-subtle);
}
&[data-change="removed"] {
background-color: var(--ds-color-danger-subtle);
}
}