jukebox
All repositories: gitoria
3.2 KB
// main-menu.hl — THE MAIN MENU: the app's top-level links, `Series | Shows | Movies` (docs/layouts/main-menu.md).// Write it twice from ONE list: in the header (shown from 60rem) and in the sidebar (shown on the phone, where the// header has no room). The link whose href is `current` (or a page below it) is marked: class `current` and// aria-current="page". With no `current` given, the menu takes the page from the route (hybriel#197: `route = null`,// {path, params, pattern}, there in the server's HTML, so the marker is in the first paint and moves on a client click).// Without a matching path the host says which one: `current = "/docs"` (the page /read/x is// under Docs) or `current = true` on the item itself. An item may carry a small count: `count = 3` (a badge, not text).//// static menu = [ { label = 'Series' href = '/series' } { label = 'Movies' href = '/movies' } ]// AppHeader { MainMenu { items = menu current = "/series" } }// Sidebar { desktop = "false" MainMenu { items = menu current = "/series" } }Hybrid items = []String current = ''String label = 'Main menu'route = nullHybrid rows = build(items, current, route)// one row per link: the current one (the page itself or a page below it) is markedbuild(list, say, r) {// the host's say (`current`) wins; without one the shell's route (hybriel#197, in the server's HTML too) is the pageat = say != '' ? say : (r == null ? '' : r.path)out = []for (it of list) {let here = it.current == true || at == it.href || (it.href != '/' && at.startsWith(it.href + '/'))let n = it.count == null ? '' : '' + it.countout.push({ label = it.label href = it.href count = n has = n != '' cls = here ? 'current' : '' aria = here ? 'page' : 'false' })}return out}Style {mainMenu {display = 'block'a {display = 'flex'alignItems = 'center'minHeight = 'var(--layout-tap)'padding = '.55rem .75rem'fontWeight = '600'color = 'var(--color-text)'borderRadius = 'var(--radius-small)'hover {textDecoration = 'none'color = 'var(--color-text-strong)'background = 'var(--color-surface)'}'span.count' {marginLeft = '.5rem'padding = '0 .45rem'minWidth = '1.4rem'textAlign = 'center'fontSize = '.8rem'fontWeight = '700'lineHeight = '1.4rem'color = 'var(--color-accent-text)'background = 'var(--color-accent)'borderRadius = 'var(--radius-small)'}}'a.current' {color = 'var(--color-accent)'background = 'var(--color-surface)'}}'application-header' {mainMenu {display = 'none'@media {minWidth = '60rem'display = 'block'marginLeft = 'auto'}nav {@media {minWidth = '60rem'display = 'flex'gap = '.15rem'}}}}'app-sidebar' {mainMenu {marginBottom = '1rem'@media {minWidth = '60rem'display = 'none'}}}@media {minWidth = '60rem''application-header' {mainMenu {a {minHeight = '2.25rem'padding = '.45rem .7rem'}}}}}View {mainMenu {nav { 'aria-label' = labelfor (r of rows) { a { href = r.href class = r.cls 'aria-current' = r.aria r.label if (r.has) { span { class = 'count' r.count } } } }}}}
Branches
Latest commits
- 8048258bRecords: day38b jb3 regression, L1 Chromes stoppedmre
- 68aace7fRecords: mission 003 day38bmre
- d105d8a9Records: mpackdb integrity check cleanmre
- 6e980c53Records: mpackdb rule refinementmre
- 6d335ac4Records: storage copy rulingmre
- 7eb2898dRecords: mpackdb second-opener rule until day38mre
- b011f98eRecords: style form live on day35mre
- 60d90cb2Records: L1 woken for the restartmre
- 75ae544fRecords: restart waits for the connection to closemre
- e0b75951Records: L1 merged and pushed, restart waits for an open connectionmre
- f2b5db98styles: format styles with nested rules and bare queriesmre
- f036bab4search: format styles with nested rules and bare queriesmre
- ef9a9d4asongs: format styles with nested rules and bare queriesmre
- f22f9aacmain: format styles with nested rules and bare queriesmre
- f56cd7c7Sync icons from 8176eb1 and verify mixed component sourcesmre
- d56e5054Sync theme and shared tokens from layouts 17e0f03mre
- b1362547Re-vendor to Hybriel set day35mre
- 89e10f08Records: mission 002 rollback wordingmre
- 9485dee7Records: mission 002 brief (live step)mre
- 9ba68fe7Records: S1b reviewedmre