Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,8 @@ not shipped. Specs live in top-level `tests/`, never in `src/lib`.
level, `truncateValues` to cut values off instead of rounding, `marksPlaces` for `drawnAt`,
answers per point refreshed at the map's `idle`) and `shapesPlugin`
(fill/`outline`/check overlay, `hoverable`, `noFigure: "outline"` for a no-level feature's
unfilled `--foreground` edge, a `no-figure` line layer under `outline: "none"`), plus shared style expressions, scale resolution,
unfilled `--foreground` edge, a `no-figure` line layer under `outline: "none"`, and `noFigure` on
those polygons' items, by the legend's rule), plus shared style expressions, scale resolution,
and the exported marker shapes (`circle`, `square`, `triangle`, `withCrosshair`).
- **Presets** (`src/lib/presets/`): `monitorsPlugin` (`detail` passes through; `figureLabel`
replaces the tooltip's interval note and names a cluster's figure; the reading box gives screen
Expand Down Expand Up @@ -149,6 +150,8 @@ not shipped. Specs live in top-level `tests/`, never in `src/lib`.
MapTooltip, SelectionBar, ViewSummary, and MapControls (zoom buttons only; basemap switching is
`MapContext`, credits are the engine's). `controls.css` holds the focus ring and motion classes.
A `FeatureListItem` with `noReading` (the focus point) shows its name alone everywhere.
One with `noFigure` (no level) reads "No data" (`mapsdk_legend_no_figure`) in `levelText`,
`rowLabel` and `summaryText`, with an unfilled list swatch.
`feature-list.ts`'s `shownValue` is the one place a row's or tooltip's value text is made; it
hides a category reading's code, since the level label already says it.
- **Entries**: `.` (everything, reaches the map engine), `./data` and `./stores` (must not reach
Expand Down
20 changes: 19 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,10 @@ list's "No level") draws in choropleth mode: `"neutral"` (default) fills it in t
like the rest; `"outline"` draws no fill and a 1px `--foreground` edge, whatever `outline` is (with
`"none"`, a line layer for those features alone), so an empty region doesn't read as a figure. It
is still hovered, clicked and selected like the others. While any shows, the legend section ends
with a "No data" row: an outlined swatch with no fill. `regionsPlugin` passes `noFigure`,
with a "No data" row: an outlined swatch with no fill, and those features read "No data" where
"No level" would be: in the feature list (with the same unfilled swatch), the row's accessible
name ("Fresno, No data"), the tooltip and the view summary. A no-figure LineString keeps its level
line and "No level". `regionsPlugin` passes `noFigure`,
`fillOpacity` (default 0.6) and `outline` (default `"theme"`) through:

```ts
Expand Down Expand Up @@ -286,6 +289,8 @@ a theme change, but not when the card changes color through its own class or sty
charger") shown where "No level" would be: in the feature list (plain text, no swatch), the row's
accessible name ("Fresno Station, Level 2 charger"), and the tooltip. A feature with a level
always shows its level. A plugin of your own sets the same `detail` on its `FeatureListItem`s.
`noFigure: true` on a `FeatureListItem` (set by `shapesPlugin` under `noFigure: "outline"`) reads
"No data" there instead, ahead of a `detail`; a level still wins.

`truncateValues: true` on `pointsPlugin` cuts values off at the display precision instead of
rounding them (`truncate` on each `FeatureListItem`), in the list, its accessible names, and the
Expand Down Expand Up @@ -842,6 +847,19 @@ local sjvair.com stack at `http://localhost:8000`.

## Changes

### 0.1.0-beta.16

- **"No data" for no-figure regions:** under `noFigure: "outline"`, a feature drawn as a no-figure
outline reads "No data" (`mapsdk_legend_no_figure`) where it read "No level": in the feature
list, the row's accessible name ("Fresno, No data", not "Fresno, no reading"), the generic
tooltip and the view summary ("2 No data", before any "No level"). Its list swatch is unfilled,
like the Legend's. A level's label still wins, and lines keep "No level". `FeatureListItem` gains
an optional `noFigure`, which `shapesPlugin` sets. Under `noFigure: "neutral"` (the default),
nothing changes. No new message keys or tokens, and the exports are otherwise unchanged.
- The Legend's "No data" swatch takes its edge from `--swatch-outline-width` and
`--swatch-outline-color` (falling back to 1px `--foreground`, as before), like the list's
swatches.

### 0.1.0-beta.15

- **Regions with no figure:** `noFigure` on `shapesPlugin` (`"neutral"`, default, today's look, or
Expand Down
215 changes: 215 additions & 0 deletions docs/superpowers/plans/2026-11-15-no-figure-text.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,215 @@
# "No data" for no-figure regions: implementation plan

> **For agentic workers:** REQUIRED SUB-SKILL: Use superpowers:subagent-driven-development (recommended) or superpowers:executing-plans to implement this plan task-by-task. Steps use checkbox (`- [ ]`) syntax for tracking.

**Goal:** Under `noFigure: "outline"`, an outlined no-figure item reads "No data" (not "No level")
in the list row, its accessible name, the generic tooltip and the view summary, with the Legend's
unfilled swatch in the list.

**Architecture:** One new optional `FeatureListItem.noFigure` flag, set by `shapesPlugin` under
the same rule as its `legend()` "No data" row. The shared text helpers (`levelText`, `rowLabel`,
`summaryText`) read it, so the list and the tooltip agree.

**Tech Stack:** Svelte 5 runes, TypeScript, Vitest (unit, client, browser), axe-core.

**Spec:** `docs/superpowers/specs/2026-11-15-no-figure-text-design.md`

## Global Constraints

- No new message keys and no new tokens. The text is `mapsdk_legend_no_figure` ("No data").
- No change under `noFigure: "neutral"` or unset, or in plain mode.
- Lines (LineString, MultiLineString) never get `noFigure`.
- A level's label always wins over `noFigure`; `noReading` still omits.
- Every new test is shown to fail first with the code under test temporarily undone.
- Tabs, double quotes, no trailing commas. Run `npm run format`. `npm run test:bundle` before each
commit under `src/lib`.

## Review Focus

1. A `noFigure` item whose value has a level (a host plugin sets the flag carelessly): the level
label wins everywhere: list, name, tooltip and summary. Covered in Task 1.
2. A `noFigure` item with a `detail`: "No data" wins, as the spec orders it. Covered in Task 1.
3. A plugin mixing outlined polygons and lines in one summary: "N No data" and "N No level" both
appear, "No data" first. Covered in Task 1.
4. The scale changes so a region gains a level (data reload): the next `features()` drops the flag.
Covered in Task 2.
5. Dark theme: the unfilled swatch is still seen, because its outline is `--foreground`. Covered in
Task 3 by checking the computed outline colour against `--foreground`.

---

### Task 1: The flag and the shared text

**Files:**
- Modify: `src/lib/core/plugin.ts` (`FeatureListItem`, beside `detail`)
- Modify: `src/lib/ui/feature-list.ts` (`levelText`, `rowLabel`)
- Modify: `src/lib/ui/view-summary.ts` (`summaryText`)
- Test: `tests/unit/ui/feature-list.test.ts`, `tests/unit/ui/view-summary.test.ts`

**Interfaces:**
- Produces: `FeatureListItem.noFigure?: boolean`. The doc says: drawn as a no-figure outline
(`shapesPlugin`'s `noFigure: "outline"`), so its level place reads "No data". Ignored when the
item has a level. Default false.
- `levelText` keeps its signature and its kinds; a `noFigure` item gets `kind: "none"`.

- [ ] **Step 1: Write the failing tests**

In `feature-list.test.ts` (use its `item()` and `good`):
- `levelText reads No data for a noFigure item with no level`: `item(..., { level: NO_LEVEL,
noFigure: true })` → `{ kind: "none", text: "No data" }`.
- `levelText: a level wins over noFigure`: `{ level: good, noFigure: true }` → `{ kind: "level",
text: "Good" }`.
- `levelText: noFigure wins over detail`: `{ level: NO_LEVEL, noFigure: true, detail: "x" }` →
text "No data".
- `levelText: noReading still omits with noFigure` → kind `"omit"`.
- `rowLabel names a no-value noFigure item "Fresno, No data"`: `{ value: null, level: NO_LEVEL,
noFigure: true, name: "Fresno" }` → `"Fresno, No data"`.
- `rowLabel puts No data after a value`: `{ value: 5, units: "µg/m³", precision: 0, level:
NO_LEVEL, noFigure: true }` → `"Fresno, 5 µg/m³, No data"`.
- `rowLabel without noFigure is unchanged`: the same no-value item without the flag is
`"Fresno, no reading"`.

In `view-summary.test.ts`:
- `counts noFigure items as No data, before No level`: items Good, NO_LEVEL+noFigure ×2,
NO_LEVEL ×1 → `"Counties: 1 Good, 2 No data, 1 No level"` (use the file's scale fixture and
the level label it uses).
- `a noFigure item with a level counts under its level`.

- [ ] **Step 2: Run them and see them fail**

Run: `npx vitest run --project unit tests/unit/ui/feature-list.test.ts tests/unit/ui/view-summary.test.ts`
Expected: the new tests FAIL (text "No level", "no reading", no "No data" part); type errors on
`noFigure` until Step 3's field exists.

- [ ] **Step 3: Implement**

Add the field. In `levelText`, after the level check and before `detail`: `if (item.noFigure)
return { kind: "none", text: messages("mapsdk_legend_no_figure") }`. Update its doc comment. In
`rowLabel`'s no-value branch, use `mapsdk_list_row_level` with `level.text` also when
`item.noFigure` and `level.kind === "none"`. In `summaryText`, count unlevelled `noFigure` items
separately; push `"N No data"` (`mapsdk_legend_no_figure`) before `"N No level"`. Update its doc
comment.

- [ ] **Step 4: Run them and see them pass, then prove they bite**

Run the Step 2 command; expect PASS. Temporarily remove the `levelText` line, then the
`summaryText` count, and check the matching tests fail. Restore.

- [ ] **Step 5: Commit**

`git commit -m "List text: a noFigure item reads No data in its level place, name and the summary"`

### Task 2: shapesPlugin sets the flag

**Files:**
- Modify: `src/lib/plugins/shapes.svelte.ts` (`features()`; share the rule with `legend()`)
- Test: `tests/client/plugins/shapes.test.ts` (`describe("shapesPlugin noFigure")`)

**Interfaces:**
- Consumes: `FeatureListItem.noFigure` (Task 1).
- Produces: a module-local predicate `drawnAsNoFigure(feature, scale): boolean` (no line geometry
and `levelFor(value, scale) === NO_LEVEL`), used by both `legend()` and `features()`, so the two
can't drift.

- [ ] **Step 1: Write the failing tests** (in the noFigure describe, using `POLYGONS`,
`WITH_LEVELS` and the line collection from the "lines out of the No data flag" test)
- `features() flags outlined polygons with no level`: `noFigure: "outline"`, POLYGONS → Alpha's
item has `noFigure: true`, and Bravo's item has no `noFigure` key.
- `features() never flags lines`: the mixed collection → the Line item has no `noFigure`.
- `features() flags nothing under neutral, unset or plain mode`: loop `undefined`, `"neutral"`,
and `mode: "plain"` with `"outline"` → no item has `noFigure`.
- `features() flags nothing while the scale is unresolved`: a source with no scale resolved
yet (follow the file's pattern for a pending scale) → no `noFigure`.
- `features() drops the flag once the feature has a level`: set `source.features = WITH_LEVELS`,
`flushSync()` → no `noFigure`.

- [ ] **Step 2: Run them and see them fail**

Run: `npx vitest run --project client tests/client/plugins/shapes.test.ts`
Expected: the first test FAILS (`noFigure` undefined). The others may pass now. They guard against
the flag being set too widely, so check them again in Step 4.

- [ ] **Step 3: Implement**

Extract `drawnAsNoFigure` and use it in `legend()`. In `features()`, spread
`...(outlineNoFigure && scale && drawnAsNoFigure(feature, scale) && { noFigure: true })`.

- [ ] **Step 4: Run them and see them pass, then prove they bite**

Run the Step 2 command; expect PASS. Temporarily drop the line check from `drawnAsNoFigure`, and
then the `outlineNoFigure` guard. Check that "never flags lines" and "flags nothing under neutral"
fail. Restore.

- [ ] **Step 5: Commit**

`git commit -m "Shapes: outlined no-figure items carry noFigure, by the legend's rule"`

### Task 3: The list swatch, and the list and tooltip in the browser

**Files:**
- Modify: `src/lib/ui/FeatureList.svelte` (swatch class `nofigure`; style beside
`.mapsdk-list-swatch.neutral`)
- Test: `tests/browser/feature-list.browser.test.ts`, `tests/browser/tooltip.browser.test.ts`

**Interfaces:**
- Consumes: `FeatureListItem.noFigure` and `levelText` (Task 1).

- [ ] **Step 1: Write the failing tests**

In `feature-list.browser.test.ts` (its `item()`/`listed()`/`newMap()`):
- `a noFigure row reads No data with an unfilled swatch`: one item `{ value: null, level:
NO_LEVEL, noFigure: true, name: "Fresno" }` → the option's accessible name is `"Fresno, No
data"`, the row's text contains "No data" and not "No level", and its
`.mapsdk-list-swatch` has computed `background-color` `rgba(0, 0, 0, 0)` and an outline colour
equal to the resolved `--foreground`.
- `a noFigure row has no axe violations`: `axe.run(document.querySelector(".mapsdk-list")!)` →
no violations.

In `tooltip.browser.test.ts`, next to `shows No level for NO_LEVEL` (same setup):
- `shows No data for a noFigure item`: tooltip text `"Gray 12.34 µg/m³ No data"`. Also run axe on
the tooltip and expect no violations.

- [ ] **Step 2: Run them and see them fail**

Run: `npx vitest run --project browser tests/browser/feature-list.browser.test.ts tests/browser/tooltip.browser.test.ts`
Expected: the swatch test FAILS (muted background). The text assertions pass already through
Task 1. Prove they bite by temporarily undoing Task 1's `levelText` line, then restore.

- [ ] **Step 3: Implement**

`class:nofigure={row.noFigure && !level}` on the swatch. `.mapsdk-list-swatch.nofigure {
background: transparent; }` after the `.neutral` rule.

- [ ] **Step 4: Run them and see them pass**

Run the Step 2 command, then `taskset -c 0,1 npx vitest run --project browser` three times.
Expected: PASS each time.

- [ ] **Step 5: Commit**

`git commit -m "List: an outlined no-figure row shows the Legend's unfilled swatch"`

### Task 4: Version, docs, and the full check

**Files:**
- Modify: `package.json` and `package-lock.json` (`0.1.0-beta.16`, via `npm version
0.1.0-beta.16 --no-git-tag-version`)
- Modify: `README.md` ("Plugins and draw order" `noFigure` paragraph near line 220; the
`FeatureListItem` `detail` paragraph near line 288; a new "### 0.1.0-beta.16" under "Changes")
- Modify: `CLAUDE.md` (Plugins: `shapesPlugin` sets `noFigure` on outlined items; UI:
`levelText`/`summaryText` read "No data" for them)
- Test: `tests/unit/readme-examples.test.ts` only if an example changes (none expected)

- [ ] **Step 1: Write the docs.** The Changes entry describes this change from map-sdk's side
only: under `noFigure: "outline"`, outlined no-figure items read "No data" in the list, row
names, generic tooltip and view summary, with an unfilled list swatch; the new
`FeatureListItem.noFigure`; no change under `"neutral"`; exports otherwise unchanged; no new
keys or tokens.
- [ ] **Step 2: Run the full check**

Run: `npm run format && npm run lint && npm run check && npm test && npm run test:bundle && npm run test:licenses && npx playwright test --project chromium --project firefox`
Expected: all pass.

- [ ] **Step 3: Commit**

`git commit -m "0.1.0-beta.16: README, CLAUDE.md and version"`
72 changes: 72 additions & 0 deletions docs/superpowers/specs/2026-11-15-no-figure-text-design.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
# "No data" for no-figure regions in the list, tooltip and summary

Date: 2026-11-15. Ships as `@sjvair/map-sdk` `0.1.0-beta.16`.

## Why

`0.1.0-beta.15` draws a region with no figure as an unfilled outline under `noFigure: "outline"`,
and the Legend labels it "No data" (`mapsdk_legend_no_figure`). The feature list, the generic
tooltip and the view summary still say "No level" for the same region, because nothing on its
`FeatureListItem` says it is drawn as a no-figure outline. The dashboard works around it by
wrapping `regionsPlugin`'s `features()`.

## Goals, non-goals, anti-goals

- Goals: wherever an outlined no-figure item says "No level" today, it says "No data". The list row
shows the Legend's unfilled swatch.
- Non-goals: a plugin option, a host-set text, new message keys or tokens, and the preset tooltips
(monitor, cluster, collocation, fire), which list no shapes.
- Anti-goals: any change for a caller that leaves `noFigure` at `"neutral"` (monitor-map 5.0, every
current caller). Meaning by colour alone.

## Decisions (the user's, 2026-11-15)

- **Option B:** no new plugin option. The "No data" text follows from `noFigure: "outline"`.
- **Mechanism:** a new optional field on the exported `FeatureListItem`,
`noFigure?: boolean`. It means "drawn as a no-figure outline" and is ignored when the item has a
level. `shapesPlugin` sets it; a host's own plugin may set it too. (Rejected: filling `detail`,
which needs messages in `features()`, turns the row into a detail row, and collides with a
host's wrapper.)
- **Which items:** the features the map draws as no-figure outlines: choropleth,
`noFigure: "outline"`, a scale the layers are built with, a geometry that isn't a LineString or
MultiLineString, and no level for its value. It's the same predicate (`drawnAsNoFigure`) as
`legend()`'s "No data" row. Lines keep "No level". A source with no scale (`scale: null`) draws
every polygon as an outline, so every polygon gets "No data", though the legend has no section
then (the user's choice after review, 2026-11-15). While the scale is unavailable nothing is
drawn and nothing is flagged.
- **Accessible name:** an outlined row with no value is "Fresno, No data"
(`mapsdk_list_row_level`), not "Fresno, no reading". With a value, it's
"Fresno, 5 µg/m³, No data".
- **View summary:** outlined items are counted as "N No data", after the levels. Items with no
level that aren't outlined are counted as "N No level", after that.
- **Swatch:** the list row's swatch for an outlined item is unfilled (transparent, its usual
`--foreground` outline), like the Legend's "No data" swatch. Same dot shape and size as the
other rows.

## Design

- `FeatureListItem.noFigure?: boolean` in `core/plugin.ts`, documented beside `detail`.
- `levelText` (`ui/feature-list.ts`): order level → `noFigure` → `detail` → "No level".
`noFigure` returns `{ kind: "none", text: messages("mapsdk_legend_no_figure") }`. A level still
wins, and `noReading` still omits.
`noFigure` comes before `detail` because a no-figure outline is what the map shows. `shapesPlugin`
never sets both.
- `rowLabel`: a no-value item with `noFigure` (and no level) uses `mapsdk_list_row_level` with the
"No data" text.
- `TooltipItem` needs no change: it renders `levelText` in the neutral chip, so it reads "No data".
- `summaryText` (`ui/view-summary.ts`): a separate count of `noFigure` items without a shown level,
labelled `mapsdk_legend_no_figure`.
- `FeatureList.svelte`: the swatch gets class `nofigure` (transparent background) when the item
has `noFigure` and no shown level.
- `shapesPlugin.features()` sets `noFigure: true` on the items the rule above covers, and omits
the key otherwise.

## Testing

- Unit tests for `levelText`, `rowLabel` and `summaryText`, with and without `noFigure`, including
that a level's label wins.
- Client tests for `shapesPlugin.features()`: outlined polygons get `noFigure`; lines, items with a
level, `"neutral"`/unset, plain mode and an unresolved scale don't.
- Browser tests: the list row text, its accessible name and its unfilled swatch; the tooltip text;
axe on both.
- Each new test is first shown to fail with the code under test undone.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading