gitoriaLog in with ident

tracker

All repositories: gitoria

ReadmeCodePull requestsReleasesTicketsSettings
Commitf14db671f14db671tracker#22-#25 (mission 058): episode air dates, season check = all episodes watched, movie watched check (+ /my/movies count), /genres/<genre> pages (movies + series, newest first, paginated); gate 238, tests/realdata-058.mjs, README + STATUSmref14db671/components/pagination.hl

3.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 (a bound attribute like tabindex does not follow a reassigned list).
  7. Number page = 1
  8. Number pages = 10
  9. String previousLabel = 'Previous'
  10. String nextLabel = 'Next'
  11. Hybrid items = build(page, pages)
  12. entry(label, target, cls) {
  13. return { label = label target = target cls = cls }
  14. }
  15. // the page numbers to show: first, last, current ± 1; at either end four in a row; 0 = a gap
  16. numbers(p, n) {
  17. let want = []
  18. let i = 1
  19. while (i <= n) {
  20. let near = i == 1 || i == n || (i >= p - 1 && i <= p + 1)
  21. if (p <= 3 && i <= 4) { near = true }
  22. if (p >= n - 2 && i >= n - 3) { near = true }
  23. if (near) { want.push(i) }
  24. i = i + 1
  25. }
  26. let out = []
  27. let last = 0
  28. let k = 0
  29. while (k < want.length) {
  30. let v = want[k]
  31. if (v == last + 2) { out.push(v - 1) }
  32. else if (v > last + 2) { out.push(0) }
  33. out.push(v)
  34. last = v
  35. k = k + 1
  36. }
  37. return out
  38. }
  39. build(p, n) {
  40. let out = []
  41. if (p > 1) { out.push(entry(previousLabel, p - 1, 'step')) }
  42. let nums = numbers(p, n)
  43. let k = 0
  44. while (k < nums.length) {
  45. let v = nums[k]
  46. if (v == 0) { out.push(entry('…', 0, 'gap')) }
  47. else { out.push(entry('' + v, v, v == p ? 'page current' : 'page')) }
  48. k = k + 1
  49. }
  50. if (p < n) { out.push(entry(nextLabel, p + 1, 'step')) }
  51. return out
  52. }
  53. show(p) {
  54. if (p < 1 || p > pages) { return }
  55. page = p
  56. items = build(p, pages)
  57. }
  58. // Colours: the semantic WorldAPI tokens as css variables, each with its palette value as fallback, so a copy of this file is styled in an app that declares no tokens (an app that imports shared/tokens.hl in its styles.hl and sets --color-accent wins). A component's browser module cannot import tokens.hl itself.
  59. Style {
  60. pagination { display = 'block' }
  61. 'pagination ol' { display = 'flex' flexWrap = 'wrap' gap = '.3rem' margin = '0' padding = '0' listStyle = 'none' }
  62. 'pagination button' { font = 'inherit' fontWeight = '600' minWidth = '2.2rem' padding = '.35rem .6rem' color = 'var(--color-text, rgb(195, 200, 205))' background = 'transparent' border = '1px solid var(--color-border, rgb(70, 75, 80))' borderRadius = '.4rem' cursor = 'pointer' }
  63. 'pagination button:hover' { background = 'var(--color-surface, rgb(35, 40, 45))' }
  64. 'pagination li.current button' { color = 'var(--color-accent-text, rgb(15, 20, 25))' background = 'var(--color-accent, #569bd4)' border = '1px solid var(--color-accent, #569bd4)' }
  65. 'pagination li.gap button' { color = 'var(--color-text-muted, rgb(145, 150, 155))' background = 'transparent' border = '0' minWidth = '0' padding = '.35rem .2rem' cursor = 'default' pointerEvents = 'none' }
  66. }
  67. View {
  68. pagination {
  69. nav { title = "Pagination"
  70. ol { id = "pagination-items" for (it of items) { li { class = it.cls button { type = "button" class = "quiet" it.label on click(e) { emit paginationGo(e.target.textContent) } } } } }
  71. }
  72. }
  73. }
  74. // the click carries the button's text (a bound attribute does not follow a reassigned list, a text does)
  75. on paginationGo(text) {
  76. if (text == previousLabel) { show(page - 1) }
  77. else if (text == nextLabel) { show(page + 1) }
  78. else if (text != '…') { show(toNumber(text)) }
  79. }

Branches

Latest commits

  • f14db671tracker#22-#25 (mission 058): episode air dates, season check = all episodes watched, movie watched check (+ /my/movies count), /genres/<genre> pages (movies + series, newest first, paginated); gate 238, tests/realdata-058.mjs, README + STATUSmre
  • 1704ec45tracker#17 (mission 057): season caret down/up, skeleton rows while a season loads, sessionless showSeasonEpisodes face (no page re-mount), client-only close; gate 214, tests/realdata-057.mjs, README + STATUSmre
  • f2fe3e36mission 056: README + STATUS (merge, fixes, Hybriel 8590df63, real-data check), tests/realdata-056.mjs, tools/check-public-slugs.hlmre
  • f40c250emission 056: re-vendor hybriel master 8590df63 (#121, #122); an adult title's page is Not found for non-followers; gate: leave the page before stopping the servermre
  • 2b7fdd6cmission 056: signed-out header one row on phones ("Log in", nowrap), backfill skips adult titles' posters, gate checksmre
  • 2c53d5efMerge branch 't16-person' (tracker#16 person pages) into main; filmography shows only public titles (054 adult flag), gate race fix (backfill start line)mre
  • c171227emission 054: hide adult/unknown titles from the public lists and the search; in-app adult-flag backfill (TMDB details + poster per title, resumes), gate + real-data proofmre
  • 139fafd8tracker#16: short bio (4 lines, click = all), real-data check script, README + STATUSmre
  • 93be9476tracker#16: person pages /person/<slug> with the filmography fetched from TMDB on the first visit (step by step), gatemre
  • 47a3cae6STATUS: mission 053 merge commit idsmre
  • dcc5eecaMerge branch 't14-search'mre
  • 03edc783Merge branch 't15-tvmaze'mre
  • 71b46345tracker#15: numbering check by date or title, placeholder titles in other languages, docs + real-data proofmre
  • 6bb2daf1tracker#13: homepage (tiles, intro, latest movies/shows), /shows, /movies/page/N, /my/movies; lists cached in memorymre
  • b8bd1157tracker#14: README + STATUS (search, real-data numbers, gate, merge notes)mre
  • 65c694a8tracker#14: search — header magnifier, /search/<text> (in-memory word-prefix index over titles + people), Fetch from web (TMDB search/multi, ours left out), Add = import via syncShow; gate +25 checks, real-data scriptmre
  • 34f2c15btracker#15: TVmaze merge in the sync (gaps only: new episodes/seasons, empty titles/air dates; numbering check), fake TVmaze episodes + gatemre
  • cbdc4ea7tracker#12: link icons TMDB/IMDb/TVDB/TVmaze; sync fills missing ids (TVmaze lookup); movies fetched via /movie/mre
  • b105bcd8tracker#11: Hybriel master ff51cf46 (checks no longer vanish), mobile-first styles, carets, follow button, sign-in modal, inverted check, orange castmre
  • 31b758aatracker#10: installable app (manifest, service worker, offline shell), own icon + faviconmre