Compare commits

..

4 commits

Author SHA1 Message Date
Zaldimmar
dad3803ccc Resolve every record image from the uploads folder
A bare image filename, whatever it belongs to (organization and event
logos, people photos, team and award logos, backgrounds, hero photos,
block images), now resolves to /uploads/<file>, in media.ts and for
link previews in pageMeta.js. The per-kind public/ folders were
guesses that don't exist. Only the site's own chosen assets, the NGU
logos in the nav, footer and admin, stay bundled from
src/assets/logos.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-27 23:29:54 -05:00
Zaldimmar
9eeb13c5ec QR tool: choose the centre, type any link, pick the colours
The centre can be nothing, the NGU dove, or any SVG dropped into
src/assets/qr, embedded in the code so downloads carry it. "A link I
type" takes a site path (sent to the live site), a full http(s)
address, or a bare domain. The code, background and dove colours can
be changed, with a warning under 4:1 contrast or for an inverted
code, which many scanners can't read.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-27 23:20:55 -05:00
Zaldimmar
9075cfb908 Show schedule maps in satellite view
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-27 23:18:32 -05:00
Zaldimmar
a67ca98394 Move the NGU logos to src/assets/logos and load event logos from uploads
The site's own logos now live in src/assets/logos. Event logos are no
longer bundled: the event cards resolve them through media.ts like
every other image, and a bare event-logo filename now means one in
the uploads directory (fall-retreat-logo.svg has been moved there by
hand). Organization logos on the cards resolve from org-logos.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-27 23:18:32 -05:00
20 changed files with 347 additions and 212 deletions

View file

@ -57,7 +57,7 @@ In dev, Vite proxies `/api` to the target set in `vite.config.ts`, so the API mu
- `navConfig.ts` is the single source of truth for navigation, routes, and actions (header, footer, pages). - `navConfig.ts` is the single source of truth for navigation, routes, and actions (header, footer, pages).
- `api.ts` is the shared caching client used by frontend data hooks. - `api.ts` is the shared caching client used by frontend data hooks.
- `docs/updating-data-in-code.md`: where content that isn't in the database lives (admin dropdown labels, fixed value lists, nav, banner, decades, map grid) and how to change it. Keep it current when adding a dropdown or code-owned content. - `docs/updating-data-in-code.md`: where content that isn't in the database lives (admin dropdown labels, fixed value lists, nav, banner, decades, map grid) and how to change it. Keep it current when adding a dropdown or code-owned content.
- Logos: org logos in `public/org-logos/` (served at `/org-logos/`), event logos in `public/event-logos/`. The `<Logo>` component hides itself on load error. - Images: every record image (logos, photos, backgrounds, block images) is an upload. A bare filename resolves to `/uploads/<file>` (`src/lib/media.ts`, and `server/src/pageMeta.js` for previews). Only the site's own chosen assets, the NGU logos in the nav, footer and admin, are bundled from `src/assets/logos/`. The `<Logo>` component hides itself on load error.
## Rules and gotchas ## Rules and gotchas
- **Role checks must use ladder comparisons, never equality.** Roles rank viewer → editor → admin → superadmin. Use the minimum-rank helpers from `src/lib/roles.ts` (`canWrite`, `canDelete`, `isSuper`, `atLeast`). Where a local variable shadows the name, import with an alias, e.g. `canWrite as roleCanWrite`. `role === "admin"` silently excludes higher roles and has caused repeated bugs. - **Role checks must use ladder comparisons, never equality.** Roles rank viewer → editor → admin → superadmin. Use the minimum-rank helpers from `src/lib/roles.ts` (`canWrite`, `canDelete`, `isSuper`, `atLeast`). Where a local variable shadows the name, import with an alias, e.g. `canWrite as roleCanWrite`. `role === "admin"` silently excludes higher roles and has caused repeated bugs.

View file

