refactor(statistics-deck): consolidate the period views' shared helpers into the shell #156

Open
opened 2026-09-27 10:02:13 +00:00 by gabogg · 0 comments
Owner

The Day, Week and Month views (#134–#136; PRs #149, #148, #147) were built in parallel. On purpose, each keeps its shared-looking helpers local until all three are merged. This issue consolidates them into the shell.

Scope

  • View kit module (e.g. statistics_deck/views/kit.js), extracted from the three view files:
    • KPI tile rendering;
    • comparison text ("—" plus reason, basis/DAILY_AVERAGE tag);
    • number, percent and count formatting via ctx.locale (memoised Intl.NumberFormat);
    • the entrance-share graph and list;
    • the tier→glyph/style maps;
    • per-cell error/loading states.
  • One set of statisticsDeck.comparison.reason.* texts. The views arrived with three different wordings; the Month wording is canonical, applied at merge.
  • withData scope. Document it as whole counts only, and add a helper that renders one <data value={raw}>formatted</data> for formatted figures (decimals, thousands separators, percentages). This came from the #149 second-pass review, S2-1. Week's numberParts folds into it.
  • deckChartOptions: deep-merge scales.*.ticks, so views stop re-spreading defaults (#149 S2-3).
  • Shared hatch. One hatch custom property/class used by the CSS swatches and the view CSS; no literal rgba() anywhere.

Acceptance

  • No behaviour change. All three views' frontend tests keep passing, adjusted only for imports.
  • The duplicated helpers are gone from the view files.
The Day, Week and Month views (#134–#136; PRs #149, #148, #147) were built in parallel. On purpose, each keeps its shared-looking helpers local until all three are merged. This issue consolidates them into the shell. ## Scope - [ ] **View kit module** (e.g. `statistics_deck/views/kit.js`), extracted from the three view files: - KPI tile rendering; - comparison text ("—" plus reason, basis/`DAILY_AVERAGE` tag); - number, percent and count formatting via `ctx.locale` (memoised `Intl.NumberFormat`); - the entrance-share graph and list; - the tier→glyph/style maps; - per-cell error/loading states. - [ ] **One set of `statisticsDeck.comparison.reason.*` texts.** The views arrived with three different wordings; the Month wording is canonical, applied at merge. - [ ] **`withData` scope.** Document it as whole counts only, and add a helper that renders one `<data value={raw}>formatted</data>` for formatted figures (decimals, thousands separators, percentages). This came from the #149 second-pass review, S2-1. Week's `numberParts` folds into it. - [ ] **`deckChartOptions`**: deep-merge `scales.*.ticks`, so views stop re-spreading defaults (#149 S2-3). - [ ] **Shared hatch.** One hatch custom property/class used by the CSS swatches and the view CSS; no literal `rgba()` anywhere. ## Acceptance - No behaviour change. All three views' frontend tests keep passing, adjusted only for imports. - The duplicated helpers are gone from the view files.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
gabogg/hikcentral#156
No description provided.