From 7ca135e6feaf66655c6c5d025e0f77dc0913b15f Mon Sep 17 00:00:00 2001 From: Isaac Brodsky Date: Mon, 29 Jun 2026 18:54:53 -0700 Subject: [PATCH 1/7] website: reenable navigation with style adjustment and preview --- website/src/components/explorer/details.jsx | 79 +++++++++++++++++---- website/src/components/explorer/index.tsx | 11 ++- website/src/components/explorer/map.jsx | 56 +++++++++++++-- website/src/components/styled.js | 9 ++- 4 files changed, 130 insertions(+), 25 deletions(-) diff --git a/website/src/components/explorer/details.jsx b/website/src/components/explorer/details.jsx index ea43688569..a05ff4bb83 100644 --- a/website/src/components/explorer/details.jsx +++ b/website/src/components/explorer/details.jsx @@ -1,6 +1,6 @@ // Contains code adapted from https://observablehq.com/@nrabinowitz/h3-index-inspector under the ISC license -import React, { useCallback } from "react"; +import React, { useCallback, useEffect } from "react"; import { cellToBoundary, cellToParent, @@ -62,27 +62,68 @@ function cellUnits(hex) { : { area: UNITS.m2, dist: UNITS.m }; } -function ClickableH3Index({ hex, setUserInput }) { +function ClickableH3Index({ hex, setUserInput, onHoverCells }) { const onClick = useCallback(() => { setUserInput(hex); - }, [hex, setUserInput]); + if (onHoverCells) { + onHoverCells([]); + } + }, [hex, setUserInput, onHoverCells]); + + const onMouseEnter = useCallback(() => { + if (onHoverCells) { + onHoverCells([hex]); + } + }, [onHoverCells]); + const onMouseLeave = useCallback(() => { + if (onHoverCells) { + onHoverCells([]); + } + }, [onHoverCells]); return ( - + {hex} ); } -function ClickableH3IndexList({ hexes, setUserInput, showAll = true }) { +function ClickableH3IndexList({ + hexes, + setUserInput, + showAll = true, + onHoverCells, +}) { const onShowAllClick = useCallback(() => { setUserInput(hexes.join(", ")); }, [hexes, setUserInput]); + + const showAllOnMouseEnter = useCallback(() => { + if (onHoverCells) { + onHoverCells(hexes); + } + }, [onHoverCells]); + const showAllOnMouseLeave = useCallback(() => { + if (onHoverCells) { + onHoverCells([]); + } + }, [onHoverCells]); + return ( <> {hexes.map((hex, index) => { const link = ( - + ); if (index === 0) { return link; @@ -93,7 +134,12 @@ function ClickableH3IndexList({ hexes, setUserInput, showAll = true }) { {showAll ? ( <>   - + (show all) @@ -110,6 +156,7 @@ export function SelectedHexDetails({ splitUserInput, showNavigation = true, showDetails = true, + onHoverCells, }) { if (splitUserInput.length === 1) { const hex = splitUserInput[0]; @@ -141,7 +188,6 @@ export function SelectedHexDetails({ return (

- Lat./Lng.: {coords} {showCellId ? ( <>
@@ -149,11 +195,15 @@ export function SelectedHexDetails({ ) : null} {showNavigation ? ( - <> -
+

+ Relations Parent:{" "} {parent ? ( - + ) : ( (none) )} @@ -163,6 +213,7 @@ export function SelectedHexDetails({ ) : ( (none) @@ -172,15 +223,18 @@ export function SelectedHexDetails({
- +
) : ( <> )} {showDetails ? (
Details + Lat./Lng.: {coords} +
Resolution: {res}
Base cell: {baseCell} @@ -208,6 +262,7 @@ export function SelectedHexDetails({ hexes={splitUserInput} setUserInput={setUserInput} showAll={false} + onHoverCells={onHoverCells} />

); diff --git a/website/src/components/explorer/index.tsx b/website/src/components/explorer/index.tsx index 49c75d04c8..a0fb377a20 100644 --- a/website/src/components/explorer/index.tsx +++ b/website/src/components/explorer/index.tsx @@ -1,6 +1,6 @@ // Contains code adapted from https://observablehq.com/@nrabinowitz/h3-index-inspector under the ISC license -import React, { useCallback, useMemo, ReactNode } from "react"; +import React, { useCallback, useMemo, ReactNode, useState } from "react"; import { isValidCell, latLngToCell, getResolution } from "h3-js"; import { Banner, @@ -15,6 +15,7 @@ import { WhereAmIButton } from "./where-am-i"; import geojson2h3 from "geojson2h3"; import wkt from "wkt"; import { Feature, MultiPolygon, Polygon } from "geojson"; +import { useColorMode } from "@docusaurus/theme-common"; const CELL_COUNT_THRESHOLD = 50; const CELL_COUNT_UPPER_THRESHOLD = 5000; @@ -217,6 +218,8 @@ function zoomToResolution(zoom: number) { export default function HomeExporer({ children }: { children: ReactNode }) { const [userInput, setUserInput] = useQueryState("hex", ""); const [userResolution, setUserResolution] = useQueryState("res", -1); + const [previewCells, setPreviewCells] = useState([]); + const { colorMode } = useColorMode(); const { splitUserInput, showCellId, inputGeoJson, showResolutionInput } = useMemo( @@ -285,10 +288,11 @@ export default function HomeExporer({ children }: { children: ReactNode }) { userValidHex={userValidHex} objectOnClick={objectOnClick} coordinateOnClick={coordinateOnClick} + previewCells={previewCells} /> - +