Write the site in US English
color, center, canceled, labeled, recognize and the rest, in UI text, help text, comments, docs and names (ColorInput, QrCenter). Migration 053 renames the two Site settings color CHECKs, whose names are the messages the admin shows. Kept: events.status's stored value 'cancelled' (shown as canceled), aria-labelledby, schema.org's EventCancelled, and old migrations as they ran. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
38aff34c97
commit
2ad65cdc15
60 changed files with 182 additions and 148 deletions
|
|
@ -8,10 +8,10 @@
|
|||
Which the page or record itself
|
||||
Section for a main page with a subnav, optionally one of
|
||||
its #sections
|
||||
Centre nothing, the NGU dove, or any SVG in
|
||||
Center nothing, the NGU dove, or any SVG in
|
||||
src/assets/qr (drop a file there and it's offered;
|
||||
it's embedded in the code, so downloads carry it)
|
||||
Colours the code, its background, and the dove. A warning
|
||||
Colors the code, its background, and the dove. A warning
|
||||
appears when the pair is unlikely to scan: too
|
||||
little contrast, or a light code on a dark ground
|
||||
|
||||
|
|
@ -27,13 +27,13 @@
|
|||
Codes point at SITE_ORIGIN, never at wherever this page is open,
|
||||
so one made on localhost still works on a poster.
|
||||
|
||||
Downloads are the on-screen <svg> itself: serialised for the SVG,
|
||||
Downloads are the on-screen <svg> itself: serialized for the SVG,
|
||||
drawn onto a canvas for the PNG. Neither needs a server.
|
||||
═══════════════════════════════════════════════════════════════ */
|
||||
|
||||
import { useEffect, useMemo, useRef, useState, type ReactNode } from 'react'
|
||||
|
||||
import QrCode, { QR_DOVE, QR_INK, QR_PAPER, type QrCentre } from '../../components/QrCode.tsx'
|
||||
import QrCode, { QR_DOVE, QR_INK, QR_PAPER, type QrCenter } from '../../components/QrCode.tsx'
|
||||
import { NAV_ACTIONS, PAGE_LINKS, PAGE_SECTIONS } from '../../navConfig.ts'
|
||||
import { awardHref, blogHref, eventHref, orgHref, personHref, teamHref } from '../../lib/hrefs.ts'
|
||||
import { siteUrl } from '../../lib/site.ts'
|
||||
|
|
@ -59,31 +59,31 @@ const KINDS: Array<[Kind, string]> = [
|
|||
['custom', 'A link I type'],
|
||||
]
|
||||
|
||||
/* The centres on offer: the dove, then every SVG in src/assets/qr,
|
||||
/* The centers on offer: the dove, then every SVG in src/assets/qr,
|
||||
named after its file ("ngu-circle.svg" → "Ngu circle"). Read as
|
||||
text and turned into data: URLs so they sit inside the code's own
|
||||
SVG. */
|
||||
const CENTRE_FILES = import.meta.glob<string>('../../assets/qr/*.svg', {
|
||||
const CENTER_FILES = import.meta.glob<string>('../../assets/qr/*.svg', {
|
||||
eager: true,
|
||||
query: '?raw',
|
||||
import: 'default',
|
||||
})
|
||||
|
||||
type CentreOption = { id: string; label: string; centre: (dove: string) => QrCentre }
|
||||
type CenterOption = { id: string; label: string; center: (dove: string) => QrCenter }
|
||||
|
||||
const toDataUrl = (svg: string) =>
|
||||
`data:image/svg+xml;base64,${btoa(String.fromCharCode(...new TextEncoder().encode(svg)))}`
|
||||
|
||||
const CENTRES: CentreOption[] = [
|
||||
{ id: 'none', label: 'Nothing', centre: () => null },
|
||||
{ id: 'dove', label: 'NGU dove', centre: (color) => ({ kind: 'dove', color }) },
|
||||
...Object.entries(CENTRE_FILES)
|
||||
const CENTERS: CenterOption[] = [
|
||||
{ id: 'none', label: 'Nothing', center: () => null },
|
||||
{ id: 'dove', label: 'NGU dove', center: (color) => ({ kind: 'dove', color }) },
|
||||
...Object.entries(CENTER_FILES)
|
||||
.sort(([a], [b]) => a.localeCompare(b))
|
||||
.map(([path, svg]) => {
|
||||
const name = path.split('/').pop()!.replace(/\.svg$/i, '')
|
||||
const label = name.replace(/[-_]+/g, ' ').replace(/^./, (c) => c.toUpperCase())
|
||||
const src = toDataUrl(svg)
|
||||
return { id: `file:${name}`, label, centre: () => ({ kind: 'image', src }) as QrCentre }
|
||||
return { id: `file:${name}`, label, center: () => ({ kind: 'image', src }) as QrCenter }
|
||||
}),
|
||||
]
|
||||
|
||||
|
|
@ -258,7 +258,7 @@ export default function QrCodeMaker() {
|
|||
const [path, setPath] = useState('/')
|
||||
const [section, setSection] = useState('')
|
||||
const [custom, setCustom] = useState('')
|
||||
const [centreId, setCentreId] = useState('dove')
|
||||
const [centerId, setCenterId] = useState('dove')
|
||||
const [ink, setInk] = useState(QR_INK)
|
||||
const [paper, setPaper] = useState(QR_PAPER)
|
||||
const [doveColor, setDoveColor] = useState(QR_DOVE)
|
||||
|
|
@ -283,8 +283,8 @@ export default function QrCodeMaker() {
|
|||
const target = kind === 'custom' ? typed : selected ? `${selected.path}${section}` : null
|
||||
const url = kind === 'custom' ? typed : target ? siteUrl(target) : null
|
||||
|
||||
const centreOption = CENTRES.find((c) => c.id === centreId) ?? CENTRES[0]
|
||||
const centre = centreOption.centre(doveColor)
|
||||
const centerOption = CENTERS.find((c) => c.id === centerId) ?? CENTERS[0]
|
||||
const center = centerOption.center(doveColor)
|
||||
const warning = scanWarning(ink, paper)
|
||||
|
||||
useEffect(() => setCopied(false), [url])
|
||||
|
|
@ -381,8 +381,8 @@ export default function QrCodeMaker() {
|
|||
</Select>
|
||||
)}
|
||||
|
||||
<Select id="qr-centre" label="In the centre" value={centreId} onChange={setCentreId}>
|
||||
{CENTRES.map((c) => (
|
||||
<Select id="qr-center" label="In the center" value={centerId} onChange={setCenterId}>
|
||||
{CENTERS.map((c) => (
|
||||
<option key={c.id} value={c.id}>
|
||||
{c.label}
|
||||
</option>
|
||||
|
|
@ -390,12 +390,12 @@ export default function QrCodeMaker() {
|
|||
</Select>
|
||||
|
||||
<fieldset>
|
||||
<legend className="text-sm font-medium text-body">Colours</legend>
|
||||
<legend className="text-sm font-medium text-body">Colors</legend>
|
||||
<div className="mt-2 flex flex-wrap items-end gap-5">
|
||||
<ColourInput id="qr-ink" label="Code" value={ink} onChange={setInk} />
|
||||
<ColourInput id="qr-paper" label="Background" value={paper} onChange={setPaper} />
|
||||
{centreOption.id === 'dove' && (
|
||||
<ColourInput id="qr-dove" label="Dove" value={doveColor} onChange={setDoveColor} />
|
||||
<ColorInput id="qr-ink" label="Code" value={ink} onChange={setInk} />
|
||||
<ColorInput id="qr-paper" label="Background" value={paper} onChange={setPaper} />
|
||||
{centerOption.id === 'dove' && (
|
||||
<ColorInput id="qr-dove" label="Dove" value={doveColor} onChange={setDoveColor} />
|
||||
)}
|
||||
{(ink !== QR_INK || paper !== QR_PAPER || doveColor !== QR_DOVE) && (
|
||||
<button
|
||||
|
|
@ -408,7 +408,7 @@ export default function QrCodeMaker() {
|
|||
className="pb-2 text-sm underline"
|
||||
style={{ color: accentText(BRAND) }}
|
||||
>
|
||||
Reset colours
|
||||
Reset colors
|
||||
</button>
|
||||
)}
|
||||
</div>
|
||||
|
|
@ -446,7 +446,7 @@ export default function QrCodeMaker() {
|
|||
<QrCode
|
||||
ref={svgRef}
|
||||
value={url}
|
||||
centre={centre}
|
||||
center={center}
|
||||
ink={ink}
|
||||
paper={paper}
|
||||
label={`QR code for ${url}`}
|
||||
|
|
@ -490,8 +490,8 @@ const inputClass =
|
|||
'w-full rounded-xl border border-muted/50 bg-surface px-4 py-3 text-body ' +
|
||||
'outline-none transition-colors focus:border-brand focus:ring-2 focus:ring-brand/25'
|
||||
|
||||
/* A colour well with its hex beside it, both editable. */
|
||||
function ColourInput({
|
||||
/* A color well with its hex beside it, both editable. */
|
||||
function ColorInput({
|
||||
id,
|
||||
label,
|
||||
value,
|
||||
|
|
@ -519,7 +519,7 @@ function ColourInput({
|
|||
/>
|
||||
<input
|
||||
type="text"
|
||||
aria-label={`${label} colour, as hex`}
|
||||
aria-label={`${label} color, as hex`}
|
||||
value={text}
|
||||
onChange={(e) => {
|
||||
setText(e.target.value)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue