BranchSwitcher
Steps between the versions of an answer. It hides itself when there is only one.
SourcePackage @weft-js/warp
Preview
tsx
import { state } from '@weft-js/core'import { BranchSwitcher, Prose, Row, Stack, Text } from '@weft-js/warp'export function Versions() { const at = state(1) return ( <Stack gap="related"> <Prose text={VERSIONS[at.value]!} /> <Row gap="related"> <Text role="caption" subtle>Regenerated twice</Text> <BranchSwitcher index={at.value} count={VERSIONS.length} onChange={i => (at.value = i)} /> </Row> </Stack> )}const VERSIONS = [ 'Lower `attempts` to 2 and redeploy. The old value passed every check.', 'Roll back to `d-4801` first, then fix the retry settings on a branch.', 'Keep five attempts, but stop retrying once a request has taken 3 seconds.',]Installation
npm install @weft-js/warpUsage
tsx
import { BranchSwitcher } from '@weft-js/warp'Accessibility
- Each change announces "Version 2 of 3".
API Reference
| Prop | Type | Default | Description |
|---|---|---|---|
index | number | — | The version on show, counting from 0. |
count | number | — | How many versions there are. |
| Event | Type | Default | Description |
|---|---|---|---|
onChange | (index: number) => void | — | Called with the new index. |
RelatedMessage actionsAssistant