Following
Wraps a surface that follows another person's view. Scroll or Esc stops it.
SourcePackage @weft-js/warp
Preview
tsx
import { state } from '@weft-js/core'import { Card, Following, Heading, PresenceStack, Row, Stack, Text } from '@weft-js/warp'import type { Peer } from '@weft-js/warp'export function FollowingPeer() { const peer = state<Peer | null>(null) return ( <Stack gap="related"> <Row justify="between"> <Text subtle>Press an avatar to follow them.</Text> <PresenceStack peers={IN_CHANNEL} following={peer.value?.id} onFollow={p => (peer.value = p)} /> </Row> <Following peer={peer.value} onStop={() => (peer.value = null)}> <Card> <Stack gap="related"> <Heading level={3}>Rollback runbook</Heading> <Text subtle>When a deploy fails its health check, roll back first and read the logs second. A failed deploy never blocks the next one.</Text> </Stack> </Card> </Following> </Stack> )}const PEOPLE = [ { id: 'mara', name: 'Mara Lindqvist', email: 'mara@weft.dev', role: 'Owner', team: 'Platform', initials: 'ML' }, { id: 'jun', name: 'Jun Tanaka', email: 'jun@weft.dev', role: 'Admin', team: 'Platform', initials: 'JT' }, { id: 'priya', name: 'Priya Raman', email: 'priya@weft.dev', role: 'Member', team: 'Web', initials: 'PR' }, { id: 'tomas', name: 'Tomás Oliveira', email: 'tomas@weft.dev', role: 'Member', team: 'Web', initials: 'TO' }, { id: 'lena', name: 'Lena Fischer', email: 'lena@weft.dev', role: 'Member', team: 'Data', initials: 'LF' }, { id: 'noor', name: 'Noor Haddad', email: 'noor@weft.dev', role: 'Viewer', team: 'Data', initials: 'NH' }, { id: 'sam', name: 'Sam Okafor', email: 'sam@weft.dev', role: 'Member', team: 'Mobile', initials: 'SO' }, { id: 'ines', name: 'Inés Vidal', email: 'ines@weft.dev', role: 'Viewer', team: 'Mobile', initials: 'IV' },]const PEERS: Peer[] = PEOPLE.map((p, i) => ({ id: p.id, name: p.name, color: i + 1 }))const [MARA, JUN, PRIYA, TOMAS, LENA, NOOR, SAM, INES] = PEERS as [Peer, Peer, Peer, Peer, Peer, Peer, Peer, Peer]const IN_CHANNEL = [SAM, JUN, LENA]Installation
npm install @weft-js/warpUsage
tsx
import { Following } from '@weft-js/warp'Accessibility
- Esc
- Stops following
API Reference
| Prop | Type | Default | Description |
|---|---|---|---|
peer | Peer | null | — | Who is followed, or null. |
top | number | — | Their viewport's top, from 0 to 1. |
children | unknown | — | What it contains. |
| Event | Type | Default | Description |
|---|---|---|---|
onStop | () => void | — | Called on a scroll or Esc. |
RelatedPresence stackAuto track