Skip to content

Commit 3802323

Browse files
committed
www/map: Hex/Circle toggle in the hexbin drawer
Adds a two-button `Hex | Circle` toggle at the top of the hexbin controls block (right below the Points/Heatmap/Hexbin mode row). Backs the existing `?viz=` URL param; clicking either button persists in the URL (or clears it back to default `hex`). Prototype circle mode was previously URL-only (`?viz=circle`), which required editing the URL by hand. Now discoverable + one-click while tuning task #121.
1 parent e15c0a5 commit 3802323

1 file changed

Lines changed: 21 additions & 1 deletion

File tree

www/src/map/CrashMapSection.tsx

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,9 @@ export function CrashMapSection({
201201
// smooth `target_px(z)` curve, capped at each cell's inscribed
202202
// circle, so res transitions don't visually pop and we get
203203
// density-scaled dots (small at wide zoom, chunkier deep-zoom).
204-
const [viz] = useUrlState("viz", enumParam("hex" as const, ["hex", "circle"] as const))
204+
const [viz, setVizUrl] = useUrlState("viz", enumParam("hex" as const, ["hex", "circle"] as const))
205+
// Keep URL absent when on default (hex) so URLs stay tidy.
206+
const setViz = (v: "hex" | "circle") => setVizUrl(v === "hex" ? "hex" : v)
205207
// `hexAuto` — when true (default), hexPxTarget grows with zoom so
206208
// close-up views get chunkier, more-pickable cells; when false, the
207209
// manual slider value wins. `?ha=false` to opt out of adaptive.
@@ -795,6 +797,24 @@ export function CrashMapSection({
795797
</div>
796798
{mode === "hexbin" && (
797799
<>
800+
<div style={{ display: "flex", gap: 4, marginBottom: 4 }}>
801+
{(["hex", "circle"] as const).map(v => (
802+
<button
803+
key={v}
804+
onClick={() => setViz(v)}
805+
style={{
806+
cursor: "pointer",
807+
background: viz === v ? activeBg : "transparent",
808+
color: viz === v ? "#fff" : fg,
809+
border: `1px solid ${viz === v ? activeBg : fg}`,
810+
borderRadius: 3,
811+
padding: "2px 8px",
812+
fontSize: "0.78em",
813+
flex: 1,
814+
}}
815+
>{v === "hex" ? "Hex" : "Circle"}</button>
816+
))}
817+
</div>
798818
<HexPxTargetSlider
799819
value={hexPxTarget}
800820
onChange={setHexPxTarget}

0 commit comments

Comments
 (0)