import type { UnitList } from '../api'; import { useText } from '../i18n/text'; import { Callout } from '../ui/Callout'; import { Loaded } from './Loaded'; import { noteTone } from './format'; import styles from './Reader.module.css'; interface Props { /** Codes, not names, and they come from the book's data — see the note on the columns below. */ sourceLang?: string; targetLang?: string; units: Parameters>[0]['query']; } /** * Two columns with NO scroll synchronisation: one scroll container, and the columns sit inside the * row of a pair — then they physically cannot drift apart (STACK_DECISIONS §2). The unit of a pair * is the export's edit unit, and a whole chapter is sometimes a single block. * * The columns are told apart by ONE device — a hairline down the gutter (owner's remark 9), drawn * on the sheet rather than per block: a rule repeated on every pair breaks into dashes at the gaps * between them, which reads as a table rather than as two columns. */ export function Reader({ sourceLang, targetLang, units }: Props) { const text = useText(); return ( data.units.length === 0} empty={{ title: text('reader.emptyTitle'), description: text('reader.emptyDescription'), }} > {(data) => ( // tabIndex: a scrollable region has to be reachable from the keyboard, or the chapter can // only be paged with a mouse. Found by the axe pass over the OPEN state — the route gate // never saw it, because on its frame the text did not overflow the panel.
{data.units.map((unit) => { const columns = (
{unit.source}
{unit.target === undefined || unit.target === '' ? ( {text('reader.missingTarget')} ) : ( unit.target )}
); return unit.note ? ( {columns} ) : (
{columns}
); })}
)}
); }