Put the other menus in the top bar

The bar hid them behind a switcher and a sheet. It now names every menu that
exists, which is what was asked for; it scrolls sideways when the categories
outgrow the width, and the current one is the only filled item. Without the
script it is simply a row of links, so nothing is lost when JavaScript is off.
This commit is contained in:
tanshu committed 2026-09-22 22:35:38 +05:30
1 parent c31b73d553
commit c5c0b7d005
6 files changed
+56 -241

No files matched your search

+9 -10
View File
@@ -130,9 +130,8 @@ describe('a Section page', () => {
assert.doesNotMatch(body, /Older menus/);
assert.doesNotMatch(body, /This is an older menu/);
assert.match(body, /src="\/assets\/app\.js"/);
assert.match(body, /class="switcher"/, 'the bar names the menu and opens the switcher');
assert.match(body, /<span class="switcher__label">Bar<\/span>/);
assert.match(body, /id="menu-sheet"/, 'the sheet exists for the script to open');
assert.match(body, /class="bar__nav"/, 'the bar links the other menus');
assert.match(body, /class="bar__link is-current"[^>]*aria-current="page"/s, 'the current one is marked');
});
it('serves both the trailing-slash and bare URLs', async () => {
@@ -147,8 +146,8 @@ describe('a Section page', () => {
});
});
describe('the menu switcher', () => {
it('lists every Section that has a menu, in category order, marking the one being read', async () => {
describe('the bar', () => {
it('links every Section that has a menu, in category order, marking the one being read', async () => {
await seedPublishedBar();
const store = app.menu.store;
const food = await store.create('food', { label: 'Food Menu' });
@@ -156,18 +155,18 @@ describe('the menu switcher', () => {
await store.publish(food.id);
const page = await app.inject({ method: 'GET', url: '/bar/' });
const listed = [...page.body.matchAll(/class="sheet__item[^"]*"\s+href="\/([a-z-]+)\//g)].map(
const linked = [...page.body.matchAll(/class="bar__link[^"]*"\s+href="\/([a-z-]+)\//g)].map(
(match) => match[1],
);
assert.deepEqual(listed, ['food', 'bar']);
assert.equal((page.body.match(/sheet__item is-current/g) ?? []).length, 1);
assert.match(page.body, />Showing</);
assert.deepEqual(linked, ['food', 'bar']);
assert.equal((page.body.match(/bar__link is-current/g) ?? []).length, 1);
assert.match(page.body, /class="bar__link is-current"[^>]*href="\/bar\/"/s);
});
it('leaves a category with no menu out until it has one', async () => {
await seedPublishedBar();
const page = await app.inject({ method: 'GET', url: '/bar/' });
assert.doesNotMatch(page.body, /sheet__name">Wine/);
assert.doesNotMatch(page.body, /bar__link[^>]*>Wine</);
assert.equal((await app.inject({ method: 'GET', url: '/wine/' })).statusCode, 404);
});
});