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:
1 parent
fb30b6e92b
commit
e7fc1e03ae
4 files changed
+17
-2
No files matched your search
@@ -7,3 +7,4 @@ data/
|
|||||||
!.env.production.example
|
!.env.production.example
|
||||||
npm-debug.log*
|
npm-debug.log*
|
||||||
*.log
|
*.log
|
||||||
|
.cursor
|
||||||
@@ -488,6 +488,10 @@ h3 {
|
|||||||
margin: 0.3rem 0;
|
margin: 0.3rem 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.when-date {
|
||||||
|
display: block;
|
||||||
|
}
|
||||||
|
|
||||||
.description {
|
.description {
|
||||||
white-space: pre-wrap;
|
white-space: pre-wrap;
|
||||||
}
|
}
|
||||||
|
|||||||
+7
-2
@@ -742,7 +742,7 @@ function ShiftPane(props: { config: AppConfig; shift: PublicShift }) {
|
|||||||
<section class={shift.ended ? 'shift-pane is-ended' : 'shift-pane'}>
|
<section class={shift.ended ? 'shift-pane is-ended' : 'shift-pane'}>
|
||||||
<div class="shift-pane-body">
|
<div class="shift-pane-body">
|
||||||
<h3>{shift.role}</h3>
|
<h3>{shift.role}</h3>
|
||||||
<ShiftWhen shift={shift} />
|
<ShiftWhen shift={shift} showDate={false} />
|
||||||
<p class="status">{shift.inProgress ? 'In progress' : ''}</p>
|
<p class="status">{shift.inProgress ? 'In progress' : ''}</p>
|
||||||
<Spots shift={shift} />
|
<Spots shift={shift} />
|
||||||
<h4 class="roster-label">Volunteers</h4>
|
<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;
|
const shift = props.shift;
|
||||||
return (
|
return (
|
||||||
<p class="when">
|
<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>
|
<time dateTime={shift.startsAtUtc}>{shift.when.startLabel}</time>
|
||||||
{' to '}
|
{' to '}
|
||||||
{shift.when.sameDay ? null : (
|
{shift.when.sameDay ? null : (
|
||||||
|
|||||||
@@ -150,6 +150,9 @@ describe('public pages', () => {
|
|||||||
const shiftHtml = await shift.text();
|
const shiftHtml = await shift.text();
|
||||||
expect(shift.status).toBe(200);
|
expect(shift.status).toBe(200);
|
||||||
expect(shiftHtml).toContain('Open Sorting');
|
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"');
|
expect(shiftHtml).not.toContain('class="crumb"');
|
||||||
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');
|
||||||
@@ -466,6 +469,8 @@ describe('public pages', () => {
|
|||||||
expect(openPane).toContain('>Sign up');
|
expect(openPane).toContain('>Sign up');
|
||||||
expect(openPane).toContain('href="/s/');
|
expect(openPane).toContain('href="/s/');
|
||||||
expect(openPane).toContain('data-signup=""');
|
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 () => {
|
it('keeps a finished shift on today and drops that day at midnight', async () => {
|
||||||
|
|||||||
Reference in new issue
Block a user