File size: 1,406 Bytes
a8fb296
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import { adjacentScreens, screenLabel, type ScreenSection } from '../../utils/matrixStory'
import type { MatrixCtx } from './types'

/**
 * The end of a screen: a Continue control that names what comes next in words ("Continue: what changed since 2019") and, from
 * the second screen on, a quieter Back control that names the one before. Both are real buttons; the destination is in their
 * visible (and so accessible) name. They page the same way the keyboard does (`ctx.goTo`): scroll, focus the heading, replace
 * the URL. The last screen has no Continue; the action block gives it the way out.
 */
export default function ScreenPager({ ctx, section }: { ctx: MatrixCtx; section: ScreenSection }) {
  const { prev, next } = adjacentScreens(section)
  if (!prev && !next) return null
  return (
    <div className="folio-pager">
      {next && (
        <button type="button" className="folio-pager-next" onClick={() => ctx.goTo(next.domId)}>
          <span>Continue: {screenLabel(next.section, ctx.labelInput)}</span>
          <span aria-hidden="true" className="folio-pager-arrow">
            ↓
          </span>
        </button>
      )}
      {prev && (
        <button type="button" className="folio-pager-back" onClick={() => ctx.goTo(prev.domId)}>
          <span aria-hidden="true">↑</span> Back: {screenLabel(prev.section, ctx.labelInput)}
        </button>
      )}
    </div>
  )
}