tracker
All repositories: gitoria
4.5 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) {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) {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'ol {display = 'flex'flexWrap = 'wrap'gap = '.3rem'margin = '0'padding = '0'listStyle = 'none'}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'hover {background = 'var(--color-surface, #f2f2f2)'}focusVisible {outline = '2px solid var(--color-accent, #555)'outlineOffset = '1px'}}'li.current' {button {color = 'var(--color-accent-text, #fff)'background = 'var(--color-accent, #000)'border = '0'}}'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
- 5b3a5693Log: SR1b merged via PR 2, DP71 startedTracker
- 783957c2Merge branch 'sr1-search' into mainTracker
- 792b9652README: search results come from the routeTracker
- fd8570b1|||PR search: one server exchange per keystrokeTracker
- e8f5cbcaLog: SR1 result, SR1bTracker
- 8ad275a4Log/status: tracker 68, SR1Tracker
- f5a06a0fLog: gitoria push setup, SR1Tracker
- d6b109baMission SR1mre
- 608b7558Log: FF1 merged via PR #1mre
- 2939d94cMerge branch 'ff1-gate-failfast' into mainTracker
- c934361a|||PR tests: gates fail fast when the app exits during startmre
- d714ae42Log/status: AP56 closed out, FF1mre
- a429d088Mission FF1mre
- 03bbfba3Log: AP56c causemre
- 24845fe3Log: AP56b result, AP56cmre
- 6a6d71eaLog: gitoria membershipmre
- 8b842dc8Log + CONDUCTOR: gitoria PR switch-onmre
- 6bb7c20estatus: window 2026-11-09mre
- 5db84974Log: Apollo window GO, AP56b started, BS1 copy removedmre
- e84586a7Mission AP56bmre