style: 14px text floor and one shared status wording

- app.css: add --hope-text-small (14px) and --hope-text-fine (13px, footer
  fine print). Every font size below 14px now uses them. The help-tip circle,
  event badge and date stamp grow to fit the larger text.
- schedule.ts: shared filledCount(), spotsSentence() and fillLabel().
  Public pages say "4 of 6 spots filled"; coordinator pills say
  "Full · 6 of 6" or "2 open · 4 of 6" (needs tone when under half full).
- admin-pages.tsx: drop needCopy(); dashboard, event page and shift lines
  all use fillLabel().
- tests: update wording expectations; add design-rules.test.ts to guard the
  14px floor and the wording.
- README: update example wording.
This commit is contained in:
Cosmically Creative committed 2026-11-20 13:24:23 -06:00
1 parent 085f2dc668
commit 1230030e39
9 files changed
+112 -67

No files matched your search

+1 -1
View File
@@ -75,7 +75,7 @@ npm run seed
`npm run dev` serves the site on `127.0.0.1` at `BASE_URL` (from `.env`, `http://127.0.0.1:3000`). It is loopback only. Stop it with Ctrl+C. `npm run dev` serves the site on `127.0.0.1` at `BASE_URL` (from `.env`, `http://127.0.0.1:3000`). It is loopback only. Stop it with Ctrl+C.
Open `/` for the weekly pantry sign-up page. **View** starts on **List**: a card for each day with a shift in the next three months, split into that day's shifts. Each shift lists the names of the people who are signed up. A shift that has already ended stays on that day's card, grayed out, until midnight in the event's time zone. At midnight the day leaves the list. Emails, phone numbers, and notes stay off the page. **Calendar** is the other choice in that menu, at `/?view=calendar`, and it stops at that same three-month date. A shift later than that date is left off both views, and the signup form does not take a reservation for it. `/e/weekly-pantry` is the same seeded event. `/healthz` returns `{"ok":true,"database":"ok"}` and nothing else. A shift shows how many spots are filled, such as 3/5 spots filled. A shift with space left uses a soft green label. A full shift uses a soft red label. Open `/` for the weekly pantry sign-up page. **View** starts on **List**: a card for each day with a shift in the next three months, split into that day's shifts. Each shift lists the names of the people who are signed up. A shift that has already ended stays on that day's card, grayed out, until midnight in the event's time zone. At midnight the day leaves the list. Emails, phone numbers, and notes stay off the page. **Calendar** is the other choice in that menu, at `/?view=calendar`, and it stops at that same three-month date. A shift later than that date is left off both views, and the signup form does not take a reservation for it. `/e/weekly-pantry` is the same seeded event. `/healthz` returns `{"ok":true,"database":"ok"}` and nothing else. A shift shows how many spots are filled, such as 3 of 5 spots filled. A shift with space left uses a soft green label. A full shift uses a soft red label. Coordinator lists use the same count with the state first, such as 2 open · 3 of 5 or Full · 5 of 5.
An open shift has a signup form. It asks for a first name, last name, email, and phone, with optional notes. **How many people** offers 1 to 20, and never more than the spots left. A signup for 3 people fills 3 spots, and only the person signing up is named. The form also lists every other open shift on the public list, from any published event, and up to 24 can be ticked in one submit. Full, ended, cancelled, and not-yet-open shifts are left out. Each date is its own signup, with its own confirmation email and private link. If any date cannot be saved, none are, and the form says which date to leave unchecked. Another person can use the same email and takes their own signup. The same person cannot sign up twice for one shift. The form needs JavaScript because of the Turnstile check. Wait a few seconds after the page loads before submitting. The confirmation page shows a private link and says a confirmation email is on the way. That page works without JavaScript. Cancel this signup there to open the spot again. A cancellation email is queued, and a confirmation that has not been sent yet is dropped. That person can sign up again once the cancellation is saved. Someone else can use the email while the first signup is still confirmed. A cancelled signup stays on that private page until the link expires. A private link controls only that signup. Use the separate link for each signup. On that page, **How many people** changes the party size. A larger number needs that many spots open. A smaller number gives spots back. Coordinators get an email when the count changes. An open shift has a signup form. It asks for a first name, last name, email, and phone, with optional notes. **How many people** offers 1 to 20, and never more than the spots left. A signup for 3 people fills 3 spots, and only the person signing up is named. The form also lists every other open shift on the public list, from any published event, and up to 24 can be ticked in one submit. Full, ended, cancelled, and not-yet-open shifts are left out. Each date is its own signup, with its own confirmation email and private link. If any date cannot be saved, none are, and the form says which date to leave unchecked. Another person can use the same email and takes their own signup. The same person cannot sign up twice for one shift. The form needs JavaScript because of the Turnstile check. Wait a few seconds after the page loads before submitting. The confirmation page shows a private link and says a confirmation email is on the way. That page works without JavaScript. Cancel this signup there to open the spot again. A cancellation email is queued, and a confirmation that has not been sent yet is dropped. That person can sign up again once the cancellation is saved. Someone else can use the email while the first signup is still confirmed. A cancelled signup stays on that private page until the link expires. A private link controls only that signup. Use the separate link for each signup. On that page, **How many people** changes the party size. A larger number needs that many spots open. A smaller number gives spots back. Coordinators get an email when the count changes.
+31 -28
View File
@@ -39,6 +39,9 @@
--hope-full-edge: #e4c4be; --hope-full-edge: #e4c4be;
--hope-blue-quiet: #d7ebf8; --hope-blue-quiet: #d7ebf8;
--hope-blue-quiet-ink: #2d5f86; --hope-blue-quiet-ink: #2d5f86;
/* Smallest text in the app. Footer fine print may use --hope-text-fine. */
--hope-text-small: 0.875rem;
--hope-text-fine: 13px;
--hope-scrollbar-size: 14px; --hope-scrollbar-size: 14px;
--hope-scrollbar-thumb: var(--hope-gold); --hope-scrollbar-thumb: var(--hope-gold);
--hope-scrollbar-thumb-hover: color-mix(in srgb, var(--hope-gold) 72%, var(--hope-ink)); --hope-scrollbar-thumb-hover: color-mix(in srgb, var(--hope-gold) 72%, var(--hope-ink));
@@ -1184,7 +1187,7 @@ main a:hover {
.roster-label { .roster-label {
margin: 0.75rem 0 0.2rem; margin: 0.75rem 0 0.2rem;
color: var(--hope-ink-2); color: var(--hope-ink-2);
font-size: 0.82rem; font-size: var(--hope-text-small);
font-weight: 650; font-weight: 650;
letter-spacing: 0.04em; letter-spacing: 0.04em;
text-transform: uppercase; text-transform: uppercase;
@@ -1292,7 +1295,7 @@ main a:hover {
.cal-weekdays { .cal-weekdays {
margin: 0.55rem 0 0.35rem; margin: 0.55rem 0 0.35rem;
text-align: center; text-align: center;
font-size: 0.82rem; font-size: var(--hope-text-small);
font-weight: 650; font-weight: 650;
color: var(--hope-ink-2); color: var(--hope-ink-2);
} }
@@ -1406,7 +1409,7 @@ main a:hover {
background: var(--hope-blue-50); background: var(--hope-blue-50);
border: 1px solid var(--hope-gold); border: 1px solid var(--hope-gold);
border-radius: 999px; border-radius: 999px;
font-size: 0.68rem; font-size: var(--hope-text-small);
font-weight: 700; font-weight: 700;
line-height: 1.4; line-height: 1.4;
} }
@@ -1452,7 +1455,7 @@ main a:hover {
padding: 0.08rem 0.28rem; padding: 0.08rem 0.28rem;
border-radius: 0.35rem; border-radius: 0.35rem;
background: var(--hope-yellow); background: var(--hope-yellow);
font-size: 0.78rem; font-size: var(--hope-text-small);
font-weight: 650; font-weight: 650;
line-height: 1.35; line-height: 1.35;
} }
@@ -1727,7 +1730,7 @@ article.shift-card {
justify-content: center; justify-content: center;
gap: 0; gap: 0;
cursor: default; cursor: default;
font-size: 0.85rem; font-size: var(--hope-text-small);
font-weight: 500; font-weight: 500;
line-height: 1.25; line-height: 1.25;
} }
@@ -2364,7 +2367,7 @@ article.shift-card {
border: 1px solid #e4edf5; border: 1px solid #e4edf5;
box-shadow: none; box-shadow: none;
color: #4a5563; color: #4a5563;
font-size: 0.75rem; font-size: var(--hope-text-small);
font-weight: 500; font-weight: 500;
line-height: 1.2; line-height: 1.2;
} }
@@ -3373,7 +3376,7 @@ button.btn-quiet::before {
.need-day-count { .need-day-count {
margin: 0; margin: 0;
font-size: 0.82rem; font-size: var(--hope-text-small);
font-weight: 650; font-weight: 650;
white-space: nowrap; white-space: nowrap;
} }
@@ -3516,7 +3519,7 @@ button.btn-quiet::before {
.desk-row-copy span { .desk-row-copy span {
color: #7d8b99; color: #7d8b99;
font-size: 0.86rem; font-size: var(--hope-text-small);
} }
.desk-row::after { .desk-row::after {
@@ -3539,7 +3542,7 @@ button.btn-quiet::before {
padding: 0.12rem 0.7rem; padding: 0.12rem 0.7rem;
border: 1px solid transparent; border: 1px solid transparent;
border-radius: 999px; border-radius: 999px;
font-size: 0.82rem; font-size: var(--hope-text-small);
font-weight: 650; font-weight: 650;
line-height: 1.2; line-height: 1.2;
white-space: nowrap; white-space: nowrap;
@@ -4009,7 +4012,7 @@ button.btn-quiet::before {
.admin-you { .admin-you {
margin-left: 0.45rem; margin-left: 0.45rem;
font-size: 0.85rem; font-size: var(--hope-text-small);
font-weight: 650; font-weight: 650;
} }
@@ -4101,7 +4104,7 @@ button.btn-quiet::before {
} }
.equal-text { .equal-text {
font-size: 12.5px; font-size: var(--hope-text-fine);
color: #444; color: #444;
} }
@@ -4454,7 +4457,7 @@ button.btn-quiet::before {
@media (max-width: 33em) { @media (max-width: 33em) {
.header, .header,
.footer { .footer {
font-size: 13.824px; font-size: var(--hope-text-small);
} }
.nav { .nav {
@@ -4486,14 +4489,14 @@ button.btn-quiet::before {
} }
.equal-text { .equal-text {
font-size: 9.6px; font-size: var(--hope-text-fine);
} }
.copyright-text { .copyright-text {
display: flex; display: flex;
flex-direction: column; flex-direction: column;
align-items: center; align-items: center;
font-size: 11.52px; font-size: var(--hope-text-fine);
} }
.social-links { .social-links {
@@ -4956,12 +4959,12 @@ main > .crumb,
display: inline-flex; display: inline-flex;
align-items: center; align-items: center;
flex: none; flex: none;
min-height: 1.4rem; min-height: 1.6rem;
padding: 0.05rem 0.55rem; padding: 0.05rem 0.55rem;
border-radius: 999px; border-radius: 999px;
background: #e7edf2; background: #e7edf2;
color: #5c6770; color: #5c6770;
font-size: 0.75rem; font-size: var(--hope-text-small);
font-weight: 650; font-weight: 650;
line-height: 1.2; line-height: 1.2;
} }
@@ -5133,7 +5136,7 @@ main > .crumb,
} }
.event-fields .hint { .event-fields .hint {
font-size: 0.86rem; font-size: var(--hope-text-small);
line-height: 1.4; line-height: 1.4;
color: #5c6b78; color: #5c6b78;
} }
@@ -5216,7 +5219,7 @@ main > .crumb,
} }
.event-panel-tools .pick-all { .event-panel-tools .pick-all {
font-size: 0.8rem; font-size: var(--hope-text-small);
color: #7d8b99; color: #7d8b99;
} }
@@ -5322,12 +5325,12 @@ main > .crumb,
.help-tip > summary { .help-tip > summary {
display: grid; display: grid;
place-items: center; place-items: center;
width: 1.15rem; width: 1.4rem;
height: 1.15rem; height: 1.4rem;
border: 1.5px solid #b7c3cc; border: 1.5px solid #b7c3cc;
border-radius: 999px; border-radius: 999px;
color: #8b98a6; color: #8b98a6;
font-size: 0.72rem; font-size: var(--hope-text-small);
font-weight: 700; font-weight: 700;
line-height: 1; line-height: 1;
list-style: none; list-style: none;
@@ -5355,7 +5358,7 @@ main > .crumb,
border-radius: 0.75rem; border-radius: 0.75rem;
box-shadow: 0 8px 24px rgb(34 55 70 / 0.12); box-shadow: 0 8px 24px rgb(34 55 70 / 0.12);
color: #44515c; color: #44515c;
font-size: 0.86rem; font-size: var(--hope-text-small);
font-weight: 400; font-weight: 400;
letter-spacing: 0; letter-spacing: 0;
line-height: 1.45; line-height: 1.45;
@@ -5430,14 +5433,14 @@ main > .crumb,
display: grid; display: grid;
justify-items: center; justify-items: center;
flex: none; flex: none;
width: 2.6rem; width: 3rem;
line-height: 1.05; line-height: 1.05;
} }
.shift-dow, .shift-dow,
.shift-mon { .shift-mon {
color: #8b98a6; color: #8b98a6;
font-size: 0.68rem; font-size: var(--hope-text-small);
font-weight: 700; font-weight: 700;
letter-spacing: 0.04em; letter-spacing: 0.04em;
} }
@@ -5462,7 +5465,7 @@ main > .crumb,
.shift-copy span { .shift-copy span {
color: #7d8b99; color: #7d8b99;
font-size: 0.86rem; font-size: var(--hope-text-small);
line-height: 1.3; line-height: 1.3;
} }
@@ -5476,7 +5479,7 @@ main > .crumb,
padding: 0.12rem 0.7rem; padding: 0.12rem 0.7rem;
border: 1px solid transparent; border: 1px solid transparent;
border-radius: 999px; border-radius: 999px;
font-size: 0.82rem; font-size: var(--hope-text-small);
font-weight: 650; font-weight: 650;
line-height: 1.2; line-height: 1.2;
white-space: nowrap; white-space: nowrap;
@@ -5624,7 +5627,7 @@ main > .crumb,
padding: 0; padding: 0;
list-style: none; list-style: none;
color: #7d8b99; color: #7d8b99;
font-size: 0.8rem; font-size: var(--hope-text-small);
} }
.fill-legend li { .fill-legend li {
@@ -5676,7 +5679,7 @@ main > .crumb,
.repeat-copy span { .repeat-copy span {
color: #7d8b99; color: #7d8b99;
font-size: 0.86rem; font-size: var(--hope-text-small);
line-height: 1.3; line-height: 1.3;
} }
+4 -18
View File
@@ -1,6 +1,6 @@
import { Temporal } from '@js-temporal/polyfill'; import { Temporal } from '@js-temporal/polyfill';
import { DESK_WINDOW_DAYS, type AdminEvent, type HomeEvent, type HomeShift, type AdminShift, type AdminShiftSummary, type AdminTemplate, type MoveTarget, type RosterPerson } from './admin/store.js'; import { DESK_WINDOW_DAYS, type AdminEvent, type HomeEvent, type HomeShift, type AdminShift, type AdminShiftSummary, type AdminTemplate, type MoveTarget, type RosterPerson } from './admin/store.js';
import { spotsSentence } from './schedule.js'; import { fillLabel, spotsSentence } from './schedule.js';
import type { EventValues, ShiftValues, TemplateValues } from './admin/forms.js'; import type { EventValues, ShiftValues, TemplateValues } from './admin/forms.js';
import { MAX_REMINDER_HOURS, MAX_RETENTION_MONTHS, type SettingsErrors, type SettingsForm } from './settings.js'; import { MAX_REMINDER_HOURS, MAX_RETENTION_MONTHS, type SettingsErrors, type SettingsForm } from './settings.js';
import type { AppConfig } from './config.js'; import type { AppConfig } from './config.js';
@@ -1251,7 +1251,7 @@ function ShiftNeedList(props: { config: AppConfig; shifts: HomeShift[]; today: s
function NeedShift(props: { config: AppConfig; shift: HomeShift; today: string }) { function NeedShift(props: { config: AppConfig; shift: HomeShift; today: string }) {
const shift = props.shift; const shift = props.shift;
const need = shift.full ? { tone: 'full' as const, text: 'Full' } : needCopy(shift.occupied, shift.capacity); const need = fillLabel(shift);
const when = shiftWhen(shift.date, shift.timeLabel, props.today); const when = shiftWhen(shift.date, shift.timeLabel, props.today);
return ( return (
<li> <li>
@@ -1333,16 +1333,6 @@ function eventSummary(event: HomeEvent, today: string): string {
return `Next shift ${when} · ${count}`; return `Next shift ${when} · ${count}`;
} }
function needCopy(occupied: number, capacity: number): { text: string; tone: 'open' | 'needs' } {
const filled = Math.min(capacity, Math.max(0, occupied));
const open = Math.max(0, capacity - filled);
const needs = open * 2 > capacity;
return {
tone: needs ? 'needs' : 'open',
text: needs ? `Needs ${open} · ${filled} of ${capacity}` : `${open} open · ${filled} of ${capacity}`,
};
}
function shiftWhen(date: string, timeLabel: string, today: string): string { function shiftWhen(date: string, timeLabel: string, today: string): string {
if (date === today) return `Today, ${timeLabel}`; if (date === today) return `Today, ${timeLabel}`;
return `${shortDate(date)}, ${timeLabel}`; return `${shortDate(date)}, ${timeLabel}`;
@@ -1555,7 +1545,7 @@ function EventNeedShift(props: { config: AppConfig; eventTitle: string; shift: A
const open = Boolean(props.now && !shift.cancelled && !ended); const open = Boolean(props.now && !shift.cancelled && !ended);
const time = clockLabel(shift.start); const time = clockLabel(shift.start);
const when = shiftWhen(shift.date, time, props.today); const when = shiftWhen(shift.date, time, props.today);
const need = ended ? { tone: 'hidden' as const, text: 'Ended' } : shift.occupied >= shift.capacity ? { tone: 'full' as const, text: 'Full' } : needCopy(shift.occupied, shift.capacity); const need = ended ? { tone: 'hidden' as const, text: 'Ended' } : fillLabel(shift);
const rowClass = ended ? 'desk-row is-ended' : 'desk-row'; const rowClass = ended ? 'desk-row is-ended' : 'desk-row';
return ( return (
<li class="need-pick"> <li class="need-pick">
@@ -2274,9 +2264,5 @@ function shiftClockLine(shift: Pick<AdminShiftSummary, 'date' | 'start' | 'end'>
function fillStatus(shift: Pick<AdminShiftSummary, 'capacity' | 'occupied' | 'cancelled'>): { tone: 'full' | 'open' | 'needs' | 'cancelled'; text: string } { function fillStatus(shift: Pick<AdminShiftSummary, 'capacity' | 'occupied' | 'cancelled'>): { tone: 'full' | 'open' | 'needs' | 'cancelled'; text: string } {
if (shift.cancelled) return { tone: 'cancelled', text: 'Cancelled' }; if (shift.cancelled) return { tone: 'cancelled', text: 'Cancelled' };
const filled = Math.min(shift.capacity, Math.max(0, shift.occupied)); return fillLabel(shift);
const open = Math.max(0, shift.capacity - filled);
if (open === 0) return { tone: 'full', text: `Full · ${filled} of ${shift.capacity}` };
if (open * 2 > shift.capacity) return { tone: 'needs', text: `Needs ${open} · ${filled} of ${shift.capacity}` };
return { tone: 'open', text: `${open} open · ${filled} of ${shift.capacity}` };
} }
+22 -2
View File
@@ -232,9 +232,29 @@ function dateChoice(shift: PublicShift): SignupDateChoice {
}; };
} }
export function spotsSentence(shift: Pick<PublicShift, 'occupied' | 'capacity'>): string { /** "4 of 6". Every page counts filled spots this one way. */
export function filledCount(shift: Pick<PublicShift, 'occupied' | 'capacity'>): string {
const filled = Math.min(shift.capacity, Math.max(0, shift.occupied)); const filled = Math.min(shift.capacity, Math.max(0, shift.occupied));
return `${filled}/${shift.capacity} spots filled`; return `${filled} of ${shift.capacity}`;
}
/** Volunteer pages and the roster heading: "4 of 6 spots filled". */
export function spotsSentence(shift: Pick<PublicShift, 'occupied' | 'capacity'>): string {
return `${filledCount(shift)} spots filled`;
}
export type FillTone = 'full' | 'open' | 'needs';
/**
* Coordinator list pills: the state first, then the count.
* "Full · 6 of 6" or "2 open · 4 of 6". A shift less than half filled uses the needs tone.
*/
export function fillLabel(shift: Pick<PublicShift, 'occupied' | 'capacity'>): { tone: FillTone; text: string } {
const filled = Math.min(shift.capacity, Math.max(0, shift.occupied));
const open = Math.max(0, shift.capacity - filled);
const count = filledCount(shift);
if (open === 0) return { tone: 'full', text: `Full · ${count}` };
return { tone: open * 2 > shift.capacity ? 'needs' : 'open', text: `${open} open · ${count}` };
} }
/** One roster line. A signup that holds several spots stays one name, with the count beside it. */ /** One roster line. A signup that holds several spots stays one name, with the count beside it. */
+2 -2
View File
@@ -266,7 +266,7 @@ describe('coordinator screens', () => {
expect(html).toContain('Today, 4:00 PM'); expect(html).toContain('Today, 4:00 PM');
expect(html).toContain('2 open · 4 of 6'); expect(html).toContain('2 open · 4 of 6');
expect(html).toContain('Tue, Oct 27, 4:00 PM'); expect(html).toContain('Tue, Oct 27, 4:00 PM');
expect(html).toContain('Needs 4 · 2 of 6'); expect(html).toContain('4 open · 2 of 6');
expect(html).toContain('Sat, Oct 24 Sorting crew is full.'); expect(html).toContain('Sat, Oct 24 Sorting crew is full.');
expect(html).toContain('Wed, Oct 28, 9:00 AM'); expect(html).toContain('Wed, Oct 28, 9:00 AM');
expect(html).not.toContain('Later shift'); expect(html).not.toContain('Later shift');
@@ -589,7 +589,7 @@ describe('coordinator screens', () => {
expect(roster).not.toContain('No-show'); expect(roster).not.toContain('No-show');
const sourceRoster = await (await app.request(`/admin/shifts/${sourceId}`, { headers: { cookie } })).text(); const sourceRoster = await (await app.request(`/admin/shifts/${sourceId}`, { headers: { cookie } })).text();
expect(sourceRoster).not.toContain(`/admin/signups/${signupId}/move`); expect(sourceRoster).not.toContain(`/admin/signups/${signupId}/move`);
expect(sourceRoster).toContain('0/2 spots filled'); expect(sourceRoster).toContain('0 of 2 spots filled');
expect(sourceRoster).toContain('event-pill is-open'); expect(sourceRoster).toContain('event-pill is-open');
const home = await (await app.request('/e/pantry?view=calendar')).text(); const home = await (await app.request('/e/pantry?view=calendar')).text();
const shiftPage = await (await app.request(`/s/${destinationId}`)).text(); const shiftPage = await (await app.request(`/s/${destinationId}`)).text();
+8 -8
View File
@@ -48,7 +48,7 @@ describe('manage-link cancellation', () => {
expect(before.created_at).toBe(before.updated_at); expect(before.created_at).toBe(before.updated_at);
const full = await app.request(`/s/${shiftId}`); const full = await app.request(`/s/${shiftId}`);
expect(await full.text()).toContain('1/1 spots filled'); expect(await full.text()).toContain('1 of 1 spots filled');
const cancelled = await postCancel(app, managePath, token); const cancelled = await postCancel(app, managePath, token);
expect(cancelled.status).toBe(303); expect(cancelled.status).toBe(303);
@@ -73,7 +73,7 @@ describe('manage-link cancellation', () => {
const open = await app.request(`/s/${shiftId}`); const open = await app.request(`/s/${shiftId}`);
const openHtml = await open.text(); const openHtml = await open.text();
expect(openHtml).toContain('0/1 spots filled'); expect(openHtml).toContain('0 of 1 spots filled');
expect(openHtml).not.toContain('pat.cancel@example.invalid'); expect(openHtml).not.toContain('pat.cancel@example.invalid');
const again = await postCancel(app, managePath, token, { ip: '203.0.113.71' }); const again = await postCancel(app, managePath, token, { ip: '203.0.113.71' });
@@ -87,7 +87,7 @@ describe('manage-link cancellation', () => {
{ status: 'cancelled' }, { status: 'cancelled' },
{ status: 'confirmed' }, { status: 'confirmed' },
]); ]);
expect((await (await app.request(`/s/${shiftId}`)).text())).toContain('1/1 spots filled'); expect((await (await app.request(`/s/${shiftId}`)).text())).toContain('1 of 1 spots filled');
const listed = await (await app.request('/?view=calendar')).text(); const listed = await (await app.request('/?view=calendar')).text();
expect(listed).toContain('Pat Cancel'); expect(listed).toContain('Pat Cancel');
expect(listed).not.toContain('pat.cancel@example.invalid'); expect(listed).not.toContain('pat.cancel@example.invalid');
@@ -215,8 +215,8 @@ describe('manage-link switch', () => {
const home = await (await app.request('/?view=calendar')).text(); const home = await (await app.request('/?view=calendar')).text();
expect(home).not.toContain('pat.switch@example.invalid'); expect(home).not.toContain('pat.switch@example.invalid');
expect(home).toContain('Pat Cancel'); expect(home).toContain('Pat Cancel');
expect(home).toContain('0/2 spots filled'); expect(home).toContain('0 of 2 spots filled');
expect(home).toContain('1/2 spots filled'); expect(home).toContain('1 of 2 spots filled');
const again = await postSwitch(app, managePath, html, String(destinationId)); const again = await postSwitch(app, managePath, html, String(destinationId));
expect(again.status).toBe(200); expect(again.status).toBe(200);
@@ -376,7 +376,7 @@ describe('manage-link party size', () => {
}]); }]);
expect(db.prepare('SELECT COUNT(*) AS n FROM contacts').get()).toEqual({ n: 1 }); expect(db.prepare('SELECT COUNT(*) AS n FROM contacts').get()).toEqual({ n: 1 });
expect(db.prepare("SELECT kind, status FROM outbox").all()).toEqual([{ kind: 'confirmation', status: 'pending' }]); expect(db.prepare("SELECT kind, status FROM outbox").all()).toEqual([{ kind: 'confirmation', status: 'pending' }]);
expect(await (await app.request(`/s/${shiftId}`)).text()).toContain('1/6 spots filled'); expect(await (await app.request(`/s/${shiftId}`)).text()).toContain('1 of 6 spots filled');
const board = await (await app.request('/?view=calendar')).text(); const board = await (await app.request('/?view=calendar')).text();
expect(board).toContain('Pat Party'); expect(board).toContain('Pat Party');
expect(board).not.toContain('Pat Party (4 people)'); expect(board).not.toContain('Pat Party (4 people)');
@@ -404,7 +404,7 @@ describe('manage-link party size', () => {
{ name: 'Pat Party', group_size: 3 }, { name: 'Pat Party', group_size: 3 },
{ name: 'Sam Other', group_size: 1 }, { name: 'Sam Other', group_size: 1 },
]); ]);
expect(await (await tight.app.request(`/s/${tight.shiftId}`)).text()).toContain('4/4 spots filled'); expect(await (await tight.app.request(`/s/${tight.shiftId}`)).text()).toContain('4 of 4 spots filled');
const wide = await buildApp({ capacity: 25 }); const wide = await buildApp({ capacity: 25 });
const opened = await postSignup(wide.app, wide.shiftId, { name: 'Pat Party', email: 'pat.wide@example.invalid', partySize: '1' }, '203.0.113.122'); const opened = await postSignup(wide.app, wide.shiftId, { name: 'Pat Party', email: 'pat.wide@example.invalid', partySize: '1' }, '203.0.113.122');
@@ -426,7 +426,7 @@ describe('manage-link party size', () => {
group_size: 20, group_size: 20,
status: 'confirmed', status: 'confirmed',
}]); }]);
expect(await (await wide.app.request(`/s/${wide.shiftId}`)).text()).toContain('20/25 spots filled'); expect(await (await wide.app.request(`/s/${wide.shiftId}`)).text()).toContain('20 of 25 spots filled');
}); });
it('refuses a party update that did not come from this signup page', async () => { it('refuses a party update that did not come from this signup page', async () => {
+36
View File
@@ -0,0 +1,36 @@
import fs from 'node:fs';
import path from 'node:path';
import { describe, expect, it } from 'vitest';
import { fillLabel, spotsSentence } from '../src/schedule.js';
const css = fs.readFileSync(path.join(import.meta.dirname, '..', 'public', 'css', 'app.css'), 'utf8');
/** Smallest text in the app is 14px. Footer fine print may use 13px. */
function pixels(value: string): number | null {
const match = /^([0-9.]+)(rem|px)$/.exec(value.trim());
if (!match) return null;
return match[2] === 'rem' ? Number(match[1]) * 16 : Number(match[1]);
}
describe('design rules', () => {
it('keeps text at 14px or larger', () => {
const small = [...css.matchAll(/font-size:\s*([^;]+);/g)]
.map((match) => match[1] ?? '')
.filter((value) => {
const px = pixels(value);
return px !== null && px < 14;
});
expect(small).toEqual([]);
expect(css).toContain('--hope-text-small: 0.875rem;');
expect(css).toContain('--hope-text-fine: 13px;');
});
it('counts filled spots the same way everywhere', () => {
expect(spotsSentence({ occupied: 4, capacity: 6 })).toBe('4 of 6 spots filled');
expect(spotsSentence({ occupied: 9, capacity: 6 })).toBe('6 of 6 spots filled');
expect(fillLabel({ occupied: 6, capacity: 6 })).toEqual({ tone: 'full', text: 'Full · 6 of 6' });
expect(fillLabel({ occupied: 4, capacity: 6 })).toEqual({ tone: 'open', text: '2 open · 4 of 6' });
expect(fillLabel({ occupied: 3, capacity: 6 })).toEqual({ tone: 'open', text: '3 open · 3 of 6' });
expect(fillLabel({ occupied: 2, capacity: 6 })).toEqual({ tone: 'needs', text: '4 open · 2 of 6' });
});
});
+7 -7
View File
@@ -40,8 +40,8 @@ describe('public pages', () => {
expect(home.headers.get('x-robots-tag')).toBe('noindex'); expect(home.headers.get('x-robots-tag')).toBe('noindex');
expect(html).toContain('class="roster-mark" src="/img/sunburst.png?v='); expect(html).toContain('class="roster-mark" src="/img/sunburst.png?v=');
expect(html).toContain('Live Greeting'); expect(html).toContain('Live Greeting');
expect(html).toContain('0/2 spots filled'); expect(html).toContain('0 of 2 spots filled');
expect(html).toContain('1/4 spots filled'); expect(html).toContain('1 of 4 spots filled');
expect(html).toContain('9:00 AM'); expect(html).toContain('9:00 AM');
expect(html).toContain('CDT'); expect(html).toContain('CDT');
expect(html).toContain('October 14'); expect(html).toContain('October 14');
@@ -131,8 +131,8 @@ describe('public pages', () => {
expect(calendar).toContain('October 2026'); expect(calendar).toContain('October 2026');
expect(calendar).toContain('Open Sorting'); expect(calendar).toContain('Open Sorting');
expect(calendar).toContain('Full Intake'); expect(calendar).toContain('Full Intake');
expect(calendar).toContain('1/3 spots filled'); expect(calendar).toContain('1 of 3 spots filled');
expect(calendar).toContain('1/1 spots filled'); expect(calendar).toContain('1 of 1 spots filled');
expect(calendar).toContain('class="cal-line"'); expect(calendar).toContain('class="cal-line"');
expect(calendar).toContain('Past Setup'); expect(calendar).toContain('Past Setup');
expect(calendar).toContain('class="cal-shift is-ended"'); expect(calendar).toContain('class="cal-shift is-ended"');
@@ -161,7 +161,7 @@ describe('public pages', () => {
const shiftMain = shiftHtml.slice(shiftHtml.indexOf('<main'), shiftHtml.indexOf('class="footer"')); const shiftMain = shiftHtml.slice(shiftHtml.indexOf('<main'), shiftHtml.indexOf('class="footer"'));
expect(shiftMain).not.toContain('Weekly pantry'); expect(shiftMain).not.toContain('Weekly pantry');
expect(shiftMain).not.toContain('sunburst'); expect(shiftMain).not.toContain('sunburst');
expect(shiftHtml).toContain('1/3 spots filled'); expect(shiftHtml).toContain('1 of 3 spots filled');
expect(shiftHtml).toContain('spots is-open'); expect(shiftHtml).toContain('spots is-open');
expect(shiftHtml).toContain('<form'); expect(shiftHtml).toContain('<form');
expect(shiftHtml).toContain('name="first_name"'); expect(shiftHtml).toContain('name="first_name"');
@@ -199,7 +199,7 @@ describe('public pages', () => {
const full = await app.request(`/s/${ids.full}`); const full = await app.request(`/s/${ids.full}`);
const fullHtml = await full.text(); const fullHtml = await full.text();
expect(fullHtml).toContain('1/1 spots filled'); expect(fullHtml).toContain('1 of 1 spots filled');
expect(fullHtml).toContain('spots is-full'); expect(fullHtml).toContain('spots is-full');
expect(fullHtml).not.toContain('<form'); expect(fullHtml).not.toContain('<form');
@@ -476,7 +476,7 @@ describe('public pages', () => {
const html = await (await app.request('/')).text(); const html = await (await app.request('/')).text();
const start = html.indexOf('Full Wednesday'); const start = html.indexOf('Full Wednesday');
const pane = html.slice(html.lastIndexOf('<section class="shift-pane"', start), html.indexOf('</section>', start)); const pane = html.slice(html.lastIndexOf('<section class="shift-pane"', start), html.indexOf('</section>', start));
expect(pane).toContain('1/1 spots filled'); expect(pane).toContain('1 of 1 spots filled');
expect(pane).toContain('class="btn-card is-static"'); expect(pane).toContain('class="btn-card is-static"');
expect(pane).toContain('>Full</span>'); expect(pane).toContain('>Full</span>');
expect(pane).toContain('Not accepting more signups'); expect(pane).toContain('Not accepting more signups');
+1 -1
View File
@@ -319,7 +319,7 @@ describe('capacity-safe signup', () => {
expect(manageHtml).toContain('People'); expect(manageHtml).toContain('People');
expect(manageHtml).toContain('>3<'); expect(manageHtml).toContain('>3<');
const shiftHtml = await (await app.request(`/s/${shiftId}`)).text(); const shiftHtml = await (await app.request(`/s/${shiftId}`)).text();
expect(shiftHtml).toContain('3/4 spots filled'); expect(shiftHtml).toContain('3 of 4 spots filled');
const board = await (await app.request('/?view=calendar')).text(); const board = await (await app.request('/?view=calendar')).text();
expect(board).toContain('Pat Review (3 people)'); expect(board).toContain('Pat Review (3 people)');
expect(board).not.toContain('Pat Review (3 people), Pat Review'); expect(board).not.toContain('Pat Review (3 people), Pat Review');