From a76dee7e2ae46b42f3dc6d91009fc5d65ff7764a Mon Sep 17 00:00:00 2001 From: Jonghyeon Ko Date: Mon, 23 Nov 2026 02:28:27 +0900 Subject: [PATCH 1/2] Anchor maintainer profiles to their globe markers --- src/components/MaintainersMap.tsx | 227 +++++++++---------- src/components/home/HomeCommunitySection.tsx | 20 +- 2 files changed, 125 insertions(+), 122 deletions(-) diff --git a/src/components/MaintainersMap.tsx b/src/components/MaintainersMap.tsx index 6a179e495..6b0307e04 100644 --- a/src/components/MaintainersMap.tsx +++ b/src/components/MaintainersMap.tsx @@ -7,6 +7,7 @@ import { useRef, useState, } from 'react' +import { Popover } from '@base-ui/react/popover' import { ClientOnly } from '@tanstack/react-router' import { useSuspenseQuery } from '@tanstack/react-query' import { geoDistance, select, zoom, zoomIdentity, type D3ZoomEvent } from 'd3' @@ -61,8 +62,6 @@ type ProfileViewport = { bottom: number contentTop: number contentBottom: number - helpTop: number - helpBottom: number } type ProfileSize = { width: number; height: number } @@ -232,12 +231,6 @@ function placeProfiles( top: bounds.height - zoomControls.height, bottom: bounds.height, }, - { - left: bounds.contentInset, - right: contentRight, - top: viewport.helpTop, - bottom: viewport.helpBottom, - }, ] const labels = nodes.flatMap( ({ id, card, line, pin, sizes, pendingImages }) => { @@ -639,10 +632,6 @@ type MaintainersMapProps = { maintainers: Maintainer[] } -function Key({ children }: { children: React.ReactNode }) { - return {children} -} - function GlobeAvatar({ member, color, @@ -687,13 +676,14 @@ export function MaintainersMap({ maintainers }: MaintainersMapProps) { > | null>(null) const [reducedMotion, setReducedMotion] = useState(false) const [scale, setScale] = useState(initialView.scale) - const [selectedId, setSelectedId] = useState('') + const [profilePopover] = useState(() => Popover.createHandle()) const [paused, setPaused] = useState(false) const [behavior] = useState(() => zoom()) const [profilePositions] = useState( (): Map => new Map(), ) const profileNodes = useRef>(undefined) + const openProfileTrigger = useRef(undefined) const [startingView] = useState(() => initialMaintainersView(initialLocation)) const view = useRef({ ...startingView }) const target = useRef({ ...startingView }) @@ -762,7 +752,6 @@ export function MaintainersMap({ maintainers }: MaintainersMapProps) { } return result }, [maintainers, prefix, scale]) - const selected = groups.find((group) => group.id === selectedId) // Read by the frame loop, so zooming doesn't restart it. const groupsRef = useRef(groups) @@ -850,7 +839,6 @@ export function MaintainersMap({ maintainers }: MaintainersMapProps) { const instance = globe const canvasSurface = surface const section = container.closest('section') - const help = section?.querySelector('#maintainers-globe-help') const intro = section?.parentElement?.querySelector(':scope > header') const navbarHeight = Number.parseFloat( @@ -877,14 +865,10 @@ export function MaintainersMap({ maintainers }: MaintainersMapProps) { const { top, height } = container.getBoundingClientRect() const contentTop = (intro?.getBoundingClientRect().bottom ?? top) - top + viewportGutter - const helpBounds = help?.getBoundingClientRect() // Keep the zoomed paint and floating profiles clear of the next section. - const nextContent = - help?.nextElementSibling ?? section?.nextElementSibling + const nextContent = section?.nextElementSibling const contentBottom = - (nextContent?.getBoundingClientRect().top ?? - helpBounds?.bottom ?? - top + height) - + (nextContent?.getBoundingClientRect().top ?? top + height) - top - viewportGutter const nextFadeOffset = contentBottom - height / 2 @@ -903,8 +887,6 @@ export function MaintainersMap({ maintainers }: MaintainersMapProps) { bottom: screenTop + screenHeight - viewportGutter - top, contentTop, contentBottom, - helpTop: (helpBounds?.top ?? 0) - top, - helpBottom: (helpBounds?.bottom ?? 0) - top, } viewportChanged = true requestFrame() @@ -973,9 +955,15 @@ export function MaintainersMap({ maintainers }: MaintainersMapProps) { const readingProfile = container.querySelector( '[data-globe-profile]:hover, [data-globe-profile]:focus-within', ) - const idle = !readingProfile && !interacting.current + const idle = + !readingProfile && + !openProfileTrigger.current && + !interacting.current const autoRotate = - globeVisible && !reducedMotion && !pausedRef.current + globeVisible && + !reducedMotion && + !pausedRef.current && + !openProfileTrigger.current if (autoRotate && idle) { target.current.phi += Math.min(elapsed, 100) * 0.00015 } @@ -1017,6 +1005,18 @@ export function MaintainersMap({ maintainers }: MaintainersMapProps) { viewport, globeVisible, ) || !profileNodes.current + const trigger = openProfileTrigger.current + if (trigger) { + const profile = trigger.closest('[data-globe-profile]') + if ( + !trigger.isConnected || + profile?.getAttribute('data-shown') !== 'true' || + profile.hasAttribute('data-offscreen') !== + trigger.hasAttribute('data-globe-count') + ) { + profilePopover.close() + } + } viewportChanged = false } wasIdle = idle @@ -1068,7 +1068,15 @@ export function MaintainersMap({ maintainers }: MaintainersMapProps) { cancelAnimationFrame(frame) wakeGlobe.current = undefined } - }, [host, globe, surface, reducedMotion, profilePositions, invalidate]) + }, [ + host, + globe, + surface, + reducedMotion, + profilePositions, + invalidate, + profilePopover, + ]) useEffect(() => { if (!host) return @@ -1127,20 +1135,6 @@ export function MaintainersMap({ maintainers }: MaintainersMapProps) { } }, [host, behavior, invalidate, pauseRotation]) - function focus(group: MaintainerGroup) { - pauseRotation() - const phi = (-group.location[1] * Math.PI) / 180 - Math.PI / 2 - target.current.phi = - view.current.phi + - Math.atan2( - Math.sin(phi - view.current.phi), - Math.cos(phi - view.current.phi), - ) - target.current.theta = (group.location[0] * Math.PI) / 180 - setSelectedId(group.id) - invalidate() - } - // The composite globe needs a focus target for its keyboard rotation controls. /* oxlint-disable jsx-a11y/no-noninteractive-tabindex */ return ( @@ -1190,10 +1184,6 @@ export function MaintainersMap({ maintainers }: MaintainersMapProps) { aria-describedby="maintainers-globe-help" tabIndex={0} onKeyDown={(event) => { - if (event.key === 'Escape') { - setSelectedId('') - return - } if (event.target !== event.currentTarget || !event.shiftKey) return const directions: Record = { ArrowLeft: [-0.15, 0], @@ -1272,7 +1262,7 @@ export function MaintainersMap({ maintainers }: MaintainersMapProps) { >
{group.members.map((member) => ( } > - + ))}
- + ))} @@ -1386,71 +1376,78 @@ export function MaintainersMap({ maintainers }: MaintainersMapProps) { -

{ + openProfileTrigger.current = open ? trigger : undefined + wakeGlobe.current?.() + }} > - - Select to see nearby maintainers, Esc to close. - - - Tap a profile to see nearby maintainers. - -

