-
Notifications
You must be signed in to change notification settings - Fork 0
Replace blocky region graphic with clean world map base and interactive anchors #173
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,79 @@ | ||
| import worldMapCleanAsset from "../assets/world-map-clean.svg"; | ||
| import "../styles/region-world-map.css"; | ||
|
|
||
| export type RegionKey = | ||
| | "us-east-1" | ||
| | "us-west-2" | ||
| | "eu-west-1" | ||
| | "eu-central-1" | ||
| | "ap-southeast-1" | ||
| | "local"; | ||
|
|
||
| type RegionAnchor = { | ||
| x: number; | ||
| y: number; | ||
| label: string; | ||
| }; | ||
|
|
||
| const REGION_ANCHORS: Record<RegionKey, RegionAnchor> = { | ||
| "us-east-1": { x: 28, y: 36, label: "US East" }, | ||
| "us-west-2": { x: 18, y: 35, label: "US West" }, | ||
| "eu-west-1": { x: 47, y: 31, label: "EU West" }, | ||
| "eu-central-1": { x: 52, y: 30, label: "EU Central" }, | ||
| "ap-southeast-1": { x: 77, y: 56, label: "AP Southeast" }, | ||
| local: { x: 50, y: 84, label: "Local / Unassigned" }, | ||
| }; | ||
|
|
||
| export type RegionWorldMapProps = { | ||
| selectedRegion?: RegionKey | null; | ||
| highlightedRegion?: RegionKey | null; | ||
| onRegionSelect?: (region: RegionKey) => void; | ||
| showLocalAnchor?: boolean; | ||
| className?: string; | ||
| }; | ||
|
|
||
| export function RegionWorldMap({ | ||
| selectedRegion, | ||
| highlightedRegion, | ||
| onRegionSelect, | ||
| showLocalAnchor = true, | ||
| className, | ||
| }: RegionWorldMapProps) { | ||
| const keys = (Object.keys(REGION_ANCHORS) as RegionKey[]).filter((key) => showLocalAnchor || key !== "local"); | ||
|
|
||
| return ( | ||
| <div className={["region-world-map", className].filter(Boolean).join(" ")}> | ||
| <img src={worldMapCleanAsset} alt="World map" className="region-world-map__asset" draggable={false} /> | ||
| <svg viewBox="0 0 100 100" className="region-world-map__overlay" aria-hidden="true"> | ||
| {keys.map((key) => { | ||
| const anchor = REGION_ANCHORS[key]; | ||
| const selected = selectedRegion === key; | ||
| const highlighted = highlightedRegion === key; | ||
| return ( | ||
| <g | ||
| key={key} | ||
| className="region-world-map__dot-group" | ||
| style={{ transform: `translate(${anchor.x}px, ${anchor.y}px)` }} | ||
| onClick={() => onRegionSelect?.(key)} | ||
| > | ||
| <circle | ||
| className="region-world-map__dot-pulse" | ||
| r={selected || highlighted ? 2.5 : 1.8} | ||
| opacity={selected || highlighted ? 0.35 : 0.16} | ||
| /> | ||
| <circle | ||
| className="region-world-map__dot-core" | ||
| r={selected ? 1.25 : highlighted ? 1.15 : 1} | ||
| data-selected={selected ? "true" : "false"} | ||
| data-highlighted={highlighted ? "true" : "false"} | ||
| /> | ||
| <title>{anchor.label}</title> | ||
| </g> | ||
| ); | ||
| })} | ||
| </svg> | ||
| </div> | ||
| ); | ||
| } | ||
|
|
||
| export { REGION_ANCHORS }; | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,67 @@ | ||
| .region-world-map { | ||
| position: relative; | ||
| width: 100%; | ||
| max-width: 760px; | ||
| margin: 0 auto; | ||
| border-radius: 14px; | ||
| overflow: hidden; | ||
| background: var(--map-bg, color-mix(in oklab, var(--surface, #0f172a) 84%, #0b1220)); | ||
| border: 1px solid var(--map-border, color-mix(in oklab, var(--text, #cbd5e1) 18%, transparent)); | ||
| } | ||
|
|
||
| .region-world-map__asset { | ||
| display: block; | ||
| width: 100%; | ||
| height: auto; | ||
| opacity: 0.95; | ||
| filter: saturate(0.9) contrast(0.95); | ||
| } | ||
|
|
||
| .region-world-map__overlay { | ||
| position: absolute; | ||
| inset: 0; | ||
| width: 100%; | ||
| height: 100%; | ||
| } | ||
|
|
||
| .region-world-map__dot-group { | ||
| cursor: pointer; | ||
| } | ||
|
|
||
| .region-world-map__dot-pulse { | ||
| fill: var(--map-accent-soft, color-mix(in oklab, var(--accent, #38bdf8) 35%, transparent)); | ||
| } | ||
|
|
||
| .region-world-map__dot-core { | ||
| fill: var(--map-accent, var(--accent, #38bdf8)); | ||
| stroke: var(--map-dot-stroke, rgba(255, 255, 255, 0.9)); | ||
| stroke-width: 0.25; | ||
| transition: transform 120ms ease, fill 120ms ease, opacity 120ms ease; | ||
| transform-origin: center; | ||
| } | ||
|
|
||
| .region-world-map__dot-core[data-highlighted="true"] { | ||
| fill: var(--map-accent-highlight, #22d3ee); | ||
| } | ||
|
|
||
| .region-world-map__dot-core[data-selected="true"] { | ||
| fill: var(--map-accent-selected, #0ea5e9); | ||
| } | ||
|
|
||
| .region-world-map__dot-group:hover .region-world-map__dot-core { | ||
| transform: scale(1.08); | ||
| } | ||
|
|
||
| :root[data-theme="light"] .region-world-map, | ||
| :root[data-theme="altius-light"] .region-world-map { | ||
| --map-bg: color-mix(in oklab, #ffffff 92%, #dbeafe); | ||
| --map-border: color-mix(in oklab, #0f172a 10%, transparent); | ||
| --map-dot-stroke: rgba(15, 23, 42, 0.25); | ||
| } | ||
|
|
||
| :root[data-theme="altius"], | ||
| :root[data-theme="dark"] { | ||
| --map-bg: color-mix(in oklab, #111827 88%, #020617); | ||
| --map-border: color-mix(in oklab, #cbd5e1 14%, transparent); | ||
| --map-dot-stroke: rgba(241, 245, 249, 0.72); | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The interactive overlay is rendered with
viewBox="0 0 100 100", but the base map asset is a wide1000x460canvas; with SVG’s defaultpreserveAspectRatio="xMidYMid meet", the overlay content is fit into a centered square region rather than the full map area. This causes the region anchor dots/hit targets to be positioned incorrectly relative to the continents in normal dashboard layouts. Match the overlay viewBox to the map aspect ratio (or explicitly set preserveAspectRatio behavior) so click targets align with the map.Useful? React with 👍 / 👎.