feat: enhance shift display with date grouping and improved styles
Refactored the shift display to group shifts by date, improving clarity and organization. Introduced new styles for better visual distinction of shifts, including indicators for full and open shifts. Updated the AdminHome component to utilize the new grouping logic and adjusted related styles in app.css for a cohesive user experience.
This commit is contained in:
1 parent
0376681a3d
commit
63aab5b6e0
2 files changed
+167
-23
No files matched your search
+85
-1
@@ -2643,15 +2643,17 @@ button.btn-quiet::before {
|
||||
|
||||
.desk-panel-head {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 0.75rem 1rem;
|
||||
}
|
||||
|
||||
.desk-panel-aside {
|
||||
margin: 0;
|
||||
margin: 0 0 0 auto;
|
||||
color: #7d8b99;
|
||||
font-size: 0.92rem;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.desk-panel-head .btn {
|
||||
@@ -2666,6 +2668,70 @@ button.btn-quiet::before {
|
||||
transform: none;
|
||||
}
|
||||
|
||||
.need-days {
|
||||
display: grid;
|
||||
gap: 1rem 1.15rem;
|
||||
align-items: start;
|
||||
}
|
||||
|
||||
.need-day {
|
||||
display: grid;
|
||||
gap: 0.4rem;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.need-day-head {
|
||||
display: flex;
|
||||
align-items: baseline;
|
||||
justify-content: space-between;
|
||||
gap: 0.5rem 0.75rem;
|
||||
padding: 0 0.15rem;
|
||||
}
|
||||
|
||||
.need-day-head h3 {
|
||||
margin: 0;
|
||||
font-size: 1.02rem;
|
||||
font-weight: 650;
|
||||
}
|
||||
|
||||
.need-day.is-today .need-day-head h3 {
|
||||
background: var(--hope-yellow);
|
||||
border-radius: 999px;
|
||||
padding: 0.08rem 0.55rem;
|
||||
}
|
||||
|
||||
.need-day-count {
|
||||
margin: 0;
|
||||
font-size: 0.82rem;
|
||||
font-weight: 650;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.need-day-count.is-needs {
|
||||
color: #8a3d36;
|
||||
}
|
||||
|
||||
.need-day-count.is-open {
|
||||
color: #6a5314;
|
||||
}
|
||||
|
||||
.need-day .desk-rows {
|
||||
gap: 0.35rem;
|
||||
}
|
||||
|
||||
.need-day .desk-row {
|
||||
min-height: 3.35rem;
|
||||
padding: 0.48rem 0.75rem;
|
||||
}
|
||||
|
||||
.need-day .desk-row-main {
|
||||
gap: 0.75rem;
|
||||
}
|
||||
|
||||
.need-day .desk-row-when {
|
||||
min-width: 4.8rem;
|
||||
}
|
||||
|
||||
.desk-rows {
|
||||
list-style: none;
|
||||
display: grid;
|
||||
@@ -2776,6 +2842,20 @@ button.btn-quiet::before {
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.need-pill.is-full {
|
||||
background: #e3f6e8;
|
||||
color: #1f7a43;
|
||||
}
|
||||
|
||||
.need-day .desk-row.is-covered {
|
||||
background: #f3faf5;
|
||||
}
|
||||
|
||||
.need-day .desk-row.is-covered:hover,
|
||||
.need-day .desk-row.is-covered:focus-visible {
|
||||
background: #e5f6eb;
|
||||
}
|
||||
|
||||
.desk-full {
|
||||
list-style: none;
|
||||
display: grid;
|
||||
@@ -2906,6 +2986,10 @@ button.btn-quiet::before {
|
||||
.desk-split {
|
||||
grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
|
||||
}
|
||||
|
||||
.need-days {
|
||||
grid-template-columns: repeat(auto-fit, minmax(28rem, 1fr));
|
||||
}
|
||||
}
|
||||
|
||||
@media (max-width: 42em) {
|
||||
|
||||
+82
-22
@@ -232,7 +232,9 @@ export function AdminHome(props: {
|
||||
? 'last'
|
||||
: 'custom';
|
||||
const openShifts = props.shifts.filter((shift) => !shift.full);
|
||||
const fullShifts = props.shifts.filter((shift) => shift.full);
|
||||
const openDates = new Set(openShifts.map((shift) => shift.date));
|
||||
const dayShifts = props.shifts.filter((shift) => openDates.has(shift.date));
|
||||
const fullOnly = props.shifts.filter((shift) => shift.full && !openDates.has(shift.date));
|
||||
return (
|
||||
<>
|
||||
<header class="desk-intro desk-home-intro">
|
||||
@@ -261,8 +263,8 @@ export function AdminHome(props: {
|
||||
<h2 id="needs-heading">Shifts that need volunteers</h2>
|
||||
<p class="desk-panel-aside">Next 2 weeks</p>
|
||||
</div>
|
||||
{openShifts.length === 0 ? <p class="empty">No open shifts in the next 2 weeks.</p> : <ShiftNeedList config={props.config} shifts={openShifts} today={clock.date} />}
|
||||
{fullShifts.length > 0 ? <FullShiftNotes shifts={fullShifts} /> : null}
|
||||
{openShifts.length === 0 ? <p class="empty">No open shifts in the next 2 weeks.</p> : <ShiftNeedList config={props.config} shifts={dayShifts} today={clock.date} />}
|
||||
{fullOnly.length > 0 ? <FullShiftNotes shifts={fullOnly} /> : null}
|
||||
</section>
|
||||
<div class="desk-split">
|
||||
<section class="desk-panel" aria-labelledby="events-heading">
|
||||
@@ -1095,25 +1097,44 @@ function EventList(props: { config: AppConfig; events: HomeEvent[]; today: strin
|
||||
|
||||
function ShiftNeedList(props: { config: AppConfig; shifts: HomeShift[]; today: string }) {
|
||||
return (
|
||||
<ul class="desk-rows">
|
||||
{props.shifts.map((shift) => {
|
||||
const need = needCopy(shift.occupied, shift.capacity);
|
||||
<div class="need-days">
|
||||
{groupShiftsByDate(props.shifts).map((day) => {
|
||||
const summary = dayOpenLabel(day.shifts);
|
||||
return (
|
||||
<li key={shift.id}>
|
||||
<a class="desk-row" href={appPath(props.config, `/admin/shifts/${shift.id}`)}>
|
||||
<span class="desk-row-main">
|
||||
<span class="desk-row-when">{shiftWhen(shift.date, shift.timeLabel, props.today)}</span>
|
||||
<span class="desk-row-copy">
|
||||
<strong>{shift.role}</strong>
|
||||
<span>{shift.eventTitle}</span>
|
||||
</span>
|
||||
</span>
|
||||
<span class={need.tone === 'needs' ? 'need-pill is-needs' : 'need-pill is-open'}>{need.text}</span>
|
||||
</a>
|
||||
</li>
|
||||
<section class={day.date === props.today ? 'need-day is-today' : 'need-day'} aria-labelledby={`need-day-${day.date}`} key={day.date}>
|
||||
<div class="need-day-head">
|
||||
<h3 id={`need-day-${day.date}`}>{dayHeading(day.date, props.today)}</h3>
|
||||
<p class={`need-day-count is-${summary.tone}`}>{summary.text}</p>
|
||||
</div>
|
||||
<ul class="desk-rows">
|
||||
{day.shifts.map((shift) => (
|
||||
<NeedShift key={shift.id} config={props.config} shift={shift} today={props.today} />
|
||||
))}
|
||||
</ul>
|
||||
</section>
|
||||
);
|
||||
})}
|
||||
</ul>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
function NeedShift(props: { config: AppConfig; shift: HomeShift; today: string }) {
|
||||
const shift = props.shift;
|
||||
const need = shift.full ? { tone: 'full' as const, text: 'Full' } : needCopy(shift.occupied, shift.capacity);
|
||||
const when = shiftWhen(shift.date, shift.timeLabel, props.today);
|
||||
return (
|
||||
<li>
|
||||
<a class={shift.full ? 'desk-row is-covered' : 'desk-row'} href={appPath(props.config, `/admin/shifts/${shift.id}`)} aria-label={`${when}. ${shift.role}. ${shift.eventTitle}. ${need.text}.`}>
|
||||
<span class="desk-row-main">
|
||||
<span class="desk-row-when">{shift.timeLabel}</span>
|
||||
<span class="desk-row-copy">
|
||||
<strong>{shift.role}</strong>
|
||||
<span>{shift.eventTitle}</span>
|
||||
</span>
|
||||
</span>
|
||||
<span class={`need-pill is-${need.tone}`}>{need.text}</span>
|
||||
</a>
|
||||
</li>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1122,9 +1143,7 @@ function FullShiftNotes(props: { shifts: HomeShift[] }) {
|
||||
<ul class="desk-full">
|
||||
{props.shifts.map((shift) => (
|
||||
<li key={shift.id}>
|
||||
<svg class="desk-full-check" viewBox="0 0 16 16" aria-hidden="true" focusable="false">
|
||||
<path d="M3.2 8.4 6.4 11.5 12.8 4.8" />
|
||||
</svg>
|
||||
<FullMark />
|
||||
{shortDate(shift.date)} {shift.role} is full.
|
||||
</li>
|
||||
))}
|
||||
@@ -1132,6 +1151,47 @@ function FullShiftNotes(props: { shifts: HomeShift[] }) {
|
||||
);
|
||||
}
|
||||
|
||||
function FullMark() {
|
||||
return (
|
||||
<svg class="desk-full-check" viewBox="0 0 16 16" aria-hidden="true" focusable="false">
|
||||
<path d="M3.2 8.4 6.4 11.5 12.8 4.8" />
|
||||
</svg>
|
||||
);
|
||||
}
|
||||
|
||||
function groupShiftsByDate(shifts: HomeShift[]): { date: string; shifts: HomeShift[] }[] {
|
||||
const groups: { date: string; shifts: HomeShift[] }[] = [];
|
||||
for (const shift of shifts) {
|
||||
const last = groups.at(-1);
|
||||
if (last?.date === shift.date) last.shifts.push(shift);
|
||||
else groups.push({ date: shift.date, shifts: [shift] });
|
||||
}
|
||||
return groups;
|
||||
}
|
||||
|
||||
function dayOpenLabel(shifts: HomeShift[]): { text: string; tone: 'open' | 'needs' } {
|
||||
let open = 0;
|
||||
let needs = false;
|
||||
for (const shift of shifts) {
|
||||
if (shift.full) continue;
|
||||
const filled = Math.min(shift.capacity, Math.max(0, shift.occupied));
|
||||
const spots = Math.max(0, shift.capacity - filled);
|
||||
open += spots;
|
||||
if (spots * 2 > shift.capacity) needs = true;
|
||||
}
|
||||
return {
|
||||
tone: needs ? 'needs' : 'open',
|
||||
text: open === 1 ? '1 open' : `${open} open`,
|
||||
};
|
||||
}
|
||||
|
||||
function dayHeading(date: string, today: string): string {
|
||||
if (date !== today) return shortDate(date);
|
||||
const plain = Temporal.PlainDate.from(date);
|
||||
const month = SHORT_MONTHS[plain.month - 1] ?? 'Month';
|
||||
return `Today, ${month} ${plain.day}`;
|
||||
}
|
||||
|
||||
function eventSummary(event: HomeEvent, today: string): string {
|
||||
const count = event.shiftCount === 1 ? '1 shift' : `${event.shiftCount} shifts`;
|
||||
if (!event.nextShift) return event.shiftCount === 0 ? 'No shifts yet' : count;
|
||||
|
||||
Reference in new issue
Block a user