gitoria

calendar

All repositories: gitoria

ReadmeCodePull requestsReleasesTicketsSettings
Commit728e84e3728e84e3Re-vendor complete Hybriel day41 plugin directoriesmre728e84e3/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(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(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

  • 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
  • 229643f7Merge branch 'cal-14'mre
  • 1110b26fcalendar#14: the month name no longer breaks into two lines on a phone (Reminder settings drops to its own row when the header is too narrow), gate checks for one-line title and all header controls on screenmre
  • 490c658aident#31: the selector's sign-in returns to the page the user started on (return attribute = the login callback with next), gate checkmre
  • 18095868calendar: Reminder settings button opens its dialog again (the dialog's open handler still closed the removed user menu and stopped); old e2e and gate scripts use the new headermre
  • 6eee4b5acalendar header: the selector alone top right plus Log out as before the theme missions; Reminder settings back on the month page (WIP: the settings test still fails)mre
  • 0b909decident selector back in the header (creator 2026-10-24): selector top right signed in and out on phone and desktop, no second Log in button, new gate checks (WIP: gates not re-run after the last edits)mre
  • 0c8f9364Merge branch 'sy-sync'mre
  • 9fab1c8fsync components.hybriel 4922f9c into the month view: prev / next 44 px targets, names formatted in UTC (a UTC+12 zone showed the wrong first weekday); the calendar keeps its own language handling (Accept-Language / browser) and the P1/C13 reminder code; gate: 44 px check (SY)mre
  • 27d3e294theme: sync from layouts 4994037 (list rows stack, td word-keep, heading code, edited tap target)mre
  • 2ac9c1bbdeploy: security gate (tests/security.mjs)mre
  • 6b0a2571merge sc-sec (calendar security) with 99-year sessionsmre