From e7fc1e03ae224b70d447d8e0aefa90a0494fcbac Mon Sep 17 00:00:00 2001 From: blake Date: Mon, 2 Nov 2026 11:28:24 -0600 Subject: [PATCH] feat: add date display toggle for shifts and update styles Enhanced the ShiftWhen component to conditionally render the date based on a new prop, showDate. Updated app.css to include a new class for date styling. Modified tests to verify the presence and absence of date information in the rendered output. --- .gitignore | 1 + public/css/app.css | 4 ++++ src/pages.tsx | 9 +++++++-- tests/public-pages.test.ts | 5 +++++ 4 files changed, 17 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index c876e4f..8de8ede 100644 --- a/.gitignore +++ b/.gitignore @@ -7,3 +7,4 @@ data/ !.env.production.example npm-debug.log* *.log +.cursor diff --git a/public/css/app.css b/public/css/app.css index e042a9b..6aa5a0c 100644 --- a/public/css/app.css +++ b/public/css/app.css @@ -488,6 +488,10 @@ h3 { margin: 0.3rem 0; } +.when-date { + display: block; +} + .description { white-space: pre-wrap; } diff --git a/src/pages.tsx b/src/pages.tsx index b81a47e..8a9da2c 100644 --- a/src/pages.tsx +++ b/src/pages.tsx @@ -742,7 +742,7 @@ function ShiftPane(props: { config: AppConfig; shift: PublicShift }) {

{shift.role}

- +

{shift.inProgress ? 'In progress' : ''}

Volunteers

@@ -978,10 +978,15 @@ function RosterNames(props: { config: AppConfig; shiftId: number; names: string[ ); } -function ShiftWhen(props: { shift: PublicShift }) { +function ShiftWhen(props: { shift: PublicShift; showDate?: boolean }) { const shift = props.shift; return (

+ {props.showDate === false ? null : ( + + )} {' to '} {shift.when.sameDay ? null : ( diff --git a/tests/public-pages.test.ts b/tests/public-pages.test.ts index 7755cfc..a8f136b 100644 --- a/tests/public-pages.test.ts +++ b/tests/public-pages.test.ts @@ -150,6 +150,9 @@ describe('public pages', () => { const shiftHtml = await shift.text(); expect(shift.status).toBe(200); expect(shiftHtml).toContain('Open Sorting'); + expect(shiftHtml).toContain('Thursday, October 15, 2026'); + expect(shiftHtml).toContain('dateTime="2026-10-15"'); + expect(shiftHtml).toContain('9:00 AM'); expect(shiftHtml).not.toContain('class="crumb"'); const shiftMain = shiftHtml.slice(shiftHtml.indexOf(' { expect(openPane).toContain('>Sign up'); expect(openPane).toContain('href="/s/'); expect(openPane).toContain('data-signup=""'); + expect(openPane).toContain('9:00 AM'); + expect(openPane).not.toContain('Wednesday, October 21, 2026'); }); it('keeps a finished shift on today and drops that day at midnight', async () => {