Files
CatoandClaude a170feb2b8 feat(shell): SiteIcon set, a tab bar that reads as one control, masthead tabBar prop (#45)
Products passed unicode glyphs (◎ ✎ ⌕ ⇄ ★) as tab icons; they render
differently on every phone and never look like an interface. The tab bar
also had a filled "active" pill and sat under a masthead that still showed a
Menu button for the same five places.

- SiteIcon / SITE_ICON_NAMES: one stroke icon set on currentColor (home,
  write, search, compass, star, user, chat, bell, settings, list, globe,
  book, heart, plus, menu, calendar, wallet, chart), aria-hidden.
- SiteTabBar: equal grid cells, 24px icon box, 11px/600 labels, the current
  tab marked by a short rule above its icon and full text colour, 56px cells
  with the safe-area inset outside them.
- SiteMasthead tabBar prop: below 48rem the tab bar is the navigation, so
  the masthead drops its menu button and keeps the account actions.
- Tests for every icon and for the masthead class; README and CHANGELOG.


Claude-Session: https://claude.ai/code/session_019MDtmvpWNTLxXNfwUHS7MD

Co-authored-by: Claude <noreply@anthropic.com>
2026-11-06 00:36:01 +01:00

50 lines
1.9 KiB
JavaScript

import { test } from 'node:test';
import assert from 'node:assert/strict';
import { createElement as h } from 'react';
import { renderToStaticMarkup } from 'react-dom/server';
import { SiteTabBar } from '@bitbaum/sitekit/react';
test('tab bar marks the current section, including nested paths', () => {
const html = renderToStaticMarkup(
h(SiteTabBar, {
currentPath: 'investigations/demo',
items: [
{ path: '', label: 'Today', icon: '◎' },
{ path: 'investigations', label: 'Investigate', icon: '⌕' },
{ path: 'desk', label: 'My desk', icon: '★' },
],
}),
);
assert.match(html, /aria-label="Main"/);
assert.match(html, /href="\/investigations" aria-current="page"/);
assert.doesNotMatch(html, /href="\/" aria-current/);
assert.equal((html.match(/sk-tab"/g) || []).length, 3);
});
test('SiteIcon draws every named icon on currentColor and hides it from assistive tech', async () => {
const { SiteIcon, SITE_ICON_NAMES } = await import('@bitbaum/sitekit/react');
assert.ok(SITE_ICON_NAMES.includes('write'));
for (const name of SITE_ICON_NAMES) {
const html = renderToStaticMarkup(h(SiteIcon, { name }));
assert.match(html, /aria-hidden="true"/, name);
assert.match(html, /stroke="currentColor"/, name);
assert.match(html, /<path|<circle|<rect/, name + ' has no drawing');
}
});
test('a masthead that shares the page with a tab bar says so in its class', async () => {
const { SiteMasthead } = await import('@bitbaum/sitekit/react');
const props = {
appearance: 'application',
chrome: { name: 'Site', tagline: '', footerNote: '' },
navItems: [{ path: '', label: 'Home' }],
currentPath: '',
};
assert.match(
renderToStaticMarkup(h(SiteMasthead, { ...props, tabBar: true })),
/sk-masthead sk-masthead--tabbar/,
);
assert.doesNotMatch(renderToStaticMarkup(h(SiteMasthead, props)), /sk-masthead--tabbar/);
});