tracker
All repositories: gitoria
4.6 KB
// pagination.hl — THE PAGINATION: "Previous 1 .. 44 45 46 .. 89 Next". Buttons for the first and last page, the current page// and its neighbours, "…" for the pages left out. Previous is missing on the first page, Next on the last. Plain Hybriel, no// script. The page reads `page` (1-based) and `pages` (how many there are) as its own members — set `pages` on the tag:// `Pagination { pages = 89 }`. USE ONE PER PAGE: a composed component's members are the page's state (COMPONENTS.md §12).// Every entry is a button (an `if` or a conditional attribute would re-create the DOM, hybriel#41); the "…" ones// only differ by class, and a click on them does nothing. Each button carries its target page in `data-page` (0 for "…"): a bound// attribute on a row follows the reassigned list (hybriel#100).// DATA OUT (ticket #16): the host hands a function, `Pagination { pages = 89 page = page onPage = goPage }`; a click (pointer or// keyboard) calls `onPage(target)` with the page it goes to — Previous / Next / a number resolved against the page shown BEFORE the// buttons change (hybriel#87: a child talks upward through a function its host gives it; the function writes the host's members).Number page = 1Number pages = 10String previousLabel = 'Previous'String nextLabel = 'Next'onPage = nullHybrid items = build(page, pages)entry(label, target, cls) {return { label = label target = target cls = cls }}// the page numbers to show: first, last, current ± 1; at either end four in a row; 0 = a gapnumbers(p, n) {want = []let i = 1while (i <= n) {let near = i == 1 || i == n || (i >= p - 1 && i <= p + 1)if (p <= 3 && i <= 4) { near = true }if (p >= n - 2 && i >= n - 3) { near = true }if (near) { want.push(i) }i = i + 1}out = []let last = 0let k = 0while (k < want.length) {let v = want[k]if (v == last + 2) { out.push(v - 1) }else if (v > last + 2) { out.push(0) }out.push(v)last = vk = k + 1}return out}build(p, n) {out = []if (p > 1) { out.push(entry(previousLabel, p - 1, 'step')) }nums = numbers(p, n)let k = 0while (k < nums.length) {let v = nums[k]if (v == 0) { out.push(entry('…', 0, 'gap')) }else { out.push(entry('' + v, v, v == p ? 'page current' : 'page')) }k = k + 1}if (p < n) { out.push(entry(nextLabel, p + 1, 'step')) }return out}show(p) {if (p < 1 || p > pages) { return }page = pitems = build(p, pages)}// 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// 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// theme) restyles it. No frames: a border or ring only where it means something. A component's browser module// cannot import tokens itself.Style {pagination { display = 'block' }'pagination ol' { display = 'flex' flexWrap = 'wrap' gap = '.3rem' margin = '0' padding = '0' listStyle = 'none' }'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' }'pagination button:hover' { background = 'var(--color-surface, #f2f2f2)' }// a keyboard focus ring in the base grey (else Chrome draws its own coloured one — seen at 390 px in mission 005)'pagination button:focus-visible' { outline = '2px solid var(--color-accent, #555)' outlineOffset = '1px' }'pagination li.current button' { color = 'var(--color-accent-text, #fff)' background = 'var(--color-accent, #000)' border = '0' }'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' }}View {pagination {nav { title = "Pagination"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) } } } } }}}}// the target is read from the clicked button FIRST (its `data-page`, written for the page shown now), then the list is rebuilt and// 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 pageon paginationGo(e) {b = e.target.closest('button')to = b == null ? null : toNumber(b.getAttribute('data-page'))if (to == null || to < 1 || to > pages || to == page) { return null }show(to)if (onPage != null) { onPage(to) }}
Branches
Latest commits
- 24e401b8Tracker: TR7 watch cleanmre
- b0412957Tracker: RV28b handed overmre
- 456940c8Tracker: RULINGS pathmre
- b87a8fdcTracker: worldapi-conductor paths backmre
- 641f3b54Tracker: Apollo answermre
- 8b3cbddaTracker: status, TR7 fix livemre
- ec30162aTracker: TR7 fix livemre
- 54cbec80compose: ignore SIGPIPE (TR7 crash loop, exit 141)mre
- 3e164b63Tracker: status after CL1mre
- 9d686bb3Tracker: CL1 reviewedmre
- b8bba562CL1: crash loop report (SIGPIPE confirmed, trap wrapper option)mre
- 298785f2Tracker: CL1 startedmre
- 36b22710Tracker: port slot, CL1 briefmre
- a401190fTracker: GO for the crash loopmre
- e195d372Tracker: token pathsmre
- 7f541d11Tracker conductor: CONDUCTOR.md, short STATUS.md, old status + decisions archive to archive/2026-10-31mre
- 8dd423f7README: login.js stays by caramboleyo's explicit rulemre
- d8df1493tracker: standby service on port 45018 and a gap-free hand-over in deploy.sh step 4mre
- 36dd1686ident#31: the selector's sign-in returns to the page the user started on (return attribute = the login callback with next), gate checkmre
- ff9b838etracker: the Ended status pill uses the same red as layouts (pill danger); gate updatedmre