github-repos-js — GitHub Repositories (continuation-URL pagination)
A demo of vanilla-grid against a public REST API that paginates via the
HTTP Link header (rel="next" continuation URLs). Implements a custom
DataManager that stores the next URL in its own state and ignores the
grid's (skip, pageSize) hint entirely.
What it shows
- Custom
DataManagersubclass —GitHubReposDataManagerextendswindow.DataManagerand overridesfetchRows()/fetchMoreRows(), which forward thesignal<vn-grid>passes them tofetch()(the grid aborts it when a newer load supersedes the request; the manager keeps no controller of its own). - Continuation URL pagination — parses
Link: <url>; rel="next"and re-issues GET on it for each subsequent page. - Optional total count — GitHub Search returns the real
total_count(millions); the status bar uses the "loaded N/total" format when known. Note: the GitHub Search API itself only allows pagination through the first 1,000 matching results — past that theLink: rel="next"header is no longer returned and our pagination naturally stops, even thoughtotal_countis much larger. <vn-grid-toolbar>status bar — asrc/vanilla-grid-toolbar/linked to the grid: standard auto-fit / reset / clear-filters / reload commands in the empty template; export-to-Excel + a custom view command (opens the repo detail panel, single selection only) + clear-selection in the selected template. Only theexportToExcelcommand is overridden (registerCommand) for the app's file naming (theme-matched Excel styling is automatic — the grid'sexportToExcel()defaults tothemeStyle: 'auto') and returns the export's promise, so the toolbar handles its outcome (a cancelled export is not an error); the view command is handled via thevn-grid-toolbar-commandevent. The row-count line is the autonomous<vn-grid-toolbar-status>(self-updates from grid state, including the live selection count, onceconfigureToolbarRowCountStatus()pushes the localized strings in); a host-driven<vn-grid-toolbar-status-message>carries only transient text (e.g. fetch errors), set viareposToolbar.setStatusMessage().- Multiple-row selection, row double-click → detail side panel, Excel export (theme-styled), 14 themes, EN/IT i18n, resizable grid container — all kept identical to northwind-orders-js.
- Export cap —
initializeGrid({ export: { maxMaterializedRows: 1000 } }), the Search API's own ceiling: a larger export is refused with a dialog in the export overlay. The app'sDataManagerhas nofetchAllRows(), so a select-all export (or the defaultscope: 'all') with pages still unloaded is refused with theexportUnsupporteddialog rather than exporting the loaded subset; scroll to load every row first. The toolbar's selected-count suffix reads "N+ selected" while a select-all's total is unknown.
Resizing the grid
The toolbar and the grid sit together in a src/vanilla-resize-box/ (aria-label="Resizable repositories grid and toolbar"). The box takes a single content child, so the two are stacked in a .resize-content wrapper, and it has a minimum size of 920 x 300 px (min-width="920", min-height="300"). Drag the corner handle to resize them together — resizing is pointer-driven, with no keyboard path. Double-click the handle to fill the available space, and again to restore the previous size.
The handle carries role="separator" and takes its accessible name from the host's aria-label — here "Resizable repositories grid and toolbar — resize handle" — but is not focusable, so it adds no tab stop to the page. This app's markup needs nothing beyond the aria-label it already carries.
Endpoint
GET https://api.github.com/search/repositories
?q=language:javascript
&sort=stars
&order=desc
&per_page=100
per_pageis capped at 100. The GitHub Search API silently clamps any larger value to 100. The data manager enforces this cap itself so the actual page size always matches what the server returns.
Sorting
Server-side sorting is wired for the three columns the GitHub Search API supports:
| Grid column | API sort= value |
|---|---|
| Stars | stars |
| Forks | forks |
| Updated | updated |
Clicking any other column header (Repo ID, Repository, Owner, Description,
Language, Open Issues, Created, License, Topics) has no effect because GitHub
does not expose a sort field for those. They are marked sortable="false" in
the HTML so the sort indicator is never shown.
open_issues_countis intentionally non-sortable: the closest GitHub option (help-wanted-issues) counts only issues labelled "help wanted", which is not the same as total open issues and would produce confusing results.
Rate limits
GitHub allows 60 unauthenticated requests/hour per IP. To raise that to 5000/h, set a personal access token in DevTools console:
localStorage.setItem('github-repos-js:githubToken', 'ghp_yourReadOnlyToken');
location.reload();
The token requires no scopes for public-repo search.
A 429, or a 403 that carries X-RateLimit-Remaining: 0, is reported
in the toolbar as the rate-limit message. GitHub also answers 403 for other
reasons (a blocked or forbidden query), and those are reported as the plain
HTTP error instead of being mistaken for a rate limit. The error reaches the
status line once, from the DataManager's onFetchError hook.
The detail panel links the repository URL and its homepage only when they
are http:/https: URLs (a homepage is free text its owner sets); any
other scheme is shown as plain text.
Run
Serve the workspace root with any static server, then open
/samples/github-repos-js/index.html.
Files
index.html— same shell as northwind-orders-js; columns target GitHub fields.modules/repos-tab.js— definesGitHubReposDataManagerand wires the grid (initializeReposGrid) / detail panel / export. The*-tab.jsfilename mirrors the other samples; the symbols inside are repo-flavored.modules/i18n.js— repo-specific translations.modules/dom-refs.js,modules/theme.js,styles.css— unchanged from northwind-orders-js. The app themes are the shared../_common/themes/app-*.css(seesamples/_common/README.md).
Notes for adapting to other Link-header APIs
The same pattern works unchanged for any API that returns a Link header
with rel="next" (Stripe, Atlassian, …). Only _buildInitialUrl() and
_get() JSON shape need adapting.