Skip to content
kerfjsGitHub

BranchSwitcher

Steps between the versions of an answer. It hides itself when there is only one.

SourcePackage @kerf-js/veneer

Preview

tsx
import { state } from '@kerf-js/core'import {  BranchSwitcher,  Prose,  Row,  Stack,  Text} from '@kerf-js/veneer'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 @kerf-js/veneer

Usage

tsx
import { BranchSwitcher } from '@kerf-js/veneer'

Accessibility

  • Each change announces "Version 2 of 3".

API Reference

PropTypeDefaultDescription
indexnumber—The version on show, counting from 0.
countnumber—How many versions there are.
EventTypeDefaultDescription
onChange(index: number) => void—Called with the new index.

RelatedMessage actionsAssistant