- {selected && ( -
-
-
-

- {`${selected.members.length} maintainer${selected.members.length === 1 ? '' : 's'} nearby`} -

-

- Select a profile to open their GitHub. -

-
- -
- - )} +
+ {selected.members.map((member) => ( + + + + +
+
+ {member.name} +
+
+ {member.location?.name} +
+
+
+ ))} +
+ + + + ) + }} + {!groups.length && (

No shared locations for the selected maintainers and contributors. diff --git a/src/components/home/HomeCommunitySection.tsx b/src/components/home/HomeCommunitySection.tsx index ecb3cdace..dc904e9a5 100644 --- a/src/components/home/HomeCommunitySection.tsx +++ b/src/components/home/HomeCommunitySection.tsx @@ -12,13 +12,7 @@ const MaintainersMap = lazy(() => })), ) -// Reserve the map, its help text line, and the gap between them. -const globeFallback = ( -

- @@ -1307,7 +1328,7 @@ export function MaintainersMap({ maintainers }: MaintainersMapProps) { ))} {group.members.length} - +
))} @@ -1377,76 +1398,84 @@ export function MaintainersMap({ maintainers }: MaintainersMapProps) { { - openProfileTrigger.current = open ? trigger : undefined - wakeGlobe.current?.() + open={Boolean(selected)} + onOpenChange={(open, details) => { + if (open) return + if ( + details.reason === 'outside-press' && + details.event.target instanceof Element && + details.event.target.closest('[data-globe-profile] button') + ) { + details.cancel() + return + } + setSelection(null) }} > - {({ payload }) => { - const selected = groups.find((group) => group.id === payload) - if (!selected) return null - return ( - - + + - -
-
- - {selected.members.length === 1 - ? '1 maintainer nearby' - : `${selected.members.length} maintainers nearby`} - - - Select a profile to open their GitHub. - -
- - +
+
+ + {selected.members.length === 1 + ? '1 maintainer nearby' + : `${selected.members.length} maintainers nearby`} + + + Select a profile to open their GitHub. +
-
- {selected.members.map((member) => ( - - - - -
-
- {member.name} -
-
- {member.location?.name} -
+ + +
+
+ {selected.members.map((member) => ( + + + + + - - - - ) - }} +
+ {member.location?.name} +
+
+ + ))} +
+ + + + )} {!groups.length && (