Skip to content

Widget lab + heatmap layout fix - #37

Merged
Makisuo merged 2 commits into
mainfrom
claude/infallible-margulis-ea68b1
May 12, 2026
Merged

Makisuo merged 2 commits into
mainfrom
claude/infallible-margulis-ea68b1

Conversation

@Makisuo

@Makisuo Makisuo commented May 12, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

  • Adds /widget-lab — an internal page that renders every custom-dashboard widget (stat, chart, table, list, pie, histogram, heatmap, markdown) against hand-crafted fixtures covering ready / loading / error (runtime + decode) / empty / edge-case data. No live queries — fixtures are pure data so we can polish layout, thresholds, and error UX without touching Tinybird or time ranges.
  • Rewrites the heatmap chart layout math so cells fill the card instead of hugging the top-left at MAX_CELL=36. Includes a new stride-based x-tick picker that guarantees no label overlap.

Heatmap before → after

Before: cells capped at 36px sat in the top-left of the card, Y label "100-300ms" truncated to "100-30…", and 5 x-ticks picked across 8 values collapsed into [0, 2, 4, 5, 7] so labels collided as "006:128:…".

After: cells expand independently in W and H (max 96 wide / 64 tall), Y-label width is content-derived (clamp 36–96px), grid centers horizontally when capped, and a stride-based picker guarantees adjacent x-labels can't overlap. Legend bar spans the full grid width; hover desaturates non-hovered cells.

Verified across all 8 widget-lab heatmap scenarios (5 OKLCH color scales + sparse + log + loading/empty).

Test plan

  • Visit `/widget-lab` and scan each section (Stat, Chart, Table, List, Pie, Histogram, Heatmap, Markdown) — every card renders without overflow, loading/error/empty states all look correct.
  • Heatmap section specifically: confirm cells fill the card width, all 5 color scales render, sparse data shows missing cells as transparent, log scale shows a geometric midpoint legend tick.
  • Toggle the View ↔ Edit switch in the page header — every widget card grows a drag handle + dropdown with Edit/Clone/Delete actions in edit mode.
  • Existing dashboards that use the heatmap widget still render correctly (the chart component is shared).

🤖 Generated with Claude Code


View in Codesmith
Need help on this PR? Tag @codesmith with what you need.

  • Let Codesmith autofix CI failures and bot reviews

Adds an internal `/widget-lab` route that renders every custom-dashboard
widget against hand-crafted fixtures (loading, error, empty, threshold,
edge-case data) so we can polish layout, typography, and error UX
without standing up a real dashboard.

Reworks the heatmap chart layout math so cells fill the card instead of
hugging the top-left:

- Separate cellW/cellH budgets (was one square cellSize) — cells expand
  independently in each axis. Max raised from 36 to 96 wide / 64 tall.
- Y-label width is content-derived (clamp 36-96) so 100-200ms no longer
  gets truncated to 56px.
- New stride-based pickXTicks guarantees adjacent x-labels can't overlap
  (replacing pickEvenTicks which produced clumps like [0,2,4,5,7]).
- Grid centers horizontally when cell width is capped.
- Legend bar spans full grid width with a hairline outline.
- Hover desaturates non-hovered cells; hover ring is 2-layer for depth.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@pullfrog

pullfrog Bot commented May 12, 2026 •

Copy link
Copy Markdown
Contributor

This run croaked 😵

The workflow encountered an error before any progress could be reported. Please check the link below for details.

Pullfrog  | Rerun failed job ➔ | View workflow run | via Pullfrog | 𝕏

Adds a tiny `gen:types` script that writes apps/mobile/uniwind-types.d.ts
with the same content uniwind's metro transformer writes at `expo start`.
The d.ts is gitignored (uniwind regenerates it on every metro start), but
tsc needs it to exist before it runs — otherwise every `<View className=…>`
in apps/mobile is a TS2769 error.

Wires the script into `bun typecheck` as a prerun step so both local and
turbo CI runs materialise it.

Also rewrites the pie/donut chart (packages/ui/.../query-builder-pie-chart)
as a custom SVG implementation, replacing Recharts. The Recharts version
let the side legend eat ~50% of the card width, then computed
outerRadius=80% of whatever scraps were left — pies with 8+ slices
rendered as a dot or not at all.

New implementation:
- Container measured via ResizeObserver; pie diameter = min(W, H-legendH)
- Bottom legend, flex-wraps, capped at 2 rows with overflow hidden
- Donut centre shows the total (only when inner radius >= 18px)
- In-slice labels for slices >= 6%, white text with paint-order stroke
- Slice hover: scale 1.035 + others fade to 55% opacity
- Soft drop shadow under the pie via feGaussianBlur

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@Makisuo
Makisuo merged commit 27c7d86 into main May 12, 2026
3 checks passed

This branch was previously deployed

1 inactive deployment
pr-preview — 319dff2e Deployed May 12, 2026 by Makisuo via deploy-pr-preview #116
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.

1 participant