feat: coordinator dropdown replaces the tab row

- pages.tsx: when signed in, the Coordinator pill in the session bar is a
  <details> menu with Shifts, Contacts and Settings, the current section
  marked. Signed out it stays a plain link to sign-in. Off coordinator pages
  no section is marked current. CoordinatorTabs is removed.
- Phones and tablets (75em and below): no nested menu inside the hamburger
  overlay; the three sections show as a second row under Sign Up / Log out.
- app.css: .coord-menu and .session-sections styles; drop .desk-tabs.
- enhance.js: the menu closes on outside click and Esc, like the View menu.
- tests: admins.test.ts checks the menu, the phone row, the signed-out link,
  and no current section on a public page.
This commit is contained in:
Cosmically Creative committed 2026-11-20 13:24:23 -06:00
1 parent c4fe911969
commit c576613b9d
4 files changed
+218 -90

No files matched your search

+159 -63
View File
@@ -445,6 +445,131 @@ a.btn:active {
content: none;
}
/* Coordinator dropdown in the session bar, signed in. Same pattern as the view menu: a white card under the pill. */
.session-bar .coord-menu {
position: relative;
}
.session-bar .coord-menu > summary {
position: relative;
display: inline-flex;
align-items: center;
min-height: 44px;
margin: 0;
padding: 0;
list-style: none;
background: transparent;
color: #222;
font: inherit;
font-size: 18px;
font-weight: 400;
line-height: 1;
text-decoration: none;
cursor: pointer;
transition: transform 0.3s;
}
.session-bar .coord-menu > summary::-webkit-details-marker {
display: none;
}
.session-bar .coord-menu > summary::marker {
content: "";
}
.session-bar .coord-menu > summary::after {
content: "";
width: 0.4rem;
height: 0.4rem;
margin-left: 0.35rem;
border-right: 2px solid currentColor;
border-bottom: 2px solid currentColor;
transform: translateY(-0.12rem) rotate(45deg);
}
.session-bar .coord-menu[open] > summary::after {
transform: translateY(0.12rem) rotate(225deg);
}
.session-bar .coord-menu > summary:hover,
.session-bar .coord-menu > summary:active {
transform: scale(1.1);
background: transparent;
color: #444;
}
/* On a coordinator page the pill is bold with the same gold line as the session-bar links. */
.session-bar .coord-menu > summary.session-here {
font-weight: 650;
}
.session-bar .coord-menu > summary.session-here::before {
content: "";
position: absolute;
left: 0;
right: 0;
bottom: 7px;
height: 2px;
border-radius: 999px;
background: var(--hope-gold);
}
.coord-menu-list {
position: absolute;
z-index: 1001;
top: calc(100% + 0.35rem);
right: 0;
display: grid;
min-width: 9.5rem;
padding: 0.3rem;
background: #fff;
border: 1px solid var(--hope-border-2);
border-radius: 1rem;
box-shadow: var(--hope-shadow);
}
.coord-menu-list a {
position: relative;
display: inline-flex;
align-items: center;
min-height: 44px;
padding: 0.3rem 0.8rem;
border-radius: 0.7rem;
color: var(--hope-ink);
font-size: 1rem;
font-weight: 500;
line-height: 1.2;
text-decoration: none;
white-space: nowrap;
}
.coord-menu-list a:hover,
.coord-menu-list a:active {
background: var(--hope-blue-75);
color: var(--hope-ink);
text-decoration: none;
}
.coord-menu-list a[aria-current] {
font-weight: 650;
}
.coord-menu-list a[aria-current]::after {
content: "";
position: absolute;
left: 0.8rem;
right: 0.8rem;
bottom: 9px;
height: 2px;
border-radius: 999px;
background: var(--hope-gold);
}
/* Phone and tablet: no dropdown inside the ☰ menu, a second plain row instead. Hidden on desktop. */
.session-sections {
display: none;
}
/* Page */
main {
@@ -3284,68 +3409,6 @@ button.btn-quiet::before {
margin: 0.15rem 0 0;
}
/* Coordinator tabs. Same family as the session bar: a white pill, plain links, a gold line under the current one. */
.desk-tabs {
display: flex;
flex-wrap: wrap;
align-items: center;
gap: 0 1.75rem;
width: fit-content;
max-width: 100%;
margin: 0 0 1.25rem;
padding: 0 1.5rem;
background: #fff;
border: 1px solid #e6eef3;
border-radius: 999px;
box-shadow: var(--hope-shadow-soft);
}
.desk-tabs a {
position: relative;
display: inline-flex;
align-items: center;
min-height: 48px;
color: var(--hope-ink);
font-size: 1.05rem;
font-weight: 500;
line-height: 1;
text-decoration: none;
}
.desk-tabs a:hover {
color: var(--hope-ink-2);
}
.desk-tabs a[aria-current] {
font-weight: 650;
}
.desk-tabs a[aria-current]::after {
content: "";
position: absolute;
left: 0;
right: 0;
bottom: 10px;
height: 2px;
border-radius: 999px;
background: var(--hope-gold);
}
.desk-tabs a:focus-visible {
outline: 2px solid var(--hope-ink);
outline-offset: 3px;
border-radius: 4px;
}
@media (max-width: 42em) {
.desk-tabs {
width: 100%;
justify-content: space-between;
gap: 0 1rem;
padding: 0 1.25rem;
}
}
.coordinator-board {
display: grid;
gap: 1rem;
@@ -4283,6 +4346,7 @@ button.btn-quiet::before {
left: 0;
bottom: 28px;
z-index: 1001;
flex-wrap: wrap;
justify-content: center;
gap: 22px;
width: auto;
@@ -4299,6 +4363,39 @@ button.btn-quiet::before {
transition: transform 0.4s ease-in, opacity 0.4s ease-in;
}
.coord-menu {
display: none;
}
.session-sections {
display: flex;
flex: 0 0 100%;
align-items: center;
justify-content: center;
gap: 22px;
}
.session-sections-label {
color: var(--hope-ink-2);
font-size: 0.875rem;
font-weight: 500;
}
.session-sections a[aria-current] {
font-weight: 650;
}
.session-sections a[aria-current]::after {
content: "";
position: absolute;
left: 0;
right: 0;
bottom: 7px;
height: 2px;
border-radius: 999px;
background: var(--hope-gold);
}
.header.nav-open ~ main .session-bar {
opacity: 1;
visibility: visible;
@@ -5901,7 +5998,6 @@ main > .crumb,
.header,
.footer,
.session-bar,
.desk-tabs,
.crumb,
.desk-actions,
.desk-inline,
+1 -1
View File
@@ -27,7 +27,7 @@
}
function bindViewMenu() {
var menus = document.querySelectorAll('details.view-menu, details.manage-menu');
var menus = document.querySelectorAll('details.view-menu, details.manage-menu, details.coord-menu');
if (!menus.length) return;
document.addEventListener('click', function (event) {
for (var i = 0; i < menus.length; i += 1) {
+44 -25
View File
@@ -38,6 +38,8 @@ export function Layout(props: {
const home = appPath(props.config, '/');
const coordinator = appPath(props.config, props.account ? '/admin' : '/login');
const coordinatorHere = pathIs(props.path, coordinator);
const adminHere = pathIs(props.path, appPath(props.config, '/admin'));
const sections = props.account ? coordinatorSections(props.config, props.path) : [];
const volunteeringCurrent = props.path === home ? 'page' : undefined;
const logo = asset(props.config, '/img/logo.png');
const menu = asset(props.config, '/img/icons/menu.svg');
@@ -110,17 +112,39 @@ export function Layout(props: {
<a href={home} aria-current={props.path === home ? 'page' : undefined}>
Sign Up
</a>
<a href={coordinator} class={props.account ? undefined : 'session-entry'} aria-current={coordinatorHere ? 'page' : undefined}>
Coordinator
</a>
{props.account ? (
<details class="coord-menu">
<summary class={adminHere ? 'session-here' : undefined}>Coordinator</summary>
<div class="coord-menu-list">
{sections.map((section) => (
<a key={section.key} href={section.href} aria-current={section.current}>
{section.label}
</a>
))}
</div>
</details>
) : (
<a href={coordinator} class="session-entry" aria-current={coordinatorHere ? 'page' : undefined}>
Coordinator
</a>
)}
{props.account ? (
<form method="post" action={appPath(props.config, '/logout')} class="session-logout">
<input type="hidden" name="csrf" value={props.account.csrf} />
<button type="submit">Log out</button>
</form>
) : null}
{props.account ? (
<nav class="session-sections" aria-label="Coordinator">
<span class="session-sections-label">Coordinator</span>
{sections.map((section) => (
<a key={section.key} href={section.href} aria-current={section.current}>
{section.label}
</a>
))}
</nav>
) : null}
</div>
{props.account && pathIs(props.path, appPath(props.config, '/admin')) ? <CoordinatorTabs config={props.config} path={props.path} /> : null}
{props.children}
</main>
<footer class="footer">
@@ -225,29 +249,24 @@ export function Layout(props: {
}
/**
* Coordinator sections, on every signed-in coordinator page.
* Coordinator sections for the dropdown and the phone row.
* Shifts covers the dashboard, events, shifts, and templates. Administrators sits under Settings.
*/
function CoordinatorTabs(props: { config: AppConfig; path?: string }) {
const shifts = appPath(props.config, '/admin');
const contacts = appPath(props.config, '/admin/contacts');
const settings = appPath(props.config, '/admin/settings');
const admins = appPath(props.config, '/admin/admins');
const section = pathIs(props.path, contacts) ? 'contacts' : pathIs(props.path, settings) || pathIs(props.path, admins) ? 'settings' : 'shifts';
const tabs = [
{ key: 'shifts', href: shifts, label: 'Shifts' },
{ key: 'contacts', href: contacts, label: 'Contacts' },
{ key: 'settings', href: settings, label: 'Settings' },
];
return (
<nav class="desk-tabs" aria-label="Coordinator">
{tabs.map((tab) => (
<a key={tab.key} href={tab.href} aria-current={tab.key === section ? (props.path === tab.href ? 'page' : 'true') : undefined}>
{tab.label}
</a>
))}
</nav>
);
function coordinatorSections(config: AppConfig, path?: string) {
// Off coordinator pages (the public schedule, a signup page), no section is current.
const inAdmin = pathIs(path, appPath(config, '/admin'));
const section = !inAdmin
? null
: pathIs(path, appPath(config, '/admin/contacts'))
? 'contacts'
: pathIs(path, appPath(config, '/admin/settings')) || pathIs(path, appPath(config, '/admin/admins'))
? 'settings'
: 'shifts';
return [
{ key: 'shifts', href: appPath(config, '/admin'), label: 'Shifts' },
{ key: 'contacts', href: appPath(config, '/admin/contacts'), label: 'Contacts' },
{ key: 'settings', href: appPath(config, '/admin/settings'), label: 'Settings' },
].map((item) => ({ ...item, current: item.key === section ? (path === item.href ? 'page' : 'true') : undefined }));
}
export function EmptySchedulePage() {
+14 -1
View File
@@ -24,6 +24,11 @@ describe('administrators', () => {
const page = await app.request('/admin/admins');
expect(page.status).toBe(303);
expect(page.headers.get('location')).toBe('/login');
const login = await app.request('/login');
expect(login.status).toBe(200);
const loginHtml = await login.text();
expect(loginHtml).toContain('session-entry');
expect(loginHtml).not.toContain('coord-menu');
const posted = await app.request('/admin/admins', {
method: 'POST',
headers: { origin: ORIGIN, 'content-type': 'application/x-www-form-urlencoded' },
@@ -38,10 +43,18 @@ describe('administrators', () => {
const cookie = await signIn(app, db, 'coordinator@example.invalid');
const home = await app.request('/admin', { headers: { cookie } });
const homeHtml = await home.text();
expect(homeHtml).toContain('<nav class="desk-tabs" aria-label="Coordinator">');
expect(homeHtml).toContain('<details class="coord-menu">');
expect(homeHtml).toContain('<summary class="session-here">Coordinator</summary>');
expect(homeHtml).toContain('<a href="/admin" aria-current="page">Shifts</a>');
expect(homeHtml).toContain('<a href="/admin/contacts">Contacts</a>');
expect(homeHtml).toContain('<a href="/admin/settings">Settings</a>');
expect(homeHtml).not.toContain('href="/admin/admins"');
expect(homeHtml).toContain('<nav class="session-sections" aria-label="Coordinator">');
const publicHtml = await (await app.request('/', { headers: { cookie } })).text();
expect(publicHtml).toContain('<details class="coord-menu">');
expect(publicHtml).toContain('<summary>Coordinator</summary>');
expect(publicHtml).toContain('<a href="/admin">Shifts</a>');
expect(publicHtml).not.toMatch(/href="\/admin[^"]*" aria-current/);
const settings = await (await app.request('/admin/settings', { headers: { cookie } })).text();
expect(settings).toContain('<a href="/admin/settings" aria-current="page">Settings</a>');
expect(settings).toContain('href="/admin/admins"');