gitoria

tracker

All repositories: gitoria

ReadmeCodePull requestsReleasesTicketsSettings
Commit105309de105309detap targets: every row link, the TMDB/IMDb badges, the widget links, the franchise names and the login-failed link are 44 px high on a phonemre105309de/components/pagination.hl

4.6 KB

  1. // pagination.hl — THE PAGINATION: "Previous 1 .. 44 45 46 .. 89 Next". Buttons for the first and last page, the current page
  2. // and its neighbours, "…" for the pages left out. Previous is missing on the first page, Next on the last. Plain Hybriel, no
  3. // script. The page reads `page` (1-based) and `pages` (how many there are) as its own members — set `pages` on the tag:
  4. // `Pagination { pages = 89 }`. USE ONE PER PAGE: a composed component's members are the page's state (COMPONENTS.md §12).
  5. // Every entry is a button (an `if` or a conditional attribute would re-create the DOM, hybriel#41); the "…" ones
  6. // only differ by class, and a click on them does nothing. Each button carries its target page in `data-page` (0 for "…"): a bound
  7. // attribute on a row follows the reassigned list (hybriel#100).
  8. // DATA OUT (ticket #16): the host hands a function, `Pagination { pages = 89 page = page onPage = goPage }`; a click (pointer or
  9. // keyboard) calls `onPage(target)` with the page it goes to — Previous / Next / a number resolved against the page shown BEFORE the
  10. // buttons change (hybriel#87: a child talks upward through a function its host gives it; the function writes the host's members).
  11. Number page = 1
  12. Number pages = 10
  13. String previousLabel = 'Previous'
  14. String nextLabel = 'Next'
  15. onPage = null
  16. Hybrid items = build(page, pages)
  17. entry(label, target, cls) {
  18. return { label = label target = target cls = cls }
  19. }
  20. // the page numbers to show: first, last, current ± 1; at either end four in a row; 0 = a gap
  21. numbers(p, n) {
  22. want = []
  23. let i = 1
  24. while (i <= n) {
  25. let near = i == 1 || i == n || (i >= p - 1 && i <= p + 1)
  26. if (p <= 3 && i <= 4) { near = true }
  27. if (p >= n - 2 && i >= n - 3) { near = true }
  28. if (near) { want.push(i) }
  29. i = i + 1
  30. }
  31. out = []
  32. let last = 0
  33. let k = 0
  34. while (k < want.length) {
  35. let v = want[k]
  36. if (v == last + 2) { out.push(v - 1) }
  37. else if (v > last + 2) { out.push(0) }
  38. out.push(v)
  39. last = v
  40. k = k + 1
  41. }
  42. return out
  43. }
  44. build(p, n) {
  45. out = []
  46. if (p > 1) { out.push(entry(previousLabel, p - 1, 'step')) }
  47. nums = numbers(p, n)
  48. let k = 0
  49. while (k < nums.length) {
  50. let v = nums[k]
  51. if (v == 0) { out.push(entry('…', 0, 'gap')) }
  52. else { out.push(entry('' + v, v, v == p ? 'page current' : 'page')) }
  53. k = k + 1
  54. }
  55. if (p < n) { out.push(entry(nextLabel, p + 1, 'step')) }
  56. return out
  57. }
  58. show(p) {
  59. if (p < 1 || p > pages) { return }
  60. page = p
  61. items = build(p, pages)
  62. }
  63. // Look: black, white and the greys #555 #999 #ddd #f2f2f2 (the library's base, named in shared/base.hl; README "Look"). Every colour is a semantic token
  64. // with its base value as fallback, `var(--color-…, #000)`, so a bare copy looks right and an app that declares the tokens (layouts.worldapi.org's
  65. // theme) restyles it. No frames: a border or ring only where it means something. A component's browser module
  66. // cannot import tokens itself.
  67. Style {
  68. pagination { display = 'block' }
  69. 'pagination ol' { display = 'flex' flexWrap = 'wrap' gap = '.3rem' margin = '0' padding = '0' listStyle = 'none' }
  70. 'pagination button' { font = 'inherit' fontWeight = '600' minWidth = '2.75rem' minHeight = '2.75rem' padding = '.35rem .6rem' color = 'var(--color-text, #000)' background = 'transparent' border = '0' borderRadius = '.4rem' cursor = 'pointer' }
  71. 'pagination button:hover' { background = 'var(--color-surface, #f2f2f2)' }
  72. // a keyboard focus ring in the base grey (else Chrome draws its own coloured one — seen at 390 px in mission 005)
  73. 'pagination button:focus-visible' { outline = '2px solid var(--color-accent, #555)' outlineOffset = '1px' }
  74. 'pagination li.current button' { color = 'var(--color-accent-text, #fff)' background = 'var(--color-accent, #000)' border = '0' }
  75. 'pagination li.gap button' { color = 'var(--color-text-muted, #555)' background = 'transparent' border = '0' minWidth = '0' minHeight = '0' padding = '.35rem .2rem' cursor = 'default' pointerEvents = 'none' }
  76. }
  77. View {
  78. pagination {
  79. nav { title = "Pagination"
  80. ol { id = "pagination-items" for (it of items) { li { class = it.cls button { type = "button" class = "quiet" 'data-page' = it.target it.label on click(e) { emit paginationGo(e) } } } } }
  81. }
  82. }
  83. }
  84. // the target is read from the clicked button FIRST (its `data-page`, written for the page shown now), then the list is rebuilt and
  85. // the host told — so neither a real click (the rebuild can run before a host's own listener) nor a script's `click()` sees another page
  86. on paginationGo(e) {
  87. b = e.target.closest('button')
  88. to = b == null ? null : toNumber(b.getAttribute('data-page'))
  89. if (to == null || to < 1 || to > pages || to == page) { return null }
  90. show(to)
  91. if (onPage != null) { onPage(to) }
  92. }

