layouts
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(Hybrid list, String say, Hybrid 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) {here = it.current == true || at == it.href || (it.href != '/' && at.startsWith(it.href + '/'))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
- font-segoe-ui
- hl-standard
- hl-standard-2
- hl-standard-4
- hl-standard-5
- mainmain branch
- readme-audit
Latest commits
- 5ea64202|||PR Gate: count the new-tab check's console errors tooAtlas
- 2752ceddMerge branch 'hl-standard-4' into mainAtlas
- ac552b81|||PR Gate: keyboard (Tab/Enter/Space) and Back/Forward/reload/new-tab checks (HL-STANDARD F5, F21)Atlas
- 8cddcaa9Merge branch 'hl-standard-2' into mainAtlas
- 2b480a64|||PR Type the route parameter of main-menu build (HL-STANDARD L10)Atlas
- ab54a39dMerge branch 'hl-standard' into mainAtlas
- 04d36fcf|||PR Type function parameters and drop unneeded let (HL-STANDARD L2, L10)Atlas
- 220c8fa4Merge branch 'readme-audit' into mainAtlas
- b78fb85a|||PR README matches the codemre
- 9f351699Preserve comments and nest supported selectors without changing rendered outputmre
- 97110ad9WIP: nest accepted layout selectors; stopped at startup parse failuremre
- ce4a0baeKeep caller slot styles whole so minimal shell apps startmre
- 12cd3992Re-vendor complete Hybriel plugins and runtime to day44mre
- b05c20feBackup tar: --hard-dereference, so mpackdb sidecars are never stored as hard links (Tracker's finding)mre
- 8d9ed0b8Re-vendor complete Hybriel plugins and runtime to day39mre
- ebd00b6cNest caller slot styles in three-panemre
- 009991efNest caller slot styles in list-firstmre
- 494d75d4Nest caller slot styles in app-sidebarmre
- e5571680Align all plugin sources with Hybriel day38bmre
- 5d204c46Re-vendor layouts to Hybriel set day38bmre