From 38c08cf87258ec98f814bcae31f74526555b1194 Mon Sep 17 00:00:00 2001
From: blake
Date: Mon, 2 Nov 2026 15:17:51 -0600
Subject: [PATCH] feat: enhance user interaction with contact details and
improved UI elements
Updated the signup and management pages to include clickable email and phone links for better user accessibility. Introduced new styles for roster management, including a collapsible move form for shift changes. Enhanced confirmation messages for cancellations and improved print styles to hide unnecessary elements. Added error handling for the Turnstile widget in the signup dialog, ensuring fallback options are visible when needed. Updated tests to verify the new features and ensure robust functionality across the application.
---
public/css/app.css | 145 +++++++++++++++++++++++++++----------
public/js/desk.js | 12 +++
public/js/signup-dialog.js | 26 +++++--
src/admin-pages.tsx | 54 ++++++++++----
src/pages.tsx | 70 ++++++++++++------
src/reminders.ts | 2 +
src/signup-http.tsx | 2 +-
src/signup.ts | 2 +
tests/admin.test.ts | 3 +
tests/cancel.test.ts | 6 +-
tests/public-pages.test.ts | 13 ++++
tests/reminders.test.ts | 2 +
12 files changed, 251 insertions(+), 86 deletions(-)
diff --git a/public/css/app.css b/public/css/app.css
index 304d978..d25fcc0 100644
--- a/public/css/app.css
+++ b/public/css/app.css
@@ -862,13 +862,19 @@ main a:hover {
margin: 0.5rem 0 0;
}
+.manage-record:has(.manage-tools) {
+ padding-top: 4.35rem;
+}
+
.manage-tools {
position: absolute;
z-index: 2;
top: 1.05rem;
right: 1.05rem;
+ left: 1.05rem;
display: flex;
align-items: center;
+ justify-content: flex-end;
gap: 0.4rem;
margin: 0;
}
@@ -878,46 +884,11 @@ main a:hover {
}
.manage-x {
- width: 2.5rem;
- height: 2.5rem;
min-height: 2.5rem;
- padding: 0;
- border-color: var(--hope-border);
- background: #fff;
+ padding: 0.4rem 0.95rem;
box-shadow: none;
}
-.manage-x::before {
- background: var(--hope-yellow);
-}
-
-.manage-x span {
- position: relative;
- width: 0.7rem;
- height: 0.7rem;
- font-size: 0;
-}
-
-.manage-x span::before,
-.manage-x span::after {
- content: "";
- position: absolute;
- left: 50%;
- top: 50%;
- width: 0.7rem;
- height: 2px;
- border-radius: 1px;
- background: currentColor;
-}
-
-.manage-x span::before {
- transform: translate(-50%, -50%) rotate(45deg);
-}
-
-.manage-x span::after {
- transform: translate(-50%, -50%) rotate(-45deg);
-}
-
.manage-menu {
position: relative;
}
@@ -3057,6 +3028,45 @@ button.btn-quiet::before {
color: var(--hope-ink);
}
+.shift-card a[href^="tel:"],
+.shift-card a[href^="mailto:"] {
+ color: inherit;
+ font-weight: 650;
+ text-decoration: underline;
+ text-underline-offset: 0.12em;
+}
+
+.roster-move {
+ margin-top: 0.75rem;
+}
+
+.roster-move:not([open]) > .move-form,
+.roster-move:not([open])::details-content {
+ display: none;
+}
+
+.roster-move > summary {
+ display: inline-flex;
+ align-items: center;
+ width: fit-content;
+ min-height: 2rem;
+ list-style: none;
+ cursor: pointer;
+ color: #4d7494;
+ font-size: 0.92rem;
+ font-weight: 650;
+ text-decoration: underline;
+ text-underline-offset: 0.12em;
+}
+
+.roster-move > summary::-webkit-details-marker {
+ display: none;
+}
+
+.roster-move > .move-form {
+ margin-top: 0.75rem;
+}
+
.event-page .desk-intro .desk-toolbar {
align-items: center;
}
@@ -4341,10 +4351,6 @@ button.btn-quiet::before {
width: 100%;
}
- .manage-record:has(.manage-tools) {
- padding-top: 4.35rem;
- }
-
.manage-record:has(.manage-tools) .details {
padding-right: 0;
}
@@ -5831,3 +5837,62 @@ main > .crumb,
flex-wrap: wrap;
}
}
+
+@media print {
+ .skip-link,
+ .header,
+ .footer,
+ .session-bar,
+ .crumb,
+ .desk-actions,
+ .desk-inline,
+ .pick,
+ .pick-bar,
+ .notice,
+ .event-edit,
+ .walkin-menu,
+ .roster-move,
+ .roster-actions,
+ .signup-form,
+ .confirm-dialog,
+ .event-dialog,
+ button,
+ .btn {
+ display: none !important;
+ }
+
+ body,
+ main,
+ .event-page,
+ .shift-card,
+ article.shift-card,
+ .desk-events,
+ .event-strip,
+ .manage,
+ .manage-record {
+ background: #fff;
+ box-shadow: none;
+ color: #000;
+ }
+
+ .shift-list {
+ display: block;
+ }
+
+ .shift-list > li,
+ li.shift-card {
+ break-inside: avoid;
+ margin-bottom: 0.75rem;
+ border: 1px solid #bbb;
+ border-radius: 0;
+ box-shadow: none;
+ background: #fff;
+ }
+
+ a,
+ .shift-card a[href^="tel:"],
+ .shift-card a[href^="mailto:"] {
+ color: #000;
+ text-decoration: none;
+ }
+}
diff --git a/public/js/desk.js b/public/js/desk.js
index 58a29e7..2889c17 100644
--- a/public/js/desk.js
+++ b/public/js/desk.js
@@ -1,4 +1,16 @@
(function () {
+ window.addEventListener(
+ 'error',
+ function (event) {
+ var target = event.target;
+ if (!target || !target.src || String(target.src).indexOf('challenges.cloudflare.com/turnstile') === -1) return;
+ document.querySelectorAll('[data-turnstile-fallback]').forEach(function (node) {
+ node.hidden = false;
+ });
+ },
+ true,
+ );
+
var key = 'hope-place';
var place = null;
try {
diff --git a/public/js/signup-dialog.js b/public/js/signup-dialog.js
index 945054d..d60d383 100644
--- a/public/js/signup-dialog.js
+++ b/public/js/signup-dialog.js
@@ -200,14 +200,28 @@
if (!widget || !sitekey) return;
loadTurnstile()
.then(function () {
- if (!widget.isConnected || !window.turnstile) return;
+ if (!widget.isConnected || !window.turnstile) {
+ showTurnstileFallback(scope);
+ return;
+ }
// turnstile.ready() throws when this script is inserted dynamically.
- widgetId = window.turnstile.render(widget, {
- sitekey: sitekey,
- action: widget.getAttribute('data-action') || 'signup',
- });
+ try {
+ widgetId = window.turnstile.render(widget, {
+ sitekey: sitekey,
+ action: widget.getAttribute('data-action') || 'signup',
+ });
+ } catch (err) {
+ showTurnstileFallback(scope);
+ }
})
- .catch(function () {});
+ .catch(function () {
+ showTurnstileFallback(scope);
+ });
+ }
+
+ function showTurnstileFallback(scope) {
+ var fallback = scope.querySelector('[data-turnstile-fallback]');
+ if (fallback) fallback.hidden = false;
}
function loadTurnstile() {
diff --git a/src/admin-pages.tsx b/src/admin-pages.tsx
index d90d18e..479472f 100644
--- a/src/admin-pages.tsx
+++ b/src/admin-pages.tsx
@@ -2007,12 +2007,18 @@ function Roster(props: { config: AppConfig; csrf: string; people: RosterPerson[]
{person.name}
{person.groupSize > 1 ? Holds {person.groupSize} spots
: null}
- {person.email}
- {person.phone ? {person.phone}
: null}
+
+ {person.email}
+
+ {person.phone ? (
+
+
+
+ ) : null}
{person.notes ? Note: {person.notes}
: null}
{person.status === 'confirmed' ? 'Confirmed' : 'Cancelled'}
{person.status === 'cancelled' ? (
-
+
-
+
{props.moves && props.moves.targets.length > 0 && props.moves.tokens[person.id] ? (
-
+
+ Move to another shift
+
+
) : null}
>
) : null}
@@ -2053,6 +2062,21 @@ function Roster(props: { config: AppConfig; csrf: string; people: RosterPerson[]
);
}
+function PhoneLink(props: { phone: string }) {
+ const href = phoneHref(props.phone);
+ if (!href) return <>{props.phone}>;
+ return {props.phone} ;
+}
+
+/** A 10-digit pantry number dials as +1. Anything else keeps the digits it has. */
+function phoneHref(phone: string): string | null {
+ const digits = phone.replace(/\D/g, '');
+ if (digits.length === 10) return `tel:+1${digits}`;
+ if (digits.length === 11 && digits.startsWith('1')) return `tel:+${digits}`;
+ if (digits.length > 0) return `tel:${digits}`;
+ return null;
+}
+
function LoginForm(props: { config: AppConfig; error?: string }) {
return (
<>
diff --git a/src/pages.tsx b/src/pages.tsx
index dfab6cf..02f4118 100644
--- a/src/pages.tsx
+++ b/src/pages.tsx
@@ -13,6 +13,9 @@ import { assetHref } from './static-assets.js';
import { appPath } from './url.js';
const PANTRY_SITE = 'https://hopefoodpantrysc.org';
+const PANTRY_PHONE_LABEL = '712\u2011540\u20119351';
+const PANTRY_PHONE_HREF = 'tel:+17125409351';
+const PANTRY_EMAIL = 'hopepantry@gmail.com';
function asset(config: AppConfig, file: string): string {
return assetHref(config, file);
@@ -136,10 +139,10 @@ export function Layout(props: {
- Signing up needs JavaScript for the abuse check. The pantry has not published a contact method for help with signup.
+
+
+
{errorEntries.length > 0 ? (
@@ -1301,7 +1314,16 @@ function SignupForm(props: { config: AppConfig; shiftId: number; eventId: number
: undefined
}
/>
-
+
) : null}
-
This check confirms the signup came from a browser.
+
+
+
{extraCount > 0 ? `Sign up for ${extraCount + 1} dates` : 'Sign up'}
);
diff --git a/src/reminders.ts b/src/reminders.ts
index d83bcc9..3815bde 100644
--- a/src/reminders.ts
+++ b/src/reminders.ts
@@ -141,6 +141,7 @@ export type ReminderPageSignup = {
eventTitle: string;
location: string;
when: ZonedClock;
+ ends: ZonedClock;
groupSize: number;
status: 'confirmed' | 'cancelled';
ended: boolean;
@@ -188,6 +189,7 @@ export function readReminderSignup(db: Database.Database, signupId: number, now:
eventTitle: row.title,
location: row.location.trim(),
when: formatInstantInZone(row.starts_at_utc, row.tz),
+ ends: formatInstantInZone(row.ends_at_utc, row.tz),
groupSize: Number(row.group_size),
status: row.status,
ended: row.ends_at_utc <= now,
diff --git a/src/signup-http.tsx b/src/signup-http.tsx
index edb0ea8..a7acf03 100644
--- a/src/signup-http.tsx
+++ b/src/signup-http.tsx
@@ -53,7 +53,7 @@ const SWITCH_ORIGIN = 'The switch could not be sent from this page.';
const SWITCH_REJECTED = 'The switch could not be confirmed. Please try again.';
const SWITCH_UNAVAILABLE = 'The switch could not be saved. Please try again in a little while.';
const SWITCH_STALE = 'This form is out of date. Submit it again.';
-const SWITCHED_NOTE = 'You are on this shift. This link replaces the earlier one. A change email is queued.';
+const SWITCHED_NOTE = 'You are on this shift. This link replaces the earlier one. A change email is on the way.';
const PARTY_ORIGIN = 'The update could not be sent from this page.';
const PARTY_REJECTED = 'The update could not be confirmed. Please try again.';
const PARTY_UNAVAILABLE = 'The update could not be saved. Please try again in a little while.';
diff --git a/src/signup.ts b/src/signup.ts
index 9dcd01c..edadcd1 100644
--- a/src/signup.ts
+++ b/src/signup.ts
@@ -47,6 +47,7 @@ export type ManageView = {
location: string;
eventTitle: string;
when: ZonedClock;
+ ends: ZonedClock;
/** True once the shift's end instant has been reached. The private link can no longer change this signup. */
ended: boolean;
};
@@ -278,6 +279,7 @@ export function readManageSignup(db: Database.Database, token: string, now: stri
location: row.location,
eventTitle: row.title,
when: formatInstantInZone(row.starts_at_utc, row.tz),
+ ends: formatInstantInZone(row.ends_at_utc, row.tz),
ended: row.ends_at_utc <= now,
};
}
diff --git a/tests/admin.test.ts b/tests/admin.test.ts
index 5524e5e..53e8f78 100644
--- a/tests/admin.test.ts
+++ b/tests/admin.test.ts
@@ -526,6 +526,9 @@ describe('coordinator screens', () => {
expect(optionValues(html, 'destination')).toEqual([String(destinationId)]);
expect(html).toContain('
');
expect(html).toContain('>Distribution, October 23, 2026, 9:00 AM to 12:00 PM CDT<');
+ expect(html).toContain('href="mailto:kim@example.invalid"');
+ expect(html).toContain('href="tel:+17125550199"');
+ expect(html).toContain('>Move to another shift');
const moved = await postMove(app, cookie, signupId, html, String(destinationId));
expect(moved.status).toBe(303);
expect(moved.headers.get('location')).toBe(`/admin/shifts/${destinationId}?notice=moved`);
diff --git a/tests/cancel.test.ts b/tests/cancel.test.ts
index 7dca8c7..78da06c 100644
--- a/tests/cancel.test.ts
+++ b/tests/cancel.test.ts
@@ -36,7 +36,11 @@ describe('manage-link cancellation', () => {
};
const viewed = await app.request(managePath);
expect(viewed.status).toBe(200);
- expect(await viewed.text()).toContain('Cancel this signup');
+ const viewedHtml = await viewed.text();
+ expect(viewedHtml).toContain('Cancel this signup');
+ expect(viewedHtml).toContain('>Cancel<');
+ expect(viewedHtml).toContain('>9:00 AM to 12:00 PM ');
+ expect(viewedHtml).not.toContain('queues a change email');
expect(db.prepare('SELECT status, updated_at FROM signups').get()).toEqual({
status: 'confirmed',
updated_at: before.updated_at,
diff --git a/tests/public-pages.test.ts b/tests/public-pages.test.ts
index 1335aab..a92d5d0 100644
--- a/tests/public-pages.test.ts
+++ b/tests/public-pages.test.ts
@@ -168,6 +168,17 @@ describe('public pages', () => {
expect(shiftHtml).toContain('name="last_name"');
expect(shiftHtml).toContain('First name');
expect(shiftHtml).toContain('Last name');
+ expect(shiftHtml).toContain('9:00 AM to 12:00 PM');
+ expect(shiftHtml).toMatch(/id="signup-email"[^>]*required/);
+ expect(shiftHtml).toContain('Signing up needs JavaScript. Call the pantry at');
+ expect(shiftHtml).toContain('712\u2011540\u20119351');
+ expect(shiftHtml).toContain('href="tel:+17125409351"');
+ expect(shiftHtml).toContain('href="mailto:hopepantry@gmail.com"');
+ expect(shiftHtml).toContain('data-turnstile-fallback');
+ expect(shiftHtml).toContain('The signup check could not load.');
+ expect(shiftHtml).not.toContain('has not published a contact method');
+ expect(shiftHtml).not.toContain('abuse check');
+ expect(shiftHtml).not.toContain('This check confirms the signup came from a browser');
expect(shiftHtml).toContain('class="signup-note">Your full name is listed on the public sign-up page. Email, phone, and notes stay off that page.');
expect(shiftHtml).not.toContain('name="robots"');
expect(shift.headers.get('x-robots-tag')).toBeNull();
@@ -176,6 +187,8 @@ describe('public pages', () => {
expect(shiftHtml).not.toContain('data-guardian');
expect(shiftHtml).not.toContain('I am under 18');
const css = await (await app.request('/css/app.css')).text();
+ expect(css).toContain('@media print');
+ expect(css).toContain('.roster-move');
expect(css).toContain('grid-template-columns: repeat(4, minmax(0, 1fr))');
expect(css).toContain('grid-template-columns: repeat(2, minmax(0, 1fr))');
expect(css).not.toContain('minmax(16rem, 1fr)');
diff --git a/tests/reminders.test.ts b/tests/reminders.test.ts
index a2fda5f..3969e41 100644
--- a/tests/reminders.test.ts
+++ b/tests/reminders.test.ts
@@ -273,6 +273,8 @@ describe('reminder mail', () => {
const confirmHtml = await confirm.text();
expect(confirmHtml).toContain('Are you sure you want to cancel?');
expect(confirmHtml).toContain('Cancel this signup to open the spot for someone else.');
+ expect(confirmHtml).toContain('We'll email you when it's cancelled.');
+ expect(confirmHtml).toContain('>9:00 AM to 12:00 PM ');
expect(confirmHtml).toContain('Pat Review');
expect(confirmHtml).toContain('Sorting');
expect(db.prepare(`SELECT status FROM signups`).get()).toEqual({ status: 'confirmed' });