@ -27,8 +27,8 @@
/admin noindex /admin noindex
Image paths resolve like src/lib/media.ts does: a bare filename Image paths resolve like src/lib/media.ts does: a bare filename
lives in that record kind's public/ directory, anything starting is in the uploads directory, anything starting with / or a scheme
with / or a scheme is used as it is. Keep DIRS in step with it. is used as it is.
An SVG isn't used as a preview image (the big sites won't show An SVG isn't used as a preview image (the big sites won't show
one), so it falls back to the site default. one), so it falls back to the site default.
═══════════════════════════════════════════════════════════════ */ ═══════════════════════════════════════════════════════════════ */
@ -45,16 +45,9 @@ export const SITE_CONFIG = path.resolve(process.env.SITE_CONFIG ?? path.join(her
const DESCRIPTION_CHARS = 160; const DESCRIPTION_CHARS = 160;
/* Where a bare filename lives, per kind. Mirrors src/lib/media.ts. */ /* Where a bare filename lives: record images are uploads, whatever
const DIRS = { kind they are. Mirrors src/lib/media.ts. */
person: "/people", const UPLOADS = "/uploads";
eventLogo: "/event-logos",
eventBackground: "/event-backgrounds",
organization: "/org-logos",
team: "/team-logos",
award: "/award-logos",
blog: "/blog",
};
/* ── site.json, reread when it changes ─────────────────────── */ /* ── site.json, reread when it changes ─────────────────────── */
@ -94,9 +87,9 @@ const first = (...values) => values.find((v) => v != null && String(v).trim() !=
function imageUrl(site, file, kind) { function imageUrl(site, file, kind) {
if (!file || /\.svg(\?|#|$)/i.test(file)) return null; if (!file || /\.svg(\?|#|$)/i.test(file)) return null;
// A bare filename is in that kind's directory, or at the site's // A record's bare filename is an upload; the site's own default
// root for the site's own default (kind null). // image (kind null) is a path from the site's root.
const pathOrUrl = /^(https?:|\/)/.test(file) ? file : kind ? `${DIRS[kind]}/${file}` : `/${file}`; const pathOrUrl = /^(https?:|\/)/.test(file) ? file : kind ? `${UPLOADS}/${file}` : `/${file}`;
return /^https?:/.test(pathOrUrl) ? pathOrUrl : `${origin(site)}${pathOrUrl}`; return /^https?:/.test(pathOrUrl) ? pathOrUrl : `${origin(site)}${pathOrUrl}`;
} }

View file

@ -39,7 +39,7 @@
}, },
"/qr": { "/qr": {
"title": "QR Codes", "title": "QR Codes",
"description": "Codes for flyers, slides and signs, pointing at any page on the site." "description": "Codes for flyers, slides and signs, pointing at any page on the site or any link, in your choice of colours."
}, },
"/give": { "/give": {
"title": "Giving", "title": "Giving",

File diff suppressed because one or more lines are too long

Before

Width:  |  Height:  |  Size: 221 KiB

File diff suppressed because one or more lines are too long

Before

Width:  |  Height:  |  Size: 221 KiB

View file

@ -1,82 +0,0 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg
width="403.64276mm"
height="86.755943mm"
viewBox="0 0 403.64273 86.755943"
version="1.1"
id="svg5"
xmlns="http://www.w3.org/2000/svg"
xmlns:svg="http://www.w3.org/2000/svg">
<defs
id="defs2" />
<g
id="layer10"
style="display:inline"
transform="translate(-344.28592,167.60401)">
<g
id="g3">
<circle
style="display:inline;fill:#008da9;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:0.634488;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
id="path205602-8-3-1"
cx="403.82111"
cy="-121.75806"
r="40.889923" />
<path
id="path1887-1-3-7-7-6-2"
style="color:#000000;display:inline;fill:#008da9;fill-opacity:1;stroke:none;stroke-width:2.284;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
d="m 443.45159,-167.57122 c -8.63995,3.71591 -17.05927,7.97953 -25.85742,11.27148 -3.76442,1.391 -7.68514,2.52606 -11.12305,4.64648 -3.58916,2.42042 -5.95825,6.25942 -7.35135,10.29228 -1.23335,3.0863 -2.32136,6.17712 -3.84982,9.11983 -3.67393,-2.17848 -7.69746,-4.08371 -12.04108,-4.24843 -4.09333,-0.39358 -8.26381,0.55262 -11.85512,2.53592 -6.41916,3.13465 -11.92468,7.82515 -18.56868,10.51862 -2.73797,1.21486 -5.51687,2.3331 -8.27926,3.49077 -0.88252,2.47734 0.77854,5.31191 3.20508,6.10351 4.27199,1.7128 8.98018,1.56772 13.49433,1.35771 4.71612,-0.31488 9.32779,-1.47771 13.7933,-2.98449 4.28568,-1.20657 8.61172,-2.23873 13.00143,-3.03728 -2.64145,2.85774 -6.27041,4.39222 -9.272,6.78523 -0.9862,0.76271 -1.85771,1.89939 -1.64657,3.21845 0.1709,1.85512 1.7211,3.08775 2.9593,4.29677 2.6421,2.35246 5.95831,4.07918 9.49722,4.487017 1.35103,0.106385 2.71085,-0.642417 3.25697,-1.900747 1.43582,-2.68121 2.25426,-5.67671 4.35603,-7.93655 1.20099,-1.4152 3.08751,-1.77888 4.83141,-2.01081 3.79664,-0.62592 7.50391,-2.47133 9.93534,-5.50938 1.37471,-1.65305 2.10201,-3.71602 2.52235,-5.79656 0.1379,-0.6722 1.04486,-0.68506 1.58622,-0.85974 1.78218,-0.35339 3.91283,-0.77776 4.83392,-2.54366 0.89776,-1.84635 -0.0715,-4.04503 -1.61189,-5.21854 -2.41639,-1.86664 -5.65021,-3.01579 -8.63111,-2.61499 2.2258,-1.54005 4.74178,-2.58917 7.19752,-3.70372 6.31792,-2.71081 13.11161,-4.94567 18.40937,-9.54069 3.73885,-3.20962 6.79577,-7.24801 8.78271,-11.76096 0.80138,-2.0522 1.44232,-4.33553 0.95805,-6.5376 -0.3398,-1.04637 -1.34059,-2.15906 -2.5332,-1.91992 z" />
<path
id="path92116-3-2-7-1-4"
style="display:inline;fill:#ffffff;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:0.222835;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
d="m 401.4397,-85.357733 -5.07733,3.7999 c 1.40469,0.28813 3.37038,0.49431 4.1477,0.56482 0,0 13.4726,-8.14749 21.27399,-14.00284 7.80139,-5.855347 13.28514,-13.045137 15.64699,-18.030857 4.23462,-8.93904 5.76755,-17.18121 4.93866,-21.94278 -2.3532,12.13055 -6.84548,20.1394 -8.91525,22.66728 -2.77658,3.39114 -7.3818,10.79482 -14.1263,15.035397 -8.02485,5.04559 -16.87157,10.25674 -17.88846,11.90908 z" />
<path
fill="#519259"
d="m 401.25566,-85.224563 c 2.11431,-7.90893 7.29014,-19.728807 13.53049,-25.077287 3.15174,-2.74769 6.75532,-5.34691 11.45401,-7.64618 4.36158,-2.05194 6.70709,-3.73973 9.19688,-6.81027 3.40267,-3.94053 5.90574,-7.35199 6.96383,-10.47421 0.22347,8.84634 -6.48806,19.37766 -9.02864,23.54668 -6.2265,9.41606 -10.0147,12.608287 -17.50625,17.196147 -4.38236,2.60687 -9.65678,5.68615 -14.61032,9.26512 z"
fill-opacity="1"
fill-rule="nonzero"
id="path184-6-7-6-9-3-2"
style="display:inline;fill:#358a0d;fill-opacity:1;stroke:none;stroke-width:0.625031;stroke-opacity:1" />
<path
style="color:#000000;display:inline;fill:#ffffff;stroke:none;stroke-width:2.284;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
d="m 358.52422,-123.11955 c 3.13369,-1.59928 7.04147,-4.49077 10.29591,-6.33595 3.25443,-1.84519 6.30899,-3.58417 9.61426,-4.20523 2.65302,-0.4889 6.37319,-0.18817 9.07211,0.58357 2.69896,0.77175 5.57299,2.70484 7.16593,3.40762 1.59295,0.70275 2.24655,0.19006 2.82855,-0.77494 0.582,-0.96504 2.81839,-6.05064 3.84362,-8.9293 1.02519,-2.87864 2.26409,-5.72337 4.14553,-7.76121 1.88144,-2.03782 2.31893,-2.07776 4.06202,-3.15865 1.74307,-1.08086 10.24244,-3.71628 14.53403,-5.61581 4.29158,-1.89953 8.11957,-3.58996 12.24067,-5.48028 4.12109,-1.89033 6.08861,-2.79441 7.30709,-3.29554 0.273,0.73801 -0.2034,3.06663 -1.16031,5.22317 -0.95691,2.15654 -2.9569,5.04357 -4.86279,7.26365 -1.90589,2.22009 -4.28775,4.10342 -6.82223,5.66812 -2.53448,1.56467 -4.53981,2.45823 -7.60439,3.71266 -3.06457,1.25446 -11.88915,4.7102 -14.64698,7.12005 -2.75786,2.40984 -4.18313,6.63212 -3.64772,7.60115 0.5354,0.96902 2.51391,-1.48598 3.81084,-2.34867 1.29694,-0.8627 1.95172,-1.05814 3.14897,-1.09198 1.17765,-0.0172 2.77532,0.40067 3.29849,0.63293 1.48441,0.659 3.97438,2.00122 3.54176,3.36038 -0.16368,0.51434 -0.19462,0.56904 -3.05611,1.25841 -2.86151,0.68935 -3.48508,1.29579 -3.81533,3.74861 -0.22097,1.47094 -1.44719,3.88743 -3.13317,5.28015 -1.68596,1.39274 -4.55099,2.93627 -8.41717,3.35482 -3.86617,0.41855 -6.17544,3.97192 -6.93256,5.37259 -0.75713,1.40064 -2.66104,5.90506 -2.99685,6.15238 -0.3358,0.24732 -2.76998,-0.36582 -3.79458,-0.82517 -1.02463,-0.45935 -2.612,-1.39111 -3.63624,-2.16132 -1.02425,-0.7702 -3.457,-2.975 -3.0018,-3.64018 0.45519,-0.66516 1.56543,-1.35445 2.73515,-2.12254 1.16972,-0.76811 3.86984,-2.33631 5.3456,-3.59002 1.47576,-1.25372 2.7334,-2.47754 3.4042,-3.48323 0.67079,-1.00567 0.9358,-2.14286 -0.28206,-2.7388 -1.21786,-0.59597 -1.84092,-0.39835 -4.4486,0.0225 -2.60769,0.42097 -4.8218,1.10142 -8.46858,1.9005 -3.64678,0.79905 -7.82786,2.49393 -10.97221,3.07304 -3.14439,0.5791 -4.3363,0.83756 -8.5197,0.95691 -4.1834,0.11935 -7.15938,-0.35864 -8.95468,-0.91763 -1.7953,-0.55899 -2.64147,-1.55556 -2.60415,-2.17667 3.90737,-1.58574 7.9469,-3.2841 11.38348,-5.04009 z"
id="path1887-1-3-7-7-6" />
<path
fill="#519259"
d="m 412.95849,-81.884143 c 4.58067,-1.05723 7.7275,-1.9948 13.67931,-5.91343 5.95181,-3.91863 10.62995,-9.54813 13.02992,-14.097387 2.39997,-4.54926 4.34384,-10.28218 4.83384,-15.81643 0.49,-5.53425 0.14775,-11.25197 -2.10696,-17.66367 0.15927,9.10203 -2.7414,15.06092 -4.17879,18.80503 -1.43739,3.74411 -4.80196,9.50687 -8.2717,13.57264 -3.46184,4.223207 -7.82036,7.647487 -12.67981,10.383567 -5.38026,3.05578 -13.21504,8.4585 -16.7484,11.61577 4.01135,0.4226 9.12694,-0.10316 12.44259,-0.88609 z"
fill-opacity="1"
fill-rule="nonzero"
id="path182-2-6-6-7-2-2"
style="display:inline;fill:#358a0d;fill-opacity:1;stroke:none;stroke-width:0.717458;stroke-opacity:1" />
</g>
<g
id="g40616-9"
transform="translate(13.096206,-216.39844)"
style="display:inline">
<g
id="g2-4">
<text
xml:space="preserve"
style="font-size:34.109px;line-height:1.25;font-family:Impact;-inkscape-font-specification:Impact;letter-spacing:0px;word-spacing:0px;display:inline;stroke-width:0.852729"
x="451.59149"
y="89.758339"
id="text156858-3-8"><tspan
id="tspan156856-8-82"
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:34.109px;font-family:Poppins;-inkscape-font-specification:'Poppins, Normal';font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-variant-east-asian:normal;fill:#008da9;fill-opacity:1;stroke-width:0.852729"
x="451.59149"
y="89.758339">Next Generation</tspan></text>
<text
xml:space="preserve"
style="font-size:33.8136px;line-height:1.25;font-family:Impact;-inkscape-font-specification:Impact;letter-spacing:0px;word-spacing:0px;display:inline;stroke-width:0.845345"
x="469.26224"
y="119.08144"
id="text156858-3-1-4"><tspan
id="tspan156856-8-8-5"
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:33.8136px;font-family:Poppins;-inkscape-font-specification:'Poppins, Normal';font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-variant-east-asian:normal;fill:#008da9;fill-opacity:1;stroke-width:0.845345"
x="469.26224"
y="119.08144">of Unity</tspan></text>
</g>
</g>
</g>
</svg>

Before

Width:  |  Height:  |  Size: 8.4 KiB

View file

Before

Width:  |  Height:  |  Size: 15 KiB

After

Width:  |  Height:  |  Size: 15 KiB

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 8.4 KiB

After

Width:  |  Height:  |  Size: 8.4 KiB

Before After
Before After

View file

@ -1,6 +1,6 @@
import { Link } from "react-router-dom"; import { Link } from "react-router-dom";
import { PAGE_LINKS, PAGE_SECTIONS, NAV_ACTIONS } from "../navConfig.ts"; import { PAGE_LINKS, PAGE_SECTIONS, NAV_ACTIONS } from "../navConfig.ts";
import nguLogo from "../assets/NGU_Logo.svg"; import nguLogo from "../assets/logos/NGU_Logo.svg";
import PlatformIcon from "./PlatformIcon.tsx"; import PlatformIcon from "./PlatformIcon.tsx";
const Social_Links = [ const Social_Links = [

View file

@ -2,7 +2,7 @@ import { useState, useEffect, useRef } from "react";
import { NavLink, Link, Outlet, useLocation } from "react-router-dom"; import { NavLink, Link, Outlet, useLocation } from "react-router-dom";
import { PAGE_LINKS, PAGE_SECTIONS, NAV_ACTIONS } from "../navConfig.ts"; import { PAGE_LINKS, PAGE_SECTIONS, NAV_ACTIONS } from "../navConfig.ts";
import Banner from "./Banner.jsx"; import Banner from "./Banner.jsx";
import nguLogo from "../assets/NGU_Logo.svg"; import nguLogo from "../assets/logos/NGU_Logo.svg";
import Footer from "./Footer.tsx"; import Footer from "./Footer.tsx";
/* ── Right-side nav actions ──────────────────────────────── */ /* ── Right-side nav actions ──────────────────────────────── */

View file

@ -1,16 +1,25 @@
/* ═══════════════════════════════════════════════════════════════ /* ═══════════════════════════════════════════════════════════════
QR CODE QR CODE
A QR code as an <svg>, sized by its container. With `dove`, the A QR code as an <svg>, sized by its container.
NGU dove sits on a white badge over the centre; the code switches
to high error correction so the modules under the badge are
recovered when it's scanned (see lib/qr.ts). The badge covers
under 6% of the code, well inside what 'H' repairs, and never
reaches the three corner finder patterns.
Everything is drawn in the SVG itself (no CSS, no external `centre` puts something on a badge over the middle: the NGU dove,
references), so the element serialises to a file that looks the or an image (an SVG from src/assets/qr, passed as a data: URL).
same outside the page. `ref` reaches the <svg> for exactly that. With anything there, the code switches to high error correction
so the modules under the badge are recovered when it's scanned
(see lib/qr.ts). The badge covers under 6% of the code, well
inside what 'H' repairs, and never reaches the three corner
finder patterns.
`ink` is the modules and the badge's outline, `paper` the
background and the badge. A code should stay dark on light with
strong contrast to scan reliably; QrCodeMaker warns when it
doesn't, this just draws what it's given.
Everything is drawn in the SVG itself (no CSS, and an image is
embedded rather than linked), so the element serialises to a
file that looks the same outside the page. `ref` reaches the
<svg> for exactly that.
═══════════════════════════════════════════════════════════════ */ ═══════════════════════════════════════════════════════════════ */
import { useMemo, type Ref } from 'react' import { useMemo, type Ref } from 'react'
@ -23,8 +32,9 @@ import { qrMatrix, qrPath } from '../lib/qr.ts'
const MARGIN = 4 const MARGIN = 4
/* Dark enough to scan as black; the site's deep teal. */ /* Dark enough to scan as black; the site's deep teal. */
const INK = '#04262e' export const QR_INK = '#04262e'
const TEAL = '#138ba0' export const QR_PAPER = '#ffffff'
export const QR_DOVE = '#138ba0'
/* Badge side as a share of the code's width. */ /* Badge side as a share of the code's width. */
const BADGE = 0.24 const BADGE = 0.24
@ -32,21 +42,28 @@ const BADGE = 0.24
/* DoveMark's own viewBox is 72.87 × 48.57. */ /* DoveMark's own viewBox is 72.87 × 48.57. */
const DOVE_ASPECT = 72.867699 / 48.568241 const DOVE_ASPECT = 72.867699 / 48.568241
export type QrCentre = { kind: 'dove'; color?: string } | { kind: 'image'; src: string } | null
export default function QrCode({ export default function QrCode({
value, value,
dove = false, centre = null,
ink = QR_INK,
paper = QR_PAPER,
label, label,
ref, ref,
className, className,
}: { }: {
value: string value: string
dove?: boolean centre?: QrCentre
ink?: string
paper?: string
/** Accessible name for the image, e.g. "QR code for /retreats". */ /** Accessible name for the image, e.g. "QR code for /retreats". */
label: string label: string
ref?: Ref<SVGSVGElement> ref?: Ref<SVGSVGElement>
className?: string className?: string
}) { }) {
const matrix = useMemo(() => qrMatrix(value, dove ? 'H' : 'M'), [value, dove]) const level = centre ? 'H' : 'M'
const matrix = useMemo(() => qrMatrix(value, level), [value, level])
const path = useMemo(() => qrPath(matrix, MARGIN), [matrix]) const path = useMemo(() => qrPath(matrix, MARGIN), [matrix])
const total = matrix.size + MARGIN * 2 const total = matrix.size + MARGIN * 2
@ -54,6 +71,7 @@ export default function QrCode({
const badgeAt = (total - badge) / 2 const badgeAt = (total - badge) / 2
const doveWidth = badge * 0.78 const doveWidth = badge * 0.78
const doveHeight = doveWidth / DOVE_ASPECT const doveHeight = doveWidth / DOVE_ASPECT
const imageSize = badge * 0.8
return ( return (
<svg <svg
@ -65,10 +83,10 @@ export default function QrCode({
className={className} className={className}
shapeRendering="crispEdges" shapeRendering="crispEdges"
> >
<rect width={total} height={total} fill="#ffffff" /> <rect width={total} height={total} fill={paper} />
<path d={path} fill={INK} /> <path d={path} fill={ink} />
{dove && ( {centre && (
<g shapeRendering="auto"> <g shapeRendering="auto">
<rect <rect
x={badgeAt} x={badgeAt}
@ -76,17 +94,28 @@ export default function QrCode({
width={badge} width={badge}
height={badge} height={badge}
rx={badge * 0.22} rx={badge * 0.22}
fill="#ffffff" fill={paper}
stroke={INK} stroke={ink}
strokeWidth={0.35} strokeWidth={0.35}
/> />
{centre.kind === 'dove' ? (
<DoveMark <DoveMark
x={(total - doveWidth) / 2} x={(total - doveWidth) / 2}
y={(total - doveHeight) / 2} y={(total - doveHeight) / 2}
width={doveWidth} width={doveWidth}
height={doveHeight} height={doveHeight}
style={{ color: TEAL }} style={{ color: centre.color ?? QR_DOVE }}
/> />
) : (
<image
href={centre.src}
x={(total - imageSize) / 2}
y={(total - imageSize) / 2}
width={imageSize}
height={imageSize}
preserveAspectRatio="xMidYMid meet"
/>
)}
</g> </g>
)} )}
</svg> </svg>

View file

@ -59,7 +59,7 @@ function todayIndex(days: Day[]): number {
} }
const mapEmbed = (place: string) => const mapEmbed = (place: string) =>
`https://maps.google.com/maps?q=${encodeURIComponent(place)}&output=embed` `https://maps.google.com/maps?q=${encodeURIComponent(place)}&output=embed&maptype=satellite`
const mapLink = (place: string) => const mapLink = (place: string) =>
`https://www.google.com/maps/search/?api=1&query=${encodeURIComponent(place)}` `https://www.google.com/maps/search/?api=1&query=${encodeURIComponent(place)}`

View file

@ -1305,7 +1305,7 @@ const frontPage = {
full: true, full: true,
help: help:
"A YouTube, Vimeo or Facebook link, or a video file: a filename in " + "A YouTube, Vimeo or Facebook link, or a video file: a filename in " +
"/front-page/ or a link ending in .mp4 or .webm", "the uploads folder, or a link ending in .mp4 or .webm",
}, },
{ path: "video_title", label: "Video title", full: true, help: "Shown after \"Featured video\" above the headline" }, { path: "video_title", label: "Video title", full: true, help: "Shown after \"Featured video\" above the headline" },
{ {

View file

@ -15,7 +15,7 @@
so the visitor presses play. so the visitor presses play.
A featured video can also be a file rather than a link: a A featured video can also be a file rather than a link: a
filename in public/front-page/, a /path, or an https URL ending filename in the uploads directory, a /path, or an https URL ending
in a video extension. videoSource() says which, so the hero can in a video extension. videoSource() says which, so the hero can
hand a file to <video> and a link to an <iframe>. hand a file to <video> and a link to an <iframe>.
═══════════════════════════════════════════════════════════════ */ ═══════════════════════════════════════════════════════════════ */

View file

@ -1,18 +1,25 @@
/* ═══════════════════════════════════════════════════════════════ /* ═══════════════════════════════════════════════════════════════
MEDIA PATHS MEDIA PATHS
Every image field in the API is a bare filename — "where the Every image field in the API is a filename or a path, and where a
images live is the component's business", as history.js puts it. bare filename lives is decided here, in one file.
This is that business, in one file, so moving a directory is one
edit rather than a grep.
⚠ Only two of these directories are confirmed by the admin help One rule: record images are uploads. A value from the media
text: people/ and event-logos/. The other three are a guess at library is already '/uploads/<file>'; a bare filename is a file
your convention. Check public/ and fix them here — nothing else copied into the uploads directory by hand (fall-retreat-logo.svg
references the paths. was), so it resolves to /uploads/<file> too. That covers logos,
photos, backgrounds, hero slides, block images: everything an
editor picks.
The site's own chosen assets (the NGU logos in the nav, footer
and admin) are the exception: they're bundled from
src/assets/logos and imported where they're used, not resolved
here.
A value that already looks like a path or a URL is returned A value that already looks like a path or a URL is returned
untouched, so a hand-written entry can point anywhere. untouched, so a hand-written entry can point anywhere.
server/src/pageMeta.js resolves images for link previews by the
same rule; keep the two in step.
═══════════════════════════════════════════════════════════════ */ ═══════════════════════════════════════════════════════════════ */
const ABSOLUTE = /^(https?:|\/|data:)/ const ABSOLUTE = /^(https?:|\/|data:)/
@ -29,40 +36,42 @@ function inDir(dir: string) {
} }
} }
export const personPhoto = inDir('/people') // confirmed export const UPLOADS = '/uploads'
export const eventLogo = inDir('/event-logos') // confirmed
export const eventBackground = inDir('/event-backgrounds')
export const orgLogo = inDir('/org-logos') // ⚠ guess
export const teamLogo = inDir('/team-logos') // ⚠ guess
export const awardLogo = inDir('/award-logos') // ⚠ guess
/* front_page_slides.media — the home page hero's photos. New with const inUploads = inDir(UPLOADS)
the Front page editor, which names the directory in its help. */
export const heroPhoto = inDir('/front-page')
/* front_page.video_url when it names a file rather than a link: /* One helper per field, all the same rule, so a caller says what the
same directory as the photos. */ image is and a future exception is one line here. */
export const heroVideo = inDir('/front-page') export const personPhoto = inUploads
export const eventLogo = inUploads
export const eventBackground = inUploads
export const orgLogo = inUploads
export const teamLogo = inUploads
export const awardLogo = inUploads
/* content_blocks.media, which can be an image on any owner's page, /* front_page_slides.media, the hero's photos. */
so it can't share a per-entity directory. */ export const heroPhoto = inUploads
export const blockMedia = inDir('/media') // ⚠ guess
/* featured_cards.image, a card's own picture. Normally an upload /* front_page.video_url when it names a file rather than a link.
('/uploads/…'); a bare filename looks here. */ Videos can't be uploaded through the media library, so a file is
export const featuredImage = inDir('/featured') one copied into the uploads directory by hand. */
export const heroVideo = inUploads
/* blog_posts.cover_image and guest_photo. Normally uploads. */ /* content_blocks.media and content_block_items.media. */
export const blogImage = inDir('/blog') export const blockMedia = inUploads
/* featured_cards.image. */
export const featuredImage = inUploads
/* blog_posts.cover_image and guest_photo. */
export const blogImage = inUploads
/* ── By record kind ──────────────────────────────────────────── /* ── By record kind ────────────────────────────────────────────
The timeline sends `logo: { file, kind }` rather than a path, The timeline sends `logo: { file, kind }` rather than a path,
because v_timeline COALESCEs across five tables and only the because v_timeline COALESCEs across five tables and only the
ref_kind says which one the filename came from. ref_kind says which one the filename came from. Featured cards
send the same shape. Every kind resolves to the uploads directory
⚠ Three of these directories are the guesses above. Your current today; the map is what lets one kind differ later.
timelineRefs.ts already has the real ones — timeline logos render
today — so copy them into the map above and delete this note.
───────────────────────────────────────────────────────────── */ ───────────────────────────────────────────────────────────── */
const BY_KIND: Record<string, (file?: string | null) => string | null> = { const BY_KIND: Record<string, (file?: string | null) => string | null> = {

View file

@ -19,7 +19,7 @@ const SECTIONS = [
id: 'make', id: 'make',
title: 'Make a QR code', title: 'Make a QR code',
blurb: blurb:
'Pick a page from the main navigation, or any event, organization, team, award, person or blog post on the site. The code always points at the live site.', 'Pick a page from the main navigation, any event, organization, team, award, person or blog post, or type any link. Site pages always point at the live site. Choose what sits in the centre and the colours; a warning shows if the code might not scan.',
accent: '#138ba0', accent: '#138ba0',
background: '#eef9fb', background: '#eef9fb',
content: ( content: (

View file

@ -27,7 +27,7 @@ import { AdminTitleContext } from "../../lib/adminTitle.tsx";
import { AdminWidthContext } from "../../lib/adminWidth.tsx"; import { AdminWidthContext } from "../../lib/adminWidth.tsx";
import { SITE_VERSION } from "../../lib/version.ts"; import { SITE_VERSION } from "../../lib/version.ts";
import { ROLE_LABELS, isSuper } from "../../lib/roles.ts"; import { ROLE_LABELS, isSuper } from "../../lib/roles.ts";
import nguLogo from "../../assets/NGU_Logo.svg"; import nguLogo from "../../assets/logos/NGU_Logo.svg";
import { import {
ADMIN_HOME, ADMIN_HOME,
AREA_TITLES, AREA_TITLES,

View file

@ -135,7 +135,7 @@ export const TOOLS_NAV = {
{ {
to: "/qr", to: "/qr",
label: "QR code generator", label: "QR code generator",
blurb: "Codes for flyers, slides and signs, pointing at any page on the site.", blurb: "Codes for flyers, slides and signs: any page or link, in your choice of colours.",
}, },
], ],
}; };

View file

@ -5,7 +5,7 @@ import { eventHref } from "../../lib/hrefs.ts";
import { EVENT_TYPES, eventTypeLabel } from "../../lib/eventTypes.ts"; import { EVENT_TYPES, eventTypeLabel } from "../../lib/eventTypes.ts";
import { seriesLabel } from "../../lib/eventSeries.ts"; import { seriesLabel } from "../../lib/eventSeries.ts";
import PlatformIcon from "../../components/PlatformIcon.tsx"; import PlatformIcon from "../../components/PlatformIcon.tsx";
import { eventBackground, isAbsoluteMedia } from "../../lib/media.ts"; import { eventBackground, eventLogo as eventLogoSrc, orgLogo as orgLogoSrc } from "../../lib/media.ts";
/* ═══════════════════════════════════════════════════════════════ /* ═══════════════════════════════════════════════════════════════
EVENT LIST — CARDS EVENT LIST — CARDS
@ -27,28 +27,17 @@ import { eventBackground, isAbsoluteMedia } from "../../lib/media.ts";
nothing but retreats shows no control at all. nothing but retreats shows no control at all.
═══════════════════════════════════════════════════════════════ */ ═══════════════════════════════════════════════════════════════ */
const LOGO_FILES = import.meta.glob("../../assets/event-logos/*.svg", {
eager: true,
import: "default",
});
const LOGOS = Object.fromEntries(
Object.entries(LOGO_FILES).map(([path, src]) => [path.split("/").pop(), src])
);
/* A bundled logo by filename, or an upload or URL as it is. */
const logoSrc = file =>
(file && LOGOS[file]) || (isAbsoluteMedia(file) ? file : null);
/* Last resort only. The API already falls back to the host /* Last resort only. The API already falls back to the host
organization's logo when an event doesn't name its own, so this organization's logo when an event doesn't name its own, so this
fires only for an event with no host at all. */ fires only for an event with no host at all. */
const DEFAULT_ORG_LOGO = null; const DEFAULT_ORG_LOGO = null;
/* An <img> that removes itself if the file 404s. */ /* An <img> that removes itself if the file 404s. `src` is already
function Logo({ file, alt = "", className }) { resolved by media.ts: a bare filename from the uploads directory,
anything with a path or URL as it is. */
function Logo({ src, alt = "", className }) {
const [failed, setFailed] = useState(false); const [failed, setFailed] = useState(false);
const src = logoSrc(file);
if (!src || failed) return null; if (!src || failed) return null;
return ( return (
<img <img
@ -165,8 +154,8 @@ export function Card({
}) { }) {
const past = ev.status === "past"; const past = ev.status === "past";
const color = ev.color || defaultColor; const color = ev.color || defaultColor;
const orgLogo = ev.org_logo || DEFAULT_ORG_LOGO; const orgLogo = orgLogoSrc(ev.org_logo) || DEFAULT_ORG_LOGO;
const eventLogo = ev.event_logo; const eventLogo = eventLogoSrc(ev.event_logo);
const schedule = seriesLabel(ev.series, ev.starts_on); const schedule = seriesLabel(ev.series, ev.starts_on);
const links = ev.links ?? []; const links = ev.links ?? [];
const igHandle = ev.instagram || null; const igHandle = ev.instagram || null;
@ -216,7 +205,7 @@ export function Card({
{compact ? ( {compact ? (
/* ── GRID CARD: layout driven by .ev-grid container queries ── */ /* ── GRID CARD: layout driven by .ev-grid container queries ── */
<div className="ev-grid mb-2"> <div className="ev-grid mb-2">
<Logo file={orgLogo} className="ev-ngu h-11 w-auto mb-4" /> <Logo src={orgLogo} className="ev-ngu h-11 w-auto mb-4" />
<div className="ev-info"> <div className="ev-info">
{typeBadge} {typeBadge}
<h3 className="text-3xl font-900 leading-tight"> <h3 className="text-3xl font-900 leading-tight">
@ -234,7 +223,7 @@ export function Card({
)} )}
</div> </div>
<Logo <Logo
file={eventLogo} src={eventLogo}
alt={ev.title} alt={ev.title}
className="ev-image w-full h-auto object-contain" className="ev-image w-full h-auto object-contain"
/> />
@ -245,7 +234,7 @@ export function Card({
<> <>
<div className="grid grid-cols-1 md:grid-cols-3 gap-x-8 mb-4"> <div className="grid grid-cols-1 md:grid-cols-3 gap-x-8 mb-4">
<div className="md:col-span-2"> <div className="md:col-span-2">
<Logo file={orgLogo} className="h-15 w-auto mb-6" /> <Logo src={orgLogo} className="h-15 w-auto mb-6" />
{typeBadge} {typeBadge}
<h3 className="text-4xl font-900"> <h3 className="text-4xl font-900">
<TitleLink ev={ev} linked={linked}> <TitleLink ev={ev} linked={linked}>
@ -263,7 +252,7 @@ export function Card({
</div> </div>
<div className="md:col-span-1 flex items-center justify-end"> <div className="md:col-span-1 flex items-center justify-end">
<Logo <Logo
file={eventLogo} src={eventLogo}
alt={ev.title} alt={ev.title}
className="w-full h-auto max-h-72 object-contain" className="w-full h-auto max-h-72 object-contain"
/> />

View file

@ -1,12 +1,23 @@
/* ═══════════════════════════════════════════════════════════════ /* ═══════════════════════════════════════════════════════════════
QR CODE MAKER QR CODE MAKER
Pick a page, get a QR code for it on the live site. Pick a page, or type a link, and get a QR code for it.
What main navigation, or one kind of record What main navigation, one kind of record, or a link
typed in
Which the page or record itself Which the page or record itself
Section for a main page with a subnav, optionally one of Section for a main page with a subnav, optionally one of
its #sections its #sections
Centre 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
appears when the pair is unlikely to scan: too
little contrast, or a light code on a dark ground
A typed link can be a site path (/retreats, which goes to the live
site like every other choice), a full http(s) address, or a bare
domain, which gets https:// in front.
The main pages come from navConfig.ts, the same list the header The main pages come from navConfig.ts, the same list the header
draws; records come from GET /directory, which lists only what's draws; records come from GET /directory, which lists only what's
@ -22,7 +33,7 @@
import { useEffect, useMemo, useRef, useState, type ReactNode } from 'react' import { useEffect, useMemo, useRef, useState, type ReactNode } from 'react'
import QrCode from '../../components/QrCode.tsx' import QrCode, { QR_DOVE, QR_INK, QR_PAPER, type QrCentre } from '../../components/QrCode.tsx'
import { NAV_ACTIONS, PAGE_LINKS, PAGE_SECTIONS } from '../../navConfig.ts' import { NAV_ACTIONS, PAGE_LINKS, PAGE_SECTIONS } from '../../navConfig.ts'
import { awardHref, blogHref, eventHref, orgHref, personHref, teamHref } from '../../lib/hrefs.ts' import { awardHref, blogHref, eventHref, orgHref, personHref, teamHref } from '../../lib/hrefs.ts'
import { siteUrl } from '../../lib/site.ts' import { siteUrl } from '../../lib/site.ts'
@ -35,7 +46,7 @@ const MUTED = '#4a6b72'
anything bigger should use the SVG. */ anything bigger should use the SVG. */
const PNG_SIZE = 1024 const PNG_SIZE = 1024
type Kind = 'pages' | 'events' | 'organizations' | 'teams' | 'awards' | 'people' | 'blog_posts' type Kind = 'pages' | 'events' | 'organizations' | 'teams' | 'awards' | 'people' | 'blog_posts' | 'custom'
const KINDS: Array<[Kind, string]> = [ const KINDS: Array<[Kind, string]> = [
['pages', 'Main navigation'], ['pages', 'Main navigation'],
@ -45,8 +56,81 @@ const KINDS: Array<[Kind, string]> = [
['awards', 'Awards'], ['awards', 'Awards'],
['people', 'People'], ['people', 'People'],
['blog_posts', 'Blog posts'], ['blog_posts', 'Blog posts'],
['custom', 'A link I type'],
] ]
/* The centres 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', {
eager: true,
query: '?raw',
import: 'default',
})
type CentreOption = { id: string; label: string; centre: (dove: string) => QrCentre }
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)
.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 }
}),
]
/* ── Contrast ──────────────────────────────────────────────────
WCAG relative luminance and contrast ratio. Below MIN_CONTRAST
some phone cameras struggle; a code lighter than its background
is "inverted", which many scanners don't read at all. */
const MIN_CONTRAST = 4
function luminance(hex: string): number {
const m = hex.replace('#', '').match(/^([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})$/i)
if (!m) return 0
const [r, g, b] = m.slice(1).map((h) => {
const c = parseInt(h, 16) / 255
return c <= 0.03928 ? c / 12.92 : ((c + 0.055) / 1.055) ** 2.4
})
return 0.2126 * r + 0.7152 * g + 0.0722 * b
}
function scanWarning(ink: string, paper: string): string | null {
const a = luminance(ink)
const b = luminance(paper)
if (a > b) return 'The code is lighter than its background. Many scanners can’t read an inverted code.'
const ratio = (b + 0.05) / (a + 0.05)
if (ratio < MIN_CONTRAST) {
return `Low contrast (${ratio.toFixed(1)}:1). Use a darker code or a lighter background so it scans reliably.`
}
return null
}
/* What a typed link means: a site path goes to the live site, a
full address is used as it is, a bare domain gets https://.
Anything else isn't a link. */
function typedUrl(raw: string): string | null {
const value = raw.trim()
if (!value) return null
if (value.startsWith('/') && !value.startsWith('//')) return siteUrl(value)
const withScheme = /^[a-z][a-z0-9+.-]*:/i.test(value) ? value : /^[^\s/]+\.[^\s/]+/.test(value) ? `https://${value}` : null
if (!withScheme) return null
try {
const url = new URL(withScheme)
return url.protocol === 'http:' || url.protocol === 'https:' ? url.href : null
} catch {
return null
}
}
/* Organizations are grouped by kind in the dropdown, in this order. */ /* Organizations are grouped by kind in the dropdown, in this order. */
const ORG_GROUPS: Array<[string, string]> = [ const ORG_GROUPS: Array<[string, string]> = [
['national', 'NGU'], ['national', 'NGU'],
@ -109,12 +193,22 @@ function groupsFor(kind: Kind, directory: Directory | null): Group[] {
return [{ choices: directory.people.map((p) => ({ path: personHref(p.id), label: p.name })) }] return [{ choices: directory.people.map((p) => ({ path: personHref(p.id), label: p.name })) }]
case 'blog_posts': case 'blog_posts':
return [{ choices: directory.blog_posts.map((b) => ({ path: blogHref(b.id), label: b.name })) }] return [{ choices: directory.blog_posts.map((b) => ({ path: blogHref(b.id), label: b.name })) }]
case 'custom':
return []
} }
} }
/* "/regions/northwest#events" → "regions-northwest-events". */ /* "/regions/northwest#events" → "regions-northwest-events"; a typed
function fileStem(path: string): string { link keeps its host too: "example-org-page". */
const stem = path.replace(/^\//, '').replace(/[^a-z0-9]+/gi, '-').replace(/^-|-$/g, '') function fileStem(target: string): string {
let name = target
try {
const url = new URL(target)
name = `${url.hostname.replace(/^www\./, '')}${url.pathname}${url.hash}`
} catch {
/* a site path */
}
const stem = name.replace(/^\//, '').replace(/[^a-z0-9]+/gi, '-').replace(/^-|-$/g, '')
return `ngu-qr-${stem || 'home'}` return `ngu-qr-${stem || 'home'}`
} }
@ -163,7 +257,11 @@ export default function QrCodeMaker() {
const [kind, setKind] = useState<Kind>('pages') const [kind, setKind] = useState<Kind>('pages')
const [path, setPath] = useState('/') const [path, setPath] = useState('/')
const [section, setSection] = useState('') const [section, setSection] = useState('')
const [dove, setDove] = useState(true) const [custom, setCustom] = useState('')
const [centreId, setCentreId] = useState('dove')
const [ink, setInk] = useState(QR_INK)
const [paper, setPaper] = useState(QR_PAPER)
const [doveColor, setDoveColor] = useState(QR_DOVE)
const [copied, setCopied] = useState(false) const [copied, setCopied] = useState(false)
const svgRef = useRef<SVGSVGElement>(null) const svgRef = useRef<SVGSVGElement>(null)
@ -181,8 +279,13 @@ export default function QrCodeMaker() {
const sections = kind === 'pages' ? (PAGE_SECTIONS[path] ?? []) : [] const sections = kind === 'pages' ? (PAGE_SECTIONS[path] ?? []) : []
const selected = choices.find((c) => c.path === path) ?? null const selected = choices.find((c) => c.path === path) ?? null
const target = selected ? `${selected.path}${section}` : null const typed = kind === 'custom' ? typedUrl(custom) : null
const url = target ? siteUrl(target) : null 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 warning = scanWarning(ink, paper)
useEffect(() => setCopied(false), [url]) useEffect(() => setCopied(false), [url])
@ -198,7 +301,7 @@ export default function QrCodeMaker() {
} }
} }
const needsDirectory = kind !== 'pages' const needsDirectory = kind !== 'pages' && kind !== 'custom'
return ( return (
<div className="grid gap-10 lg:grid-cols-2 lg:items-start"> <div className="grid gap-10 lg:grid-cols-2 lg:items-start">
@ -211,7 +314,27 @@ export default function QrCodeMaker() {
))} ))}
</Select> </Select>
{needsDirectory && loading && !directory ? ( {kind === 'custom' ? (
<div>
<label htmlFor="qr-custom" className="block text-sm font-medium text-[#26454c]">
Link
</label>
<input
id="qr-custom"
type="text"
inputMode="url"
value={custom}
onChange={(e) => setCustom(e.target.value)}
placeholder="https://… or /retreats"
className={`mt-2 ${inputClass}`}
/>
<p className="mt-1 text-sm" style={{ color: custom.trim() && !typed ? '#b3261e' : MUTED }}>
{custom.trim() && !typed
? 'That isn’t a web address. Use https://…, a domain, or a site path like /retreats.'
: 'A full address, a domain (example.org), or a path on this site (/retreats).'}
</p>
</div>
) : needsDirectory && loading && !directory ? (
<p style={{ color: MUTED }}>Loading the list…</p> <p style={{ color: MUTED }}>Loading the list…</p>
) : needsDirectory && error ? ( ) : needsDirectory && error ? (
<p className="text-[#b3261e]">Couldn't load the list of pages. {error}</p> <p className="text-[#b3261e]">Couldn't load the list of pages. {error}</p>
@ -258,15 +381,43 @@ export default function QrCodeMaker() {
</Select> </Select>
)} )}
<label className="flex items-center gap-3 text-[#26454c]"> <Select id="qr-centre" label="In the centre" value={centreId} onChange={setCentreId}>
<input {CENTRES.map((c) => (
type="checkbox" <option key={c.id} value={c.id}>
checked={dove} {c.label}
onChange={(e) => setDove(e.target.checked)} </option>
className="h-4 w-4 accent-[#138ba0]" ))}
/> </Select>
NGU dove in the centre
</label> <fieldset>
<legend className="text-sm font-medium text-[#26454c]">Colours</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} />
)}
{(ink !== QR_INK || paper !== QR_PAPER || doveColor !== QR_DOVE) && (
<button
type="button"
onClick={() => {
setInk(QR_INK)
setPaper(QR_PAPER)
setDoveColor(QR_DOVE)
}}
className="pb-2 text-sm underline"
style={{ color: TEAL }}
>
Reset colours
</button>
)}
</div>
{warning && (
<p role="status" className="mt-2 rounded-lg bg-[#fdf3f2] px-3 py-2 text-sm text-[#b3261e]">
{warning}
</p>
)}
</fieldset>
{url && ( {url && (
<div> <div>
@ -295,7 +446,9 @@ export default function QrCodeMaker() {
<QrCode <QrCode
ref={svgRef} ref={svgRef}
value={url} value={url}
dove={dove} centre={centre}
ink={ink}
paper={paper}
label={`QR code for ${url}`} label={`QR code for ${url}`}
className="block h-auto w-full" className="block h-auto w-full"
/> />
@ -333,6 +486,52 @@ function DownloadButton({ onClick, children }: { onClick: () => void; children:
) )
} }
const inputClass =
'w-full rounded-xl border border-[#4a6b72]/25 bg-white px-4 py-3 text-[#26454c] ' +
'outline-none transition-colors focus:border-[#138ba0] focus:ring-2 focus:ring-[#138ba0]/25'
/* A colour well with its hex beside it, both editable. */
function ColourInput({
id,
label,
value,
onChange,
}: {
id: string
label: string
value: string
onChange: (value: string) => void
}) {
const [text, setText] = useState(value)
useEffect(() => setText(value), [value])
return (
<div>
<label htmlFor={id} className="block text-xs font-medium" style={{ color: MUTED }}>
{label}
</label>
<div className="mt-1 flex items-center gap-2">
<input
id={id}
type="color"
value={value}
onChange={(e) => onChange(e.target.value)}
className="h-9 w-11 cursor-pointer rounded border border-[#4a6b72]/25 bg-white"
/>
<input
type="text"
aria-label={`${label} colour, as hex`}
value={text}
onChange={(e) => {
setText(e.target.value)
if (/^#[0-9a-f]{6}$/i.test(e.target.value)) onChange(e.target.value.toLowerCase())
}}
className="w-24 rounded-lg border border-[#4a6b72]/25 bg-white px-2 py-1.5 font-mono text-sm text-[#26454c] outline-none focus:border-[#138ba0]"
/>
</div>
</div>
)
}
const selectClass = const selectClass =
'w-full appearance-none rounded-xl border border-[#4a6b72]/25 bg-white px-4 py-3 pr-10 text-[#26454c] ' + 'w-full appearance-none rounded-xl border border-[#4a6b72]/25 bg-white px-4 py-3 pr-10 text-[#26454c] ' +
'outline-none transition-colors focus:border-[#138ba0] focus:ring-2 focus:ring-[#138ba0]/25' 'outline-none transition-colors focus:border-[#138ba0] focus:ring-2 focus:ring-[#138ba0]/25'