Skip to content

feat: rebuild the admin dashboard around act / context / reference - #213

Open
thunpisit wants to merge 1 commit into
mainfrom
feat/admin-refresh
Open

thunpisit wants to merge 1 commit into
mainfrom
feat/admin-refresh

Conversation

@thunpisit

Copy link
Copy Markdown
Contributor

Closes #211 (dashboard phase 1 only — phases 2 and 3 stay open).

The dashboard had grown to eight sections of near-identical visual weight, and most of its numbers did not change what an operator does next. On a fresh install it rendered eight panels, six of them empty, with a text-5xl zero as the largest element on the page — the first screen a new operator ever sees, and it read as a failed deployment rather than a new one.

Information architecture

Three bands, ordered act → context → reference:

  1. NEEDS YOU — drafts, the scheduled queue, and searches that returned nothing. Work items, above the fold.
  2. REACH — views over 30d with a direction of travel, the daily trend, and the articles that produced it.
  3. REFERENCE — translation coverage (only when a locale is behind) and the audit feed.

Promoted: "searched for, not found" out of the bottom half of a "Search insights" card into band 1. It is the most directly actionable list on the page — visitors asked for content in their own words and got nothing — and it was below the fold.

Metrics cut, and why

Cut Reason
Articles Printed twice (headline sub-line and its own tile), and it is the denominator of published/drafts, not a metric
Media Files No decision follows from it on a dashboard
Users Same — it belongs on the users page, where it already is
Published at 5xl A stock, not a flow. It only moves when you move it, so it cannot be news. Demoted to a tile

Added: total views with % change vs the previous 30 days — the one number an operator actually checks, previously absent entirely while Media Files: 0 got a tile. viewsWithPrevious() reports the previous window as null rather than 0 when there is no data, so a first-month install shows "no comparison yet" instead of a meaningless +100%.

Shared primitives, not one-off styling

Four components in $lib/components/admin, ported from the design language redblu-siloscale / redblu-autoscale / khaopad-telemetry already share. PageShell's own comment records what happens when 45 pages each style themselves — five padding scales, six max-widths — so this changes the primitives rather than the page:

  • MetricTile — tone colours the number, never the tile. Both upstream implementations carry this comment: a tinted card makes every tile shout at one volume, which is the same as no emphasis at all. null renders — + "no data yet", never 0 — "nobody visited" and "not measured" are different facts.
  • EmptyState — dashed border, a bold line naming what appears here, one sentence on how to make it appear. The dashed edge is load-bearing: a solid border is the same affordance as a populated card, which is exactly the confusion that made a fresh install look broken.
  • TrendChart — 30-day area chart. Three gridlines, no axis spine, no tick marks; first/middle/last date labels only (more collide at phone width).
  • Sparkline — 14-day bars per top article. Zero days draw a hairline at the baseline so a gap in publishing stays visible instead of collapsing to nothing.

All inline SVG, no new dependencies. The admin runs under script-src 'self'; a CDN chart library is a new script origin, and this codebase already paid for underestimating that policy when the admin webfont was silently blocked for weeks. Every stroke and fill is a semantic token, so light/dark needs no second set of markup.

A fresh install now shows one instruction and one action.

Gates

Gate Result
pnpm run lint 0 errors (55 pre-existing warnings, untouched files)
pnpm run check 0 errors (35 pre-existing warnings)
pnpm test 1114 / 1114 passed
pnpm build ok
node scripts/contract-guard.mjs ok
node scripts/css-inventory.mjs re-baselined — see below

On the test baseline: the baseline on main is 1114, measured before any change in this branch. This PR neither adds nor removes tests, and no pre-existing test was lost — all 78 files and 1114 tests pass, including every pin in design-system.node.test.ts, unmodified.

css-inventory re-baseline. Six classes are no longer emitted, all from markup this PR deletes; no classes added:

  • text-5xl (+ tokens --text-5xl, --text-5xl--line-height) — the giant published-count number
  • lg:col-span-1, xl:grid-cols-5, md:grid-cols-4, 2xl:grid-cols-3, 2xl:grid-cols-8 — the six-tile counter row and the 8-column grids

Verification, and what it does not cover

Verified on npx wrangler dev --port 4214 --local in light and dark mode, with seeded content and against an emptied database. No console errors; no horizontal overflow with content constrained to 390px.

The four live deployments were not inspected. test.drvakuum.com, www.bactrack.in.th, www.codustry.com and khaopad-example.codustry.workers.dev all sit behind a login wall, and the browser profile available was not authenticated to any of them — so there was nothing to inspect without signing in, and no credentials were entered. Evidence came from a locally seeded instance instead.