Branches

Latest commits

  • 105309detap targets: every row link, the TMDB/IMDb badges, the widget links, the franchise names and the login-failed link are 44 px high on a phonemre
  • f0b86c8efranchises: 40 loose timelines per page (/franchises/page/N) and a merge sort for the names (1,546 timelines: 20 s and 54,000 px before)mre
  • b9e841a7Merge branch 'sy-sync'mre
  • d1ae2701sync components.hybriel 4922f9c: modal and pagination 44 px targets (vendored copies, verbatim) (SY)mre
  • 043624b2theme: sync from layouts 4994037 (list rows stack, td word-keep, heading code, edited tap target)mre
  • 05d89fd0deploy: security gate (tests/security.mjs)mre
  • 2ae8a47bMerge branch 'sk-sec'mre
  • 8fee5d52sessions last 99 years (creator 2026-10-23: logins never expire; only sign out ends them)mre
  • 944ad51eSK: report reports/SK-sec.md, LOGsk
  • 415487c1SK: import budget per user + id type check, gate checkssk
  • 7b8a4f74security audit SK: nosniff + image sandbox headers, face id checks, adult follow, login budget + new session at login, guest-link budget, tests/security.mjssk
  • f0f26c5areports: T18 section (gates, boot-gate, 3x3 table, search + short-id compare)mre
  • 2a8682a1deploy.sh GATES: tests/warmstart.mjsmre
  • 3761338breports/T17-boot.md: handoff (phase table, fix, numbers so far, open proof)mre
  • 52e09eb2boot: sync window 1000 ms (the gates ask for a complete start), README boot-time sectionmre
  • c87149e8tests/warmstart.mjs: the progressive start proven over HTTP (note in the window, 503 short id, after: everything); bootBeginmre
  • 593a6350boot: resumable start-up scan, the server listens first (T17)mre
  • be4890a0reports: H2 hydration audit (no test change needed)mre
  • 1f9c8bf4re-vendor Hybriel 5406d146 (hl:web batches 9+10: #72 emits while the socket is closed delivered after reconnect, browser boot linear, faster list appends; contains int 6–14 + m406)mre
  • c1df88eddocker-compose: HL_GC_TABLE_LOAD=62 (tracker mission 048, T16 real-data numbers)mre