Lay out hour nav horizontally and use real links
Deploy / deploy (push) Successful in 1m7s

Matches the reference app's row layout instead of a vertical sidebar
list, and switches from buttons to anchors since hours are real
routes — plain click still SPA-navigates, modifier/middle clicks
fall through to native browser behavior (open in new tab, etc.).

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
2026-08-19 09:31:46 -04:00
parent 15929a6e50
commit 4373b60f07
2 changed files with 21 additions and 17 deletions
+14 -6
View File
@@ -2,6 +2,8 @@ import { getState, setSelectedHour } from '../app-state';
import { HOUR_IDS, resolveOrdo, type HourId } from '../hours'; import { HOUR_IDS, resolveOrdo, type HourId } from '../hours';
import { hourLabel } from './format'; import { hourLabel } from './format';
const BASE = import.meta.env.BASE_URL;
export function renderHourList(container: HTMLElement): void { export function renderHourList(container: HTMLElement): void {
const { date, selectedHour } = getState(); const { date, selectedHour } = getState();
@@ -11,24 +13,30 @@ export function renderHourList(container: HTMLElement): void {
const isReady = !ordo.notImplemented; const isReady = !ordo.notImplemented;
return ` return `
<li> <li>
<button <a
type="button" href="${BASE}${date}/${hourId}"
class="hour-item${isSelected ? ' is-selected' : ''}${isReady ? '' : ' is-pending'}" class="hour-item${isSelected ? ' is-selected' : ''}${isReady ? '' : ' is-pending'}"
data-hour="${hourId}" data-hour="${hourId}"
aria-current="${isSelected ? 'true' : 'false'}" aria-current="${isSelected ? 'true' : 'false'}"
> >
<span class="hour-name">${hourLabel(hourId)}</span> <span class="hour-name">${hourLabel(hourId)}</span>
${isReady ? '' : '<span class="hour-status">coming soon</span>'} ${isReady ? '' : '<span class="hour-status">coming soon</span>'}
</button> </a>
</li> </li>
`; `;
}).join(''); }).join('');
container.innerHTML = `<ul class="hour-list">${items}</ul>`; container.innerHTML = `<ul class="hour-list">${items}</ul>`;
container.querySelectorAll<HTMLButtonElement>('[data-hour]').forEach((btn) => { container.querySelectorAll<HTMLAnchorElement>('[data-hour]').forEach((link) => {
btn.addEventListener('click', () => { link.addEventListener('click', (event) => {
setSelectedHour(btn.dataset.hour as HourId); // Let modifier/middle clicks fall through to normal browser navigation
// (open in new tab, etc.) — only plain left-clicks are SPA-routed.
if (event.defaultPrevented || event.button !== 0 || event.metaKey || event.ctrlKey || event.shiftKey || event.altKey) {
return;
}
event.preventDefault();
setSelectedHour(link.dataset.hour as HourId);
}); });
}); });
} }
+7 -11
View File
@@ -190,21 +190,17 @@ button:focus-visible {
-------------------------------------------------------------------------- */ -------------------------------------------------------------------------- */
.app-main { .app-main {
display: grid; display: flex;
grid-template-columns: 12rem 1fr; flex-direction: column;
gap: var(--space-3); gap: var(--space-3);
max-width: 64rem; max-width: 64rem;
margin: 0 auto; margin: 0 auto;
padding: var(--space-3) var(--space-2); padding: var(--space-3) var(--space-2);
} }
@media (max-width: 40rem) {
.app-main {
grid-template-columns: 1fr;
}
}
.hour-list { .hour-list {
display: flex;
flex-wrap: wrap;
list-style: none; list-style: none;
margin: 0; margin: 0;
padding: 0; padding: 0;
@@ -214,15 +210,15 @@ button:focus-visible {
.hour-item { .hour-item {
display: flex; display: flex;
flex-direction: column; flex-direction: column;
align-items: flex-start; align-items: center;
width: 100%; text-align: center;
text-align: left;
padding: 0.6rem 0.75rem; padding: 0.6rem 0.75rem;
border: none; border: none;
background: none; background: none;
border-radius: var(--radius); border-radius: var(--radius);
cursor: pointer; cursor: pointer;
color: var(--color-ink); color: var(--color-ink);
text-decoration: none;
} }
.hour-item:hover { .hour-item:hover {