That bounds what the "before" evidence proves: it covers layout, hierarchy, empty states and the shape of the metrics, all of which a local instance reproduces faithfully. It does not cover real-site data volumes, the shop-enabled vs shop-disabled contrast on live sites, or the specific behaviour reported in #200. Someone with access should sanity-check the new dashboard against a real deployment before this ships.

Scope

Dashboard only. The other 44 admin pages are untouched — phase 2 (19 data-table pages, which have the same empty-state problem) and phase 3 (form/editor pages) are deliberately deferred so the primitives get proven on one page before 44 more adopt them. The visitor-sources work on feat/visitor-sources-v2 has an obvious home as a "view all" from the REACH band; no analytics capture was built here.

Unrelated finding filed separately as #212 (pnpm run db:seed writes a file that three migration-reading tests then load and fail on).

Do not merge or deploy — for maintainer review.

🤖 Generated with Claude Code

The dashboard had grown to eight sections of near-identical visual
weight, and most of its numbers did not change what an operator does
next. On a FRESH INSTALL it rendered eight panels, six of them empty,
with a `text-5xl` zero as the largest element on the page — the first
screen a new operator ever sees, and it reads as a failed deployment
rather than a new one.

## Information architecture

Three bands, ordered act → context → reference:

  1. NEEDS YOU  — drafts, the scheduled queue, and searches that
                  returned nothing. Work items, above the fold.
  2. REACH      — views over 30d WITH a direction of travel, the daily
                  trend, and the articles that produced it.
  3. REFERENCE  — translation coverage (only when a locale is behind)
                  and the audit feed.

Promoted: "searched for, not found" out of the bottom half of a
"Search insights" card into band 1. It is the most directly actionable
list on the page — visitors asked for content in their own words and
got nothing — and it was below the fold.

## Metrics cut, and why

  · Articles      — printed TWICE (headline sub-line and its own tile),
                    and it is the denominator of published/drafts, not
                    a metric.
  · Media Files   — no decision follows from it on a dashboard.
  · Users         — same; it belongs on the users page, where it is.
  · Published(5xl)— a stock, not a flow. It only moves when you move
                    it, so it cannot be news. Demoted to a tile.

Added: total views with % change vs the previous 30 days — the one
number an operator actually checks, previously absent entirely while
"Media Files: 0" got a tile. `viewsWithPrevious()` reports the previous
window as `null` rather than 0 when there is no data, so a first-month
install shows "no comparison yet" instead of a meaningless +100%.

## Shared primitives, not one-off styling

Four components in `$lib/components/admin`, ported from the design
language redblu-siloscale / redblu-autoscale / khaopad-telemetry
already share (PageShell's own comment records what happens when 45
pages each style themselves: five padding scales, six max-widths):

  · MetricTile  — tone colours the NUMBER, never the tile. Both
                  upstream implementations carry this comment: a
                  tinted card makes every tile shout at one volume,
                  which is the same as no emphasis at all. `null`
                  renders `—` + "no data yet", never 0 — "nobody
                  visited" and "not measured" are different facts.
  · EmptyState  — DASHED border, a bold line naming what appears here,
                  one sentence on how to make it appear. The dashed
                  edge is load-bearing: a solid border is the same
                  affordance as a populated card, which is exactly the
                  confusion that made a fresh install look broken.
  · TrendChart  — 30-day area chart. Three gridlines, no axis spine,
                  no tick marks; first/middle/last date labels only
                  (more collide at phone width).
  · Sparkline   — 14-day bars per top article. Zero days draw a
                  hairline at the baseline so a gap in publishing stays
                  visible instead of collapsing to nothing.

All inline SVG, no new dependencies. The admin runs under
`script-src 'self'`; a CDN chart library is a new script origin, and
this codebase already paid for underestimating that policy when the
admin webfont was silently blocked for weeks. Every stroke and fill is
a semantic token, so light/dark needs no second set of markup.

A fresh install now shows one instruction and one action.

## Gates

  lint 0 errors · check 0 errors · test 1114/1114 (baseline, unchanged
  — every design-system pin still passes) · build ok · contract-guard ok

  css-inventory re-baselined. Six classes are no longer emitted, all
  from markup this commit deletes: `text-5xl` (+ `--text-5xl`,
  `--text-5xl--line-height`) was the giant published-count; and
  `lg:col-span-1`, `xl:grid-cols-5`, `md:grid-cols-4`,
  `2xl:grid-cols-3`, `2xl:grid-cols-8` were the six-tile counter row
  and the 8-column grids. No classes added.

Verified on `wrangler dev --port 4214 --local` in light and dark, with
content and on an emptied database; no console errors, no horizontal
overflow at 390px.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Admin dashboard: rebuild around act / context / reference, and cut the metrics that don't earn their place

1 participant