gitoria

layouts

All repositories: gitoria

ReadmeCodePull requestsReleasesTicketsSettings
Commit97110ad997110ad9WIP: nest accepted layout selectors; stopped at startup parse failuremre97110ad9/theme/shell/main-menu.hl

3.6 KB

  1. // main-menu.hl — THE MAIN MENU: the app's top-level links, `Series | Shows | Movies` (docs/layouts/main-menu.md).
  2. // Write it twice from ONE list: in the header (shown from 60rem) and in the sidebar (shown on the phone, where the
  3. // header has no room). The link whose href is `current` (or a page below it) is marked: class `current` and
  4. // aria-current="page". With no `current` given, the menu takes the page from the route (hybriel#197: `route = null`,
  5. // {path, params, pattern}, there in the server's HTML, so the marker is in the first paint and moves on a client click).
  6. // Without a matching path the host says which one: `current = "/docs"` (the page /read/x is
  7. // under Docs) or `current = true` on the item itself. An item may carry a small count: `count = 3` (a badge, not text).
  8. //
  9. // static menu = [ {
  10. label = 'Series'
  11. href = '/series'
  12. } { label = 'Movies' href = '/movies' } ]
  13. // AppHeader { MainMenu { items = menu current = "/series" } }
  14. // Sidebar { desktop = "false" MainMenu { items = menu current = "/series" } }
  15. Hybrid items = []
  16. String current = ''
  17. String label = 'Main menu'
  18. route = null
  19. Hybrid rows = build(items, current, route)
  20. // one row per link: the current one (the page itself or a page below it) is marked
  21. build(list, say, r) {
  22. // the host's say (`current`) wins; without one the shell's route (hybriel#197, in the server's HTML too) is the page
  23. at = say != '' ? say : (r == null ? '' : r.path)
  24. out = []
  25. for (it of list) {
  26. let here = it.current == true || at == it.href || (it.href != '/' && at.startsWith(it.href + '/'))
  27. let n = it.count == null ? '' : '' + it.count
  28. out.push({ label = it.label href = it.href count = n has = n != '' cls = here ? 'current' : '' aria = here ? 'page' : 'false' })
  29. }
  30. return out
  31. }
  32. Style {
  33. mainMenu {
  34. display = 'block'
  35. a {
  36. display = 'flex'
  37. alignItems = 'center'
  38. minHeight = 'var(--layout-tap)'
  39. padding = '.55rem .75rem'
  40. fontWeight = '600'
  41. color = 'var(--color-text)'
  42. borderRadius = 'var(--radius-small)'
  43. hover {
  44. textDecoration = 'none'
  45. color = 'var(--color-text-strong)'
  46. background = 'var(--color-surface)'
  47. }
  48. // Class rule would lose its ancestor or has no View reference (probe v03; hybriel#243).
  49. 'span.count' {
  50. marginLeft = '.5rem'
  51. padding = '0 .45rem'
  52. minWidth = '1.4rem'
  53. textAlign = 'center'
  54. fontSize = '.8rem'
  55. fontWeight = '700'
  56. lineHeight = '1.4rem'
  57. color = 'var(--color-accent-text)'
  58. background = 'var(--color-accent)'
  59. borderRadius = 'var(--radius-small)'
  60. }
  61. }
  62. // Class rule would lose its ancestor or has no View reference (probe v03; hybriel#243).
  63. 'a.current' {
  64. color = 'var(--color-accent)'
  65. background = 'var(--color-surface)'
  66. }
  67. }
  68. // Ancestor context is outside this View; retain whole selector (hybriel#243; v23).
  69. 'application-header' {
  70. mainMenu {
  71. display = 'none'
  72. @media {
  73. minWidth = '60rem'
  74. display = 'block'
  75. marginLeft = 'auto'
  76. }
  77. nav {
  78. @media {
  79. minWidth = '60rem'
  80. display = 'flex'
  81. gap = '.15rem'
  82. }
  83. }
  84. }
  85. }
  86. // Ancestor context is outside this View; retain whole selector (hybriel#243; v23).
  87. 'app-sidebar' {
  88. mainMenu {
  89. marginBottom = '1rem'
  90. @media {
  91. minWidth = '60rem'
  92. display = 'none'
  93. }
  94. }
  95. }
  96. @media {
  97. minWidth = '60rem'
  98. // Ancestor context is outside this View; retain whole selector (hybriel#243; v23).
  99. 'application-header' {
  100. mainMenu {
  101. a {
  102. minHeight = '2.25rem'
  103. padding = '.45rem .7rem'
  104. }
  105. }
  106. }
  107. }
  108. }
  109. View {
  110. mainMenu {
  111. nav { 'aria-label' = label
  112. for (r of rows) { a { href = r.href class = r.cls 'aria-current' = r.aria r.label if (r.has) { span { class = 'count' r.count } } } }
  113. }
  114. }
  115. }

Branches

Latest commits

  • 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
  • 17e0f03eNest html-prefixed theme component overridesmre
  • e54e735eFormat plain theme elements with nested rules and bare mediamre
  • 547f834eRecord LY7 deployment and live verificationmre
  • fa4600b1Link caller-slot style exceptions to hybriel#270mre
  • 413b11e1Record corrected LY7 nesting, exact CSS and Chrome proofmre
  • b810453etracker-demo: nest child and compound selectors in Stylemre
  • 0b5b1d61notes-demo: nest child and compound selectors in Stylemre
  • ab22bdc2mail-demo: nest child and compound selectors in Stylemre
  • fe2d8de9home: nest child and compound selectors in Stylemre
  • e631791buser-menu: nest child and compound selectors in Stylemre