ci / check (push) Successful in 50s
- replace default Onyx surfaces with paper/ink, signal orange and Archivo - make /plan answer peak, staff-hours, cost vs flat and coverage above the fold - add the weekly shift board, shared plan helpers and a pulse line - rebuild /live as a phone-first dark board and /stage as a full-bleed projector - label the real 14-20 Nov window; remove 'next week' claims - keep Onyx components, SSR, live scenario updates and accessible states
420 lines
9.4 KiB
Vue
420 lines
9.4 KiB
Vue
<script setup lang="ts">
|
||
import type { Point } from '#shared/types'
|
||
import type { PlanDay } from '~/utils/plan'
|
||
|
||
const props = withDefaults(
|
||
defineProps<{
|
||
days: PlanDay[]
|
||
peakDate?: string
|
||
selectedDate?: string
|
||
interactive?: boolean
|
||
dense?: boolean
|
||
large?: boolean
|
||
dark?: boolean
|
||
showPulse?: boolean
|
||
label?: string
|
||
}>(),
|
||
{
|
||
peakDate: '',
|
||
selectedDate: '',
|
||
interactive: false,
|
||
dense: false,
|
||
large: false,
|
||
dark: false,
|
||
showPulse: false,
|
||
label: 'Weekly shift board',
|
||
},
|
||
)
|
||
|
||
const emit = defineEmits<{ select: [date: string] }>()
|
||
|
||
function duration(shift: { start: string; end: string }): number {
|
||
return Math.max(0.5, Number(shift.end.slice(0, 2)) - Number(shift.start.slice(0, 2)))
|
||
}
|
||
|
||
function pulseOf(day: PlanDay): Point[] {
|
||
return day.hours.map((hour) => ({ t: hour.t, v: hour.footfall }))
|
||
}
|
||
|
||
function dayLabel(day: PlanDay): string {
|
||
const blocks = day.shifts.map((shift) => `${shift.start}–${shift.end}: ${shift.staff} staff`).join(', ')
|
||
return `${day.weekdayLong} ${day.dayNumber} ${day.month}: ${blocks || 'no shifts'}. ${day.staffHours} staff-hours.`
|
||
}
|
||
|
||
function activate(day: PlanDay) {
|
||
if (props.interactive) emit('select', day.date)
|
||
}
|
||
</script>
|
||
|
||
<template>
|
||
<div
|
||
class="pc-board"
|
||
:class="{
|
||
'pc-board--dense': dense,
|
||
'pc-board--large': large,
|
||
'pc-board--dark': dark,
|
||
'pc-board--interactive': interactive,
|
||
}"
|
||
role="group"
|
||
:aria-label="label"
|
||
>
|
||
<component
|
||
:is="interactive ? 'button' : 'div'"
|
||
v-for="day in days"
|
||
:key="day.date"
|
||
class="pc-board__day"
|
||
:class="{
|
||
'pc-board__day--peak': day.date === peakDate,
|
||
'pc-board__day--selected': day.date === selectedDate,
|
||
}"
|
||
:type="interactive ? 'button' : undefined"
|
||
:aria-pressed="interactive ? day.date === selectedDate : undefined"
|
||
:aria-label="interactive ? dayLabel(day) : undefined"
|
||
@click="activate(day)"
|
||
>
|
||
<span class="pc-board__head">
|
||
<span class="pc-board__weekday">{{ day.weekday }}</span>
|
||
<span class="pc-board__date">{{ day.dayNumber }}</span>
|
||
<span v-if="day.date === peakDate" class="pc-board__peak" aria-hidden="true">Peak</span>
|
||
</span>
|
||
|
||
<PulseLine
|
||
v-if="showPulse && day.hours.length"
|
||
class="pc-board__pulse"
|
||
:points="pulseOf(day)"
|
||
:height="dense ? 16 : large ? 38 : 22"
|
||
:show-peak="false"
|
||
:label="`Forecast footfall for ${day.weekdayLong} ${day.dayNumber}`"
|
||
/>
|
||
|
||
<span class="pc-board__track" aria-hidden="true">
|
||
<span
|
||
v-for="shift in day.shifts"
|
||
:key="`${shift.date}-${shift.start}`"
|
||
class="pc-board__block"
|
||
:class="{ 'pc-board__block--short': duration(shift) < 3 }"
|
||
:style="{ flex: `${duration(shift)} 1 0` }"
|
||
>
|
||
<span class="pc-board__staff">{{ shift.staff }}</span>
|
||
<span v-if="!dense" class="pc-board__time">{{ shift.start }}–{{ shift.end }}</span>
|
||
</span>
|
||
<span v-if="!day.shifts.length" class="pc-board__empty">No shifts</span>
|
||
</span>
|
||
|
||
<span class="pc-board__foot" aria-hidden="true">
|
||
<span class="pc-board__hours">{{ day.staffHours }}h</span>
|
||
<span v-if="!dense" class="pc-board__peakstaff">{{ day.peakStaff }} peak</span>
|
||
</span>
|
||
</component>
|
||
</div>
|
||
</template>
|
||
|
||
<style scoped>
|
||
.pc-board {
|
||
--pc-board-block: var(--pc-paper-2, #e9e3d7);
|
||
--pc-board-border: var(--pc-line-strong, #a99f8e);
|
||
--pc-board-text: var(--pc-ink, #16130f);
|
||
display: grid;
|
||
grid-auto-flow: column;
|
||
grid-auto-columns: minmax(0, 1fr);
|
||
gap: 1px;
|
||
width: 100%;
|
||
background: var(--pc-line, #d3caba);
|
||
border-block: 1px solid var(--pc-board-border);
|
||
}
|
||
|
||
.pc-board--dense {
|
||
gap: 1px;
|
||
}
|
||
|
||
.pc-board__day {
|
||
display: flex;
|
||
min-width: 0;
|
||
min-height: 0;
|
||
flex-direction: column;
|
||
gap: 0.35rem;
|
||
padding: 0.55rem 0.5rem 0.5rem;
|
||
border: 0;
|
||
background: var(--pc-paper, #f4efe6);
|
||
color: var(--pc-board-text);
|
||
font: inherit;
|
||
text-align: left;
|
||
}
|
||
|
||
.pc-board--interactive .pc-board__day {
|
||
min-height: 44px;
|
||
cursor: pointer;
|
||
transition: background-color 160ms ease, outline-color 160ms ease;
|
||
}
|
||
|
||
.pc-board--interactive .pc-board__day:hover {
|
||
background: var(--pc-paper-2, #e9e3d7);
|
||
}
|
||
|
||
.pc-board__day:focus-visible {
|
||
outline: 2px solid var(--pc-focus, #b63a00);
|
||
outline-offset: -3px;
|
||
z-index: 1;
|
||
}
|
||
|
||
.pc-board__day--peak {
|
||
background: var(--pc-signal-wash, #ffe4d6);
|
||
box-shadow: inset 0 3px 0 var(--pc-signal, #e84100);
|
||
}
|
||
|
||
.pc-board__day--selected {
|
||
outline: 2px solid var(--pc-ink, #16130f);
|
||
outline-offset: -2px;
|
||
}
|
||
|
||
.pc-board__head {
|
||
display: flex;
|
||
align-items: baseline;
|
||
gap: 0.3rem;
|
||
min-width: 0;
|
||
}
|
||
|
||
.pc-board__weekday {
|
||
color: var(--pc-muted, #6e665a);
|
||
font-size: 0.62rem;
|
||
font-weight: 700;
|
||
letter-spacing: 0.08em;
|
||
text-transform: uppercase;
|
||
}
|
||
|
||
.pc-board__date {
|
||
font-size: 0.95rem;
|
||
font-weight: 800;
|
||
letter-spacing: -0.02em;
|
||
font-variant-numeric: tabular-nums;
|
||
}
|
||
|
||
.pc-board__peak {
|
||
margin-inline-start: auto;
|
||
color: var(--pc-signal-text, #b63a00);
|
||
font-size: 0.55rem;
|
||
font-weight: 800;
|
||
letter-spacing: 0.08em;
|
||
text-transform: uppercase;
|
||
}
|
||
|
||
.pc-board__pulse {
|
||
--pc-pulse-color: var(--pc-board-border);
|
||
margin-block: 0.1rem;
|
||
}
|
||
|
||
.pc-board__track {
|
||
display: flex;
|
||
min-height: 9rem;
|
||
flex: 1 1 auto;
|
||
flex-direction: column;
|
||
gap: 2px;
|
||
}
|
||
|
||
.pc-board__block {
|
||
display: flex;
|
||
min-height: 0;
|
||
flex-direction: column;
|
||
align-items: flex-start;
|
||
justify-content: center;
|
||
gap: 0.05rem;
|
||
padding: 0.2rem 0.35rem;
|
||
border: 1px solid var(--pc-board-border);
|
||
background: var(--pc-board-block);
|
||
color: var(--pc-board-text);
|
||
overflow: hidden;
|
||
}
|
||
|
||
.pc-board__day--peak .pc-board__block {
|
||
border-color: var(--pc-signal-text, #b63a00);
|
||
background: var(--pc-signal, #e84100);
|
||
color: var(--pc-ink, #16130f);
|
||
}
|
||
|
||
.pc-board__staff {
|
||
font-size: 1.35rem;
|
||
font-weight: 800;
|
||
line-height: 0.9;
|
||
letter-spacing: -0.03em;
|
||
font-variant-numeric: tabular-nums;
|
||
}
|
||
|
||
.pc-board__time {
|
||
color: var(--pc-ink-2, #2a261f);
|
||
font-size: 0.55rem;
|
||
font-weight: 650;
|
||
letter-spacing: 0.02em;
|
||
font-variant-numeric: tabular-nums;
|
||
white-space: nowrap;
|
||
}
|
||
|
||
.pc-board__day--peak .pc-board__time {
|
||
color: var(--pc-ink, #16130f);
|
||
}
|
||
|
||
.pc-board__block--short .pc-board__time {
|
||
display: none;
|
||
}
|
||
|
||
.pc-board__block--short .pc-board__staff {
|
||
font-size: 1.05rem;
|
||
}
|
||
|
||
.pc-board__empty {
|
||
display: grid;
|
||
flex: 1;
|
||
place-items: center;
|
||
border: 1px dashed var(--pc-board-border);
|
||
color: var(--pc-muted, #6e665a);
|
||
font-size: 0.65rem;
|
||
}
|
||
|
||
.pc-board__foot {
|
||
display: flex;
|
||
align-items: baseline;
|
||
justify-content: space-between;
|
||
gap: 0.2rem;
|
||
margin-top: auto;
|
||
color: var(--pc-muted, #6e665a);
|
||
font-size: 0.62rem;
|
||
font-variant-numeric: tabular-nums;
|
||
}
|
||
|
||
.pc-board__hours {
|
||
color: var(--pc-board-text);
|
||
font-weight: 700;
|
||
}
|
||
|
||
.pc-board__peakstaff {
|
||
white-space: nowrap;
|
||
}
|
||
|
||
/* Dense phone/stage variants */
|
||
.pc-board--dense .pc-board__day {
|
||
padding: 0.35rem 0.25rem 0.3rem;
|
||
gap: 0.2rem;
|
||
}
|
||
|
||
.pc-board--dense .pc-board__track {
|
||
min-height: 6.5rem;
|
||
}
|
||
|
||
.pc-board--dense .pc-board__staff {
|
||
font-size: 0.9rem;
|
||
}
|
||
|
||
.pc-board--dense .pc-board__weekday {
|
||
font-size: 0.52rem;
|
||
}
|
||
|
||
.pc-board--dense .pc-board__date {
|
||
font-size: 0.78rem;
|
||
}
|
||
|
||
.pc-board--dense .pc-board__foot {
|
||
font-size: 0.52rem;
|
||
}
|
||
|
||
.pc-board--dense .pc-board__peak {
|
||
display: none;
|
||
}
|
||
|
||
/* Projector variant */
|
||
.pc-board--large {
|
||
gap: 2px;
|
||
border-block-width: 3px;
|
||
}
|
||
|
||
.pc-board--large .pc-board__day {
|
||
gap: 0.7rem;
|
||
padding: 1rem 0.9rem 0.9rem;
|
||
}
|
||
|
||
.pc-board--large .pc-board__weekday {
|
||
font-size: 1rem;
|
||
}
|
||
|
||
.pc-board--large .pc-board__date {
|
||
font-size: 1.9rem;
|
||
}
|
||
|
||
.pc-board--large .pc-board__peak {
|
||
display: none;
|
||
}
|
||
|
||
.pc-board--large .pc-board__track {
|
||
min-height: 21rem;
|
||
}
|
||
|
||
.pc-board--large .pc-board__staff {
|
||
font-size: 3rem;
|
||
}
|
||
|
||
.pc-board--large .pc-board__time {
|
||
display: none;
|
||
}
|
||
|
||
.pc-board--large .pc-board__block {
|
||
padding: 0.55rem 0.7rem;
|
||
}
|
||
|
||
.pc-board--large .pc-board__foot {
|
||
font-size: 1rem;
|
||
}
|
||
|
||
/* Dark board variant */
|
||
.pc-board--dark {
|
||
--pc-board-block: var(--pc-dark-2, #191c18);
|
||
--pc-board-border: var(--pc-dark-line, #343a31);
|
||
--pc-board-text: var(--pc-paper, #f4efe6);
|
||
background: var(--pc-dark-line, #343a31);
|
||
border-color: var(--pc-dark-line, #343a31);
|
||
}
|
||
|
||
.pc-board--dark .pc-board__day {
|
||
background: var(--pc-dark, #0e100e);
|
||
}
|
||
|
||
.pc-board--dark.pc-board--interactive .pc-board__day:hover {
|
||
background: var(--pc-dark-2, #191c18);
|
||
}
|
||
|
||
.pc-board--dark .pc-board__day--peak {
|
||
background: color-mix(in srgb, var(--pc-signal-bright, #ff6a2a) 12%, var(--pc-dark, #0e100e));
|
||
box-shadow: inset 0 3px 0 var(--pc-signal-bright, #ff6a2a);
|
||
}
|
||
|
||
.pc-board--dark .pc-board__day--selected {
|
||
outline-color: var(--pc-paper, #f4efe6);
|
||
}
|
||
|
||
.pc-board--dark .pc-board__weekday,
|
||
.pc-board--dark .pc-board__foot,
|
||
.pc-board--dark .pc-board__peakstaff,
|
||
.pc-board--dark .pc-board__time {
|
||
color: var(--pc-dark-muted, #b4ae9f);
|
||
}
|
||
|
||
.pc-board--dark .pc-board__peak {
|
||
color: var(--pc-signal-bright, #ff6a2a);
|
||
}
|
||
|
||
.pc-board--dark .pc-board__day--peak .pc-board__block {
|
||
border-color: var(--pc-signal-bright, #ff6a2a);
|
||
background: var(--pc-signal-bright, #ff6a2a);
|
||
color: var(--pc-dark, #0e100e);
|
||
}
|
||
|
||
.pc-board--dark .pc-board__day--peak .pc-board__time {
|
||
color: color-mix(in srgb, var(--pc-dark, #0e100e) 80%, transparent);
|
||
}
|
||
|
||
.pc-board--dark .pc-board__hours {
|
||
color: var(--pc-paper, #f4efe6);
|
||
}
|
||
|
||
.pc-board--dark .pc-board__pulse {
|
||
--pc-pulse-color: var(--pc-dark-line, #343a31);
|
||
}
|
||
</style>
|