Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 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 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 | 1x 715x 1x 3198x 2483x 715x 715x 715x 715x 2x | import { Option } from 'effect'
import type { Html, HtmlBuilder } from 'foldkit/html'
import { Message } from '@/message'
import type { Model } from '@/model'
import type { SystemOptions } from '../../core/systems/types'
import * as Copy from '../../submodels/copy'
import type { ReadoutColumn } from './columns'
import type { CellTone, ReadoutRow } from './rows'
const toneClass: Record<CellTone, string> = {
Live: 'text-ink',
Stale: 'text-muted',
Cue: 'text-cue',
}
const systemOptions = (model: Model): SystemOptions => ({
mgrsPrecision: model.settings.values.mgrsPrecision,
garsPrecision: model.settings.values.garsPrecision,
tileZoom: model.settings.values.tileZoom,
})
/** The reading for one row in one system. Click to copy. */
export const view = (
row: ReadoutRow,
column: ReadoutColumn,
model: Model,
h: HtmlBuilder<Message>,
): Html =>
Option.match(row.point(model), {
onNone: () =>
h.span(
[h.Class('block px-3 py-1 leading-5 text-faint')],
[h.span([h.AriaHidden(true)], ['—']), h.br([]), ' '],
),
onSome: point => {
const { formatter } = column
const reading = formatter.format(point, systemOptions(model))
const cellId = `${row.id}-${formatter.id}`
return h.submodel({
slotId: `copy-${cellId}`,
model: model.copy,
view: Copy.view,
viewInputs: {
cellId,
text: reading.copyText,
ariaLabel: `${row.label} ${formatter.label}: ${reading.copyText}. Copy`,
lines: reading.lines,
toneClass: toneClass[row.tone(model)],
},
toParentMessage: message => Message.GotCopyMessage({ message }),
})
},
})
|