gitoria

calendar

All repositories: gitoria

ReadmeCodePull requestsReleasesTicketsSettings
Commitb37cc1dab37cc1da|||PR Vendor Hybriel day59Atlasb37cc1da/components/main.hl

7.1 KB

  1. // components/main.hl — THE SHELL (mission 006, phone first on the WorldAPI theme): the theme's AppHeader (brand · main menu ·
  2. // user icon), the phone's Sidebar (☰ → the main menu) and the slot every page renders into; the pages render
  3. // in the theme's ContentFirst shell (a month is one big content area, no list beside it; ContentFirst without a desktop sidebar
  4. // gives it the whole 72rem column). The theme's shell files theme/shell/*.hl are never
  5. // edited here. The shell's own CSS is the Style block below; components/styles.hl keeps only the site-wide rules.
  6. // IDENT'S SELECTOR STANDS IN THE HEADER, visible signed in and signed out, on the phone and on the desktop (creator 2026-10-24: the
  7. // theme move hid it behind an icon and replaced it by the user menu — never again; the gate checks it at 390 and 1280). Signed in the
  8. // user icon beside it opens the UserMenu (Log out, Reminder settings). Nothing else stands beside the selector: no second "Log in" button (creator 2026-10-24).
  9. // THE SELECTOR: `<ident-selector key=IDENT_API_KEY>` from <ident>/selector.js, as in gitoria. Choosing an identity
  10. // fires `ident-login` (one-time code); /login.js hands it to the hidden input #identcode, whose `change` goes to the
  11. // face calendarLogin (server-side exchange, lib/users.hl userOfLoginCode; no reload). The element's class is `in` / `out`; /login.js mirrors it into
  12. // the selector's `loggedIn`.
  13. // LOGIN: a plain link to <ident>/login?key=&return=<public url>/login/callback (lib/api.hl loginCallback).
  14. // After a login or logout in this tab the page is fetched again (navigate('/')): the calendar of the session show.
  15. import { navigate } from 'hl:web'
  16. import { siteName } from '../project.hl'
  17. import { identKey, callbackUrl, selectorScript, userIdOfSession, userOfLoginCode } from '../lib/users.hl'
  18. import { randomBytes } from 'hl:crypto'
  19. import AppHeader from '../theme/shell/app-header.hl'
  20. import MainMenu from '../theme/shell/main-menu.hl'
  21. import Sidebar from '../theme/shell/app-sidebar.hl'
  22. import ContentFirst from '../theme/shell/content-first.hl'
  23. slot = null
  24. session = null
  25. loggedIn = userIdOfSession(session) != null
  26. loggedOut = userIdOfSession(session) == null
  27. selectorClass = loggedIn ? 'in' : 'out'
  28. selectorKey = identKey
  29. // where the selector's sign-in panel (ident#31) sends the browser: the login button's callback, with the page the user is on as `next`
  30. // (the callback takes it back there). No route known (first paint) = no `next` = the start page.
  31. route = null
  32. path = route == null ? '' : route.path
  33. selectorReturn = callbackUrl + (path == '' ? '' : '?next=' + encodeURIComponent(path))
  34. identScript = selectorScript
  35. loginError = ''
  36. hasLoginError = false
  37. // the main menu: the header from 60rem, the phone's sidebar below — one list (one page so far; the menu is the shell's place for more)
  38. menu = [ { label = 'Calendar' href = '/' } ]
  39. // The shell's own styles (calendar#16): the header's login widgets — ident's selector, the sign-in error banner and Log out.
  40. // ident's selector stands top right, signed in AND signed out, on the phone and on the desktop — never behind an icon or a popover
  41. // (creator 2026-10-24, "you removed the ident widget from all sites"). Its shadow DOM is in ident's design, restyled to the accent through its
  42. // custom properties and parts; the pill is kept compact so brand, selector and the user icon fit one row at 390 px. Its dropdown opens under it,
  43. // as wide as a phone allows. Colours are the theme's css variables (a component cannot import tokens.hl).
  44. Style {
  45. identSelector { '--ident-accent' = 'var(--color-accent)' '--ident-accent-text' = 'var(--color-accent-text)' '--ident-background' = 'var(--color-surface)' '--ident-border' = 'var(--color-surface)' '--ident-font' = '600 .9rem/1.3 system-ui, sans-serif' position = 'relative' flex = '0 1 auto' minWidth = '0' }
  46. 'ident-selector::part(button)' { minHeight = 'var(--layout-tap)' padding = '.25rem .6rem' whiteSpace = 'nowrap' }
  47. 'ident-selector::part(status)' { minHeight = 'var(--layout-tap)' padding = '.25rem .6rem' whiteSpace = 'nowrap' overflow = 'hidden' textOverflow = 'ellipsis' }
  48. 'ident-selector::part(identity)' { minHeight = 'var(--layout-tap)' }
  49. 'ident-selector::part(panel)' { position = 'absolute' top = '100%' right = '0' zIndex = '30' width = 'min(20rem, calc(100vw - 2 * var(--layout-gutter)))' maxWidth = 'none' boxShadow = '0 .75rem 2rem var(--color-background-sunken)' }
  50. #loginerror { margin = '0' padding = '.5rem var(--layout-gutter)' background = 'var(--color-background-sunken)' }
  51. #logout { flex = 'none' whiteSpace = 'nowrap' padding = '.25rem .5rem' }
  52. }
  53. View {
  54. body {
  55. AppHeader { brand = siteName
  56. MainMenu { items = menu }
  57. // ident's selector stands in the header, visible signed in AND signed out, on the phone and on the desktop (signed in it shows the
  58. // chosen identity). /login.js mirrors its state from the class (`in` / `out`). Nothing else stands beside it: no second "Log in" button (creator 2026-10-24).
  59. identSelector { id = "selector" key = selectorKey return = selectorReturn class = selectorClass }
  60. // signed in, like before the theme missions: Log out stands beside the selector (Reminder settings is on the month page)
  61. if (loggedIn) {
  62. button { id = "logout" type = "button" class = "quiet" "Log out" on click(e) { emit doLogout(e) } }
  63. }
  64. }
  65. input { id = "identcode" type = "hidden" on change(e) { emit gotCode(e) } }
  66. if (hasLoginError) { p { id = "loginerror" class = "message banner" loginError } }
  67. // the phone's overlay with the main menu (desktop = "false": the header shows the menu from 60rem); then the page in the
  68. // content-first shell — hybriel#130: the page slot starts its own line
  69. Sidebar { desktop = "false" MainMenu { items = menu } }
  70. main {
  71. ContentFirst { slot }
  72. }
  73. script { src = identScript }
  74. script { src = "/login.js" }
  75. }
  76. }
  77. showIn = () => {
  78. loggedIn = true
  79. loggedOut = false
  80. selectorClass = 'in'
  81. loginError = ''
  82. hasLoginError = false
  83. }
  84. showOut = () => {
  85. loggedIn = false
  86. loggedOut = true
  87. selectorClass = 'out'
  88. }
  89. // the selector's code (via /login.js and the hidden input) → the server exchanges it
  90. on gotCode(Hybrid e) {
  91. code = e.target.value
  92. e.target.value = ''
  93. if (code == null || code == '') { return null }
  94. r = emit server calendarLogin(code)
  95. if (r == null || r.error != null) {
  96. loginError = r != null ? r.error : 'the login failed'
  97. hasLoginError = true
  98. return null
  99. }
  100. showIn()
  101. navigate('/')
  102. }
  103. on client calendarSignedIn(tag) {
  104. showIn()
  105. navigate('/')
  106. }
  107. on client calendarSignedOut(tag) {
  108. showOut()
  109. navigate('/')
  110. }
  111. on doLogout(Hybrid e) {
  112. emit server calendarLogOut()
  113. showOut()
  114. navigate('/')
  115. }
  116. // ---- the faces (the trailing `session` is always the server's: hybriel #16) ----
  117. on server calendarLogin(code, session) {
  118. if (session == null) { return { error = 'no session — reload the page' } }
  119. x = userOfLoginCode(code)
  120. if (x.error != null) { return { error = x.error } }
  121. tag = randomBytes(16)
  122. session.user = { id = x.user.id }
  123. session.data.tag = tag
  124. emit client calendarSignedIn(tag)
  125. return { ok = true }
  126. }
  127. on server calendarLogOut(session) {
  128. if (session == null) { return { error = 'no session' } }
  129. emit client calendarSignedOut(session.data.tag)
  130. session.user = null
  131. return { ok = true }
  132. }

Branches

Latest commits

  • b37cc1da|||PR Vendor Hybriel day59Atlas
  • 05665102Merge branch 'vendor-day56' into mainAtlas
  • 687296fb|||PR Vendor Hybriel day56Atlas
  • a6166d4eMerge branch 'hl-standard-3' into mainAtlas
  • 6d0eb3b0|||PR Calendar day add buttons only when signed in (Kunibert minor)Atlas
  • add4b499|||PR Make calendar day actions keyboard accessibleAtlas
  • 79e49b4dMerge branch 'hl-standard' into mainAtlas
  • e9fec7bb|||PR HL-STANDARD clean-up: typed parameters, plain locals, by-reference cacheAtlas
  • eff166a4Re-vendor complete Hybriel plugins and runtime to day44mre
  • cef81394Wait for the DST fixture page instead of an unused socketmre
  • 42434f47Check lazy-session cookies after login with a stored anonymous fixturemre
  • 728e84e3Re-vendor complete Hybriel day41 plugin directoriesmre
  • cbd7ff43Backup tar: --hard-dereference, so mpackdb sidecars are never stored as hard links (Tracker's finding)mre
  • 59d1da0acalendar: plain declarations instead of needless let in 9 files (calendar#17): 49 declarations that are never reassigned; reassigned ones and the timer closure's p stay letmre
  • f5415cf9calendar: the Style blocks in the language's nested form (calendar#16): rules named after the View's own elements with their children nested, pseudo-classes and @media nested, merged duplicate select rule; same CSS, shots identical in Chrome at 4 sizesmre
  • edb7c947calendar: the sign-in callback keeps the session it finds and signs it in (same cookie, nothing signed out; ident#28); security gate 56+4 failing → 60 passedmre
  • bf8cc0fcStyles move into their components: the shell's styles into main.hl, the events and the editors into the month view's Style block; styles.hl keeps only the theme inherit, the accent and the message line; .gitignore ignores a bin symlink too; tests/styles-shots.mjs for the before/after pixel comparemre
  • 5d8579d7README: login.js stays by caramboleyo's explicit rulemre
  • cc759328Merge sb3-standby: calendar deploys through its standbymre
  • f2fcdc6dcalendar: a standby container (port 45015, profile standby, reminder clock off) and a /health page; deploy hands over through standby-swap.sh without a gapmre