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.
This commit is contained in:
blake committed 2026-11-02 11:28:24 -06:00
1 parent fb30b6e92b
commit e7fc1e03ae
4 files changed
+17 -2

No files matched your search

+1
View File
@@ -7,3 +7,4 @@ data/
!.env.production.example
npm-debug.log*
*.log
.cursor
+4
View File
@@ -488,6 +488,10 @@ h3 {
margin: 0.3rem 0;
}
.when-date {
display: block;
}
.description {
white-space: pre-wrap;
}
+7 -2
View File
@@ -742,7 +742,7 @@ function ShiftPane(props: { config: AppConfig; shift: PublicShift }) {
<section class={shift.ended ? 'shift-pane is-ended' : 'shift-pane'}>
<div class="shift-pane-body">
<h3>{shift.role}</h3>
<ShiftWhen shift={shift} />
<ShiftWhen shift={shift} showDate={false} />
<p class="status">{shift.inProgress ? 'In progress' : ''}</p>
<Spots shift={shift} />
<h4 class="roster-label">Volunteers</h4>
@@ -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 (
<p class="when">
{props.showDate === false ? null : (
<time class="when-date" dateTime={shift.when.date}>
{shift.when.dateLabel}
</time>
)}
<time dateTime={shift.startsAtUtc}>{shift.when.startLabel}</time>
{' to '}
{shift.when.sameDay ? null : (
+5
View File
@@ -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('<main'), shiftHtml.indexOf('class="footer"'));
expect(shiftMain).not.toContain('Weekly pantry');
@@ -466,6 +469,8 @@ describe('public pages', () => {
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 () => {