feat: hover Coordinator menu; pages named by their own heading
- The Coordinator pill is a real link to Shifts (/admin) and opens the Shifts / Contacts / Settings card on hover or keyboard focus (desktop). Esc closes it. Phones and tablets keep the second row in the menu overlay. - Menu links no longer scale on hover, so the blue highlight stays inside the card. - No gold "current page" line in the menu, the phone row, or the pill; aria-current stays for screen readers. The page heading shows where you are. - The dashboard heading and title are "Shifts". Breadcrumbs start at their section: Shifts > ..., Contacts > Name, Settings > Administrators. - tests: admins.test.ts updated for the new markup.
This commit is contained in:
1 parent
c576613b9d
commit
bf3724d531
6 files changed
+49
-101
No files matched your search
+22
-84
@@ -445,39 +445,12 @@ a.btn:active {
|
|||||||
content: none;
|
content: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Coordinator dropdown in the session bar, signed in. Same pattern as the view menu: a white card under the pill. */
|
/* Coordinator menu in the session bar, signed in. A real pill link with the three sections in a card; opens on hover on desktop. */
|
||||||
.session-bar .coord-menu {
|
.session-bar .coord-menu {
|
||||||
position: relative;
|
position: relative;
|
||||||
}
|
}
|
||||||
|
|
||||||
.session-bar .coord-menu > summary {
|
.session-bar .coord-menu > a::after {
|
||||||
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: "";
|
content: "";
|
||||||
width: 0.4rem;
|
width: 0.4rem;
|
||||||
height: 0.4rem;
|
height: 0.4rem;
|
||||||
@@ -487,39 +460,17 @@ a.btn:active {
|
|||||||
transform: translateY(-0.12rem) rotate(45deg);
|
transform: translateY(-0.12rem) rotate(45deg);
|
||||||
}
|
}
|
||||||
|
|
||||||
.session-bar .coord-menu[open] > summary::after {
|
.session-bar .coord-menu:hover > a::after,
|
||||||
|
.session-bar .coord-menu:focus-within > a::after {
|
||||||
transform: translateY(0.12rem) rotate(225deg);
|
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 {
|
.coord-menu-list {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
z-index: 1001;
|
z-index: 1001;
|
||||||
top: calc(100% + 0.35rem);
|
top: calc(100% + 0.35rem);
|
||||||
right: 0;
|
right: 0;
|
||||||
display: grid;
|
display: none;
|
||||||
min-width: 9.5rem;
|
min-width: 9.5rem;
|
||||||
padding: 0.3rem;
|
padding: 0.3rem;
|
||||||
background: #fff;
|
background: #fff;
|
||||||
@@ -528,6 +479,21 @@ a.btn:active {
|
|||||||
box-shadow: var(--hope-shadow);
|
box-shadow: var(--hope-shadow);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Invisible bridge over the gap, so the card stays open while the pointer crosses it. */
|
||||||
|
.coord-menu-list::before {
|
||||||
|
content: "";
|
||||||
|
position: absolute;
|
||||||
|
top: -0.5rem;
|
||||||
|
left: 0;
|
||||||
|
right: 0;
|
||||||
|
height: 0.5rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.session-bar .coord-menu:hover .coord-menu-list,
|
||||||
|
.session-bar .coord-menu:focus-within .coord-menu-list {
|
||||||
|
display: grid;
|
||||||
|
}
|
||||||
|
|
||||||
.coord-menu-list a {
|
.coord-menu-list a {
|
||||||
position: relative;
|
position: relative;
|
||||||
display: inline-flex;
|
display: inline-flex;
|
||||||
@@ -543,28 +509,15 @@ a.btn:active {
|
|||||||
white-space: nowrap;
|
white-space: nowrap;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* The session-bar links scale up on hover; the menu links must not, so the highlight stays inside the card. */
|
||||||
.coord-menu-list a:hover,
|
.coord-menu-list a:hover,
|
||||||
.coord-menu-list a:active {
|
.coord-menu-list a:active {
|
||||||
|
transform: none;
|
||||||
background: var(--hope-blue-75);
|
background: var(--hope-blue-75);
|
||||||
color: var(--hope-ink);
|
color: var(--hope-ink);
|
||||||
text-decoration: none;
|
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. */
|
/* Phone and tablet: no dropdown inside the ☰ menu, a second plain row instead. Hidden on desktop. */
|
||||||
.session-sections {
|
.session-sections {
|
||||||
display: none;
|
display: none;
|
||||||
@@ -4381,21 +4334,6 @@ button.btn-quiet::before {
|
|||||||
font-weight: 500;
|
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 {
|
.header.nav-open ~ main .session-bar {
|
||||||
opacity: 1;
|
opacity: 1;
|
||||||
visibility: visible;
|
visibility: visible;
|
||||||
|
|||||||
+12
-1
@@ -2,6 +2,7 @@
|
|||||||
bindNav();
|
bindNav();
|
||||||
bindCalendar();
|
bindCalendar();
|
||||||
bindViewMenu();
|
bindViewMenu();
|
||||||
|
bindCoordMenu();
|
||||||
bindManage();
|
bindManage();
|
||||||
bindSignupDates();
|
bindSignupDates();
|
||||||
document.querySelectorAll('[data-contact]').forEach(bindContact);
|
document.querySelectorAll('[data-contact]').forEach(bindContact);
|
||||||
@@ -27,7 +28,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
function bindViewMenu() {
|
function bindViewMenu() {
|
||||||
var menus = document.querySelectorAll('details.view-menu, details.manage-menu, details.coord-menu');
|
var menus = document.querySelectorAll('details.view-menu, details.manage-menu');
|
||||||
if (!menus.length) return;
|
if (!menus.length) return;
|
||||||
document.addEventListener('click', function (event) {
|
document.addEventListener('click', function (event) {
|
||||||
for (var i = 0; i < menus.length; i += 1) {
|
for (var i = 0; i < menus.length; i += 1) {
|
||||||
@@ -41,6 +42,16 @@
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function bindCoordMenu() {
|
||||||
|
var menu = document.querySelector('.coord-menu');
|
||||||
|
if (!menu) return;
|
||||||
|
menu.addEventListener('keydown', function (event) {
|
||||||
|
if (event.key !== 'Escape') return;
|
||||||
|
var active = document.activeElement;
|
||||||
|
if (active && menu.contains(active)) active.blur();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
function bindCalendar() {
|
function bindCalendar() {
|
||||||
var calendar = document.querySelector('.shift-calendar');
|
var calendar = document.querySelector('.shift-calendar');
|
||||||
var weeks = document.querySelectorAll('.cal-week');
|
var weeks = document.querySelectorAll('.cal-week');
|
||||||
|
|||||||
+1
-1
@@ -298,7 +298,7 @@ function showHome(
|
|||||||
return html(
|
return html(
|
||||||
c,
|
c,
|
||||||
services,
|
services,
|
||||||
newEvent ? 'New event · Hope Volunteer' : 'Coordinator · Hope Volunteer',
|
newEvent ? 'New event · Hope Volunteer' : 'Shifts · Hope Volunteer',
|
||||||
<AdminHome
|
<AdminHome
|
||||||
config={services.config}
|
config={services.config}
|
||||||
name={session.name}
|
name={session.name}
|
||||||
|
|||||||
+5
-7
@@ -264,7 +264,7 @@ export function AdminHome(props: {
|
|||||||
<>
|
<>
|
||||||
<header class="desk-intro desk-home-intro">
|
<header class="desk-intro desk-home-intro">
|
||||||
<div class="desk-home-copy">
|
<div class="desk-home-copy">
|
||||||
<h1>Coordinator</h1>
|
<h1>Shifts</h1>
|
||||||
<p class="desk-date">{clock.dateLabel}</p>
|
<p class="desk-date">{clock.dateLabel}</p>
|
||||||
<p class="desk-signed">
|
<p class="desk-signed">
|
||||||
Signed in as <strong>{props.name}</strong>. This sign-in ends on {sessionEnds.dateLabel}.
|
Signed in as <strong>{props.name}</strong>. This sign-in ends on {sessionEnds.dateLabel}.
|
||||||
@@ -534,7 +534,6 @@ export function AdminsPage(props: {
|
|||||||
<>
|
<>
|
||||||
<Crumb
|
<Crumb
|
||||||
items={[
|
items={[
|
||||||
{ href: appPath(props.config, '/admin'), label: 'Coordinator' },
|
|
||||||
{ href: appPath(props.config, '/admin/settings'), label: 'Settings' },
|
{ href: appPath(props.config, '/admin/settings'), label: 'Settings' },
|
||||||
{ label: 'Administrators' },
|
{ label: 'Administrators' },
|
||||||
]}
|
]}
|
||||||
@@ -782,7 +781,6 @@ export function ContactPage(props: {
|
|||||||
<>
|
<>
|
||||||
<Crumb
|
<Crumb
|
||||||
items={[
|
items={[
|
||||||
{ href: appPath(props.config, '/admin'), label: 'Coordinator' },
|
|
||||||
{ href: appPath(props.config, '/admin/contacts'), label: 'Contacts' },
|
{ href: appPath(props.config, '/admin/contacts'), label: 'Contacts' },
|
||||||
{ label: props.contact.name },
|
{ label: props.contact.name },
|
||||||
]}
|
]}
|
||||||
@@ -893,7 +891,7 @@ export function EventEditor(props: {
|
|||||||
<div class="event-page">
|
<div class="event-page">
|
||||||
{event ? (
|
{event ? (
|
||||||
<header class="event-head">
|
<header class="event-head">
|
||||||
<Crumb items={[{ href: appPath(props.config, '/admin'), label: 'Coordinator' }, { label: props.heading }]} />
|
<Crumb items={[{ href: appPath(props.config, '/admin'), label: 'Shifts' }, { label: props.heading }]} />
|
||||||
<div class="event-titlebar">
|
<div class="event-titlebar">
|
||||||
<div class="event-title">
|
<div class="event-title">
|
||||||
<h1>{props.heading}</h1>
|
<h1>{props.heading}</h1>
|
||||||
@@ -970,7 +968,7 @@ export function TemplateEditor(props: {
|
|||||||
<>
|
<>
|
||||||
<Crumb
|
<Crumb
|
||||||
items={[
|
items={[
|
||||||
{ href: appPath(props.config, '/admin'), label: 'Coordinator' },
|
{ href: appPath(props.config, '/admin'), label: 'Shifts' },
|
||||||
{ href: appPath(props.config, `/admin/events/${props.eventId}`), label: props.eventTitle },
|
{ href: appPath(props.config, `/admin/events/${props.eventId}`), label: props.eventTitle },
|
||||||
{ label: props.heading },
|
{ label: props.heading },
|
||||||
]}
|
]}
|
||||||
@@ -1008,7 +1006,7 @@ export function ShiftEditor(props: {
|
|||||||
<div class="event-page">
|
<div class="event-page">
|
||||||
<Crumb
|
<Crumb
|
||||||
items={[
|
items={[
|
||||||
{ href: appPath(props.config, '/admin'), label: 'Coordinator' },
|
{ href: appPath(props.config, '/admin'), label: 'Shifts' },
|
||||||
{ href: appPath(props.config, `/admin/events/${props.eventId}`), label: props.eventTitle },
|
{ href: appPath(props.config, `/admin/events/${props.eventId}`), label: props.eventTitle },
|
||||||
{ label: 'New shift' },
|
{ label: 'New shift' },
|
||||||
]}
|
]}
|
||||||
@@ -1054,7 +1052,7 @@ export function ShiftRoster(props: {
|
|||||||
<div class="event-page">
|
<div class="event-page">
|
||||||
<Crumb
|
<Crumb
|
||||||
items={[
|
items={[
|
||||||
{ href: appPath(props.config, '/admin'), label: 'Coordinator' },
|
{ href: appPath(props.config, '/admin'), label: 'Shifts' },
|
||||||
{ href: appPath(props.config, `/admin/events/${props.shift.eventId}`), label: props.shift.eventTitle },
|
{ href: appPath(props.config, `/admin/events/${props.shift.eventId}`), label: props.shift.eventTitle },
|
||||||
{ label: props.shift.role },
|
{ label: props.shift.role },
|
||||||
]}
|
]}
|
||||||
|
|||||||
+5
-4
@@ -38,7 +38,6 @@ export function Layout(props: {
|
|||||||
const home = appPath(props.config, '/');
|
const home = appPath(props.config, '/');
|
||||||
const coordinator = appPath(props.config, props.account ? '/admin' : '/login');
|
const coordinator = appPath(props.config, props.account ? '/admin' : '/login');
|
||||||
const coordinatorHere = pathIs(props.path, coordinator);
|
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 sections = props.account ? coordinatorSections(props.config, props.path) : [];
|
||||||
const volunteeringCurrent = props.path === home ? 'page' : undefined;
|
const volunteeringCurrent = props.path === home ? 'page' : undefined;
|
||||||
const logo = asset(props.config, '/img/logo.png');
|
const logo = asset(props.config, '/img/logo.png');
|
||||||
@@ -113,8 +112,10 @@ export function Layout(props: {
|
|||||||
Sign Up
|
Sign Up
|
||||||
</a>
|
</a>
|
||||||
{props.account ? (
|
{props.account ? (
|
||||||
<details class="coord-menu">
|
<div class="coord-menu">
|
||||||
<summary class={adminHere ? 'session-here' : undefined}>Coordinator</summary>
|
<a href={appPath(props.config, '/admin')} aria-haspopup="true">
|
||||||
|
Coordinator
|
||||||
|
</a>
|
||||||
<div class="coord-menu-list">
|
<div class="coord-menu-list">
|
||||||
{sections.map((section) => (
|
{sections.map((section) => (
|
||||||
<a key={section.key} href={section.href} aria-current={section.current}>
|
<a key={section.key} href={section.href} aria-current={section.current}>
|
||||||
@@ -122,7 +123,7 @@ export function Layout(props: {
|
|||||||
</a>
|
</a>
|
||||||
))}
|
))}
|
||||||
</div>
|
</div>
|
||||||
</details>
|
</div>
|
||||||
) : (
|
) : (
|
||||||
<a href={coordinator} class="session-entry" aria-current={coordinatorHere ? 'page' : undefined}>
|
<a href={coordinator} class="session-entry" aria-current={coordinatorHere ? 'page' : undefined}>
|
||||||
Coordinator
|
Coordinator
|
||||||
|
|||||||
@@ -43,16 +43,16 @@ describe('administrators', () => {
|
|||||||
const cookie = await signIn(app, db, 'coordinator@example.invalid');
|
const cookie = await signIn(app, db, 'coordinator@example.invalid');
|
||||||
const home = await app.request('/admin', { headers: { cookie } });
|
const home = await app.request('/admin', { headers: { cookie } });
|
||||||
const homeHtml = await home.text();
|
const homeHtml = await home.text();
|
||||||
expect(homeHtml).toContain('<details class="coord-menu">');
|
expect(homeHtml).toContain('<div class="coord-menu">');
|
||||||
expect(homeHtml).toContain('<summary class="session-here">Coordinator</summary>');
|
expect(homeHtml).toContain('<a href="/admin" aria-haspopup="true">Coordinator</a>');
|
||||||
expect(homeHtml).toContain('<a href="/admin" aria-current="page">Shifts</a>');
|
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/contacts">Contacts</a>');
|
||||||
expect(homeHtml).toContain('<a href="/admin/settings">Settings</a>');
|
expect(homeHtml).toContain('<a href="/admin/settings">Settings</a>');
|
||||||
expect(homeHtml).not.toContain('href="/admin/admins"');
|
expect(homeHtml).not.toContain('href="/admin/admins"');
|
||||||
expect(homeHtml).toContain('<nav class="session-sections" aria-label="Coordinator">');
|
expect(homeHtml).toContain('<nav class="session-sections" aria-label="Coordinator">');
|
||||||
const publicHtml = await (await app.request('/', { headers: { cookie } })).text();
|
const publicHtml = await (await app.request('/', { headers: { cookie } })).text();
|
||||||
expect(publicHtml).toContain('<details class="coord-menu">');
|
expect(publicHtml).toContain('<div class="coord-menu">');
|
||||||
expect(publicHtml).toContain('<summary>Coordinator</summary>');
|
expect(publicHtml).toContain('<a href="/admin" aria-haspopup="true">Coordinator</a>');
|
||||||
expect(publicHtml).toContain('<a href="/admin">Shifts</a>');
|
expect(publicHtml).toContain('<a href="/admin">Shifts</a>');
|
||||||
expect(publicHtml).not.toMatch(/href="\/admin[^"]*" aria-current/);
|
expect(publicHtml).not.toMatch(/href="\/admin[^"]*" aria-current/);
|
||||||
const settings = await (await app.request('/admin/settings', { headers: { cookie } })).text();
|
const settings = await (await app.request('/admin/settings', { headers: { cookie } })).text();
|
||||||
|
|||||||
Reference in new issue
Block a user