From 8ba9bc871f9d6df95a26238476efe3f928fa5a7b Mon Sep 17 00:00:00 2001 From: Jonghyeon Ko Date: Sat, 7 Nov 2026 09:18:45 +0900 Subject: [PATCH 1/2] feat: show maintainer locations on an interactive globe --- package.json | 1 + pnpm-lock.yaml | 8 + src/components/MaintainersMap.tsx | 983 ++++++++++++++++++++---------- 3 files changed, 680 insertions(+), 312 deletions(-) diff --git a/package.json b/package.json index cf2375f88..6bab65bfd 100644 --- a/package.json +++ b/package.json @@ -138,6 +138,7 @@ "algoliasearch": "^5.50.0", "cheerio": "^1.2.0", "cmdk": "^1.1.1", + "cobe": "^2.0.1", "codemirror": "^6.0.2", "d3": "^7.9.0", "d3-interpolate": "3.0.1", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 02e52c155..c7cdf6265 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -250,6 +250,9 @@ importers: cmdk: specifier: ^1.1.1 version: 1.1.1(@types/react-dom@19.2.3(@types/react@19.2.14))(@types/react@19.2.14)(react-dom@19.2.3(react@19.2.3))(react@19.2.3) + cobe: + specifier: ^2.0.1 + version: 2.0.1 codemirror: specifier: ^6.0.2 version: 6.0.2 @@ -5091,6 +5094,9 @@ packages: react: ^18 || ^19 || ^19.0.0-rc react-dom: ^18 || ^19 || ^19.0.0-rc + cobe@2.0.1: + resolution: {integrity: sha512-aaa6vcIlaC8C1SF50LDH0Anybo/EAXnrxqe+bwvr4+YUtZydqjeBjTTD7ziCCkbRrRGSns3I3F6cZsf3W+L+ag==} + codemirror@6.0.2: resolution: {integrity: sha512-VhydHotNW5w1UGK0Qj96BwSk/Zqbp9WbnyK2W/eVMv4QyF41INRGpjUhFJY7/uDNuudSc33a/PKr4iDqRduvHw==} @@ -13037,6 +13043,8 @@ snapshots: - '@types/react' - '@types/react-dom' + cobe@2.0.1: {} + codemirror@6.0.2: dependencies: '@codemirror/autocomplete': 6.20.3 diff --git a/src/components/MaintainersMap.tsx b/src/components/MaintainersMap.tsx index 676570945..3e0286abc 100644 --- a/src/components/MaintainersMap.tsx +++ b/src/components/MaintainersMap.tsx @@ -1,233 +1,427 @@ -import { useEffect, useMemo, useState } from 'react' -import { - geoEqualEarth, - scaleIdentity, - select, - zoom, - zoomIdentity, - type D3ZoomEvent, -} from 'd3' -import { defineChart, type ChartPoint } from '@tanstack/charts' -import { geoShape } from '@tanstack/charts/geo' -import { Chart } from '@tanstack/charts/react' -import { tooltip } from '@tanstack/charts/tooltip' -import { decorative } from '@tanstack/charts/mark/decorative' -import { text } from '@tanstack/charts/text' +import { useEffect, useId, useMemo, useRef, useState } from 'react' +import { ClientOnly } from '@tanstack/react-router' +import createGlobe, { type Globe, type Marker } from 'cobe' +import { geoDistance, select, zoom, zoomIdentity, type D3ZoomEvent } from 'd3' +import { XIcon } from '@phosphor-icons/react' import type { Maintainer } from '~/libraries/maintainers' import type { LibraryId } from '~/libraries/types' import { categoryOf } from '~/libraries/categories' -import land from '~/data/maintainers-land.json' +import { Tooltip } from '~/ui/Tooltip' -type LandGeometry = { - type: 'MultiPolygon' - coordinates: number[][][][] -} +const initialView = { phi: -Math.PI / 2 - 0.25, theta: 0.4, scale: 1.5 } -type MaintainerPin = { - type: 'Feature' +type MaintainerGroup = { id: string - geometry: { type: 'Point'; coordinates: [number, number] } - properties: Record + location: [number, number] members: Maintainer[] - x: number - y: number - fill: string -} - -const pinRadius = 5 -const groupRadius = 10 -const pinStrokeWidth = 1.5 - -const worldLand: LandGeometry = { - type: 'MultiPolygon', - coordinates: land.coordinates, + color: string } -function getMapLibraryId( - maintainer: Maintainer, - selectedLibraries?: LibraryId[], -) { - return [ - ...(maintainer.creatorOf ?? []), - ...(maintainer.maintainerOf ?? []), - ...(maintainer.contributorOf ?? []), - ...(maintainer.consultantOf ?? []), - ].find((id) => !selectedLibraries?.length || selectedLibraries.includes(id)) +type ProfilePosition = { + x: number + y: number + vx: number + vy: number + offsetX: number + offsetY: number + visible: boolean } -export function createMaintainersMapChart( - maintainers: Maintainer[], - selectedLibraries?: LibraryId[], - transform = zoomIdentity, +// Keep each location's chosen offset for its entire visible pass. Rotation +// carries the row along; empty space opening up is not a reason to reshuffle. +function placeProfiles( + host: Element, + positions: Map, + elapsed: number, ) { - return defineChart({ - chart: ({ width, height }) => { - const projection = geoEqualEarth().fitExtent( - [ - [8, 8], - [width - 8, height - 8], - ], - { type: 'Sphere' }, - ) - const [x, y] = projection.translate() - projection - .scale(projection.scale() * transform.k) - .translate([ - x * transform.k + transform.x, - y * transform.k + transform.y, - ]) - .clipExtent([ - [0, 0], - [width, height], - ]) - - const located = maintainers - .flatMap((member) => { - if (!member.location) return [] - const coordinates: [number, number] = [ - member.location.longitude, - member.location.latitude, - ] - const position = projection(coordinates) - return position - ? [{ member, coordinates, x: position[0], y: position[1] }] - : [] - }) - .sort((a, b) => a.member.github.localeCompare(b.member.github)) - const groups = located.map((anchor) => ({ - anchor, - members: [anchor.member], - })) - let merged = true - while (merged) { - merged = false - for (const [index, group] of groups.entries()) { - for ( - let otherIndex = index + 1; - otherIndex < groups.length; - otherIndex++ - ) { - const other = groups[otherIndex] - const radius = group.members.length > 1 ? groupRadius : pinRadius - const otherRadius = - other.members.length > 1 ? groupRadius : pinRadius - if ( - Math.hypot( - group.anchor.x - other.anchor.x, - group.anchor.y - other.anchor.y, - ) <= - radius + otherRadius + pinStrokeWidth - ) { - group.members.push(...other.members) - groups.splice(otherIndex, 1) - otherIndex-- - merged = true - } - } - } - } - const pins: MaintainerPin[] = [] - for (const { anchor, members } of groups) { - members.sort((a, b) => a.github.localeCompare(b.github)) - const categories = new Set( - members.map((member) => { - const libraryId = getMapLibraryId(member, selectedLibraries) - return libraryId ? categoryOf(libraryId) : undefined - }), - ) - const category = - categories.size === 1 ? categories.values().next().value : undefined - pins.push({ - type: 'Feature', - id: members.map((member) => member.github).join(','), - geometry: { type: 'Point', coordinates: anchor.coordinates }, - properties: {}, - members, - x: anchor.x, - y: anchor.y, - fill: category - ? `var(--color-category-${category})` - : 'var(--color-text-secondary)', - }) + const bounds = host.getBoundingClientRect() + const labels = [...host.querySelectorAll('[data-globe-profile]')].flatMap( + (card) => { + if (!(card instanceof HTMLElement)) return [] + const id = card.dataset.globeProfile + if (!id) return [] + const anchor = host.querySelector(`[data-globe-anchor="${id}"]`) + const line = host.querySelector(`[data-globe-line="${id}"]`) + if (!(anchor instanceof HTMLElement) || !(line instanceof SVGLineElement)) + return [] + const point = anchor.getBoundingClientRect() + const anchorX = point.left - bounds.left, + anchorY = point.top - bounds.top + const visible = + getComputedStyle(anchor).visibility !== 'hidden' && + anchorX >= 0 && + anchorX <= bounds.width && + anchorY >= 0 && + anchorY <= bounds.height + card.style.visibility = visible ? 'visible' : 'hidden' + card.style.opacity = visible ? '1' : '0' + card.style.filter = visible ? 'blur(0px)' : 'blur(6px)' + card.style.transitionDelay = visible ? '0s, 0s, 0s' : '0s, 0s, 280ms' + card.style.pointerEvents = visible ? 'auto' : 'none' + card.inert = !visible + line.style.opacity = visible ? '1' : '0' + const previous = positions.get(id) + if (!visible) { + if (previous) previous.visible = false + return [] } - return { - marks: [ - decorative( - geoShape([worldLand], { - id: 'maintainers-land', - projection: () => projection, - fill: 'currentColor', - stroke: 'currentColor', - strokeWidth: 0.5, - }), - ), - geoShape(pins, { - id: 'maintainers-pins', - projection: () => projection, - key: 'id', - r: (pin) => (pin.members.length > 1 ? groupRadius : pinRadius), - fill: (pin) => pin.fill, - stroke: '#ffffff', - strokeWidth: pinStrokeWidth, - }), - decorative( - text( - pins.filter((pin) => pin.members.length > 1), - { - id: 'maintainers-counts', - key: 'id', - x: 'x', - y: 'y', - text: (pin) => pin.members.length, - fill: '#ffffff', - fontSize: 11, - fontWeight: 600, - }, - ), - ), - ], - scales: { - x: { scale: scaleIdentity() }, - y: { scale: scaleIdentity() }, + const width = card.offsetWidth, + height = card.offsetHeight + const fresh = !previous?.visible + return [ + { + id, + card, + line, + anchorX, + anchorY, + width, + height, + fresh, + x: anchorX + (fresh ? -width / 2 : previous.offsetX), + y: anchorY + (fresh ? -height - 28 : previous.offsetY), }, - guides: false, - margin: 0, - clip: true, - theme: { background: 'transparent' }, - } + ] }, - maxFocusDistance: 16, - tooltip: { - use: tooltip, - format: formatTooltip, - }, - }) + ) + type Label = (typeof labels)[number] + const constrain = (label: Label) => { + label.x = Math.max(10, Math.min(bounds.width - label.width - 10, label.x)) + label.y = Math.max(10, Math.min(bounds.height - label.height - 66, label.y)) + } + const overlaps = (a: Label, b: Label) => + a.x < b.x + b.width + 8 - 0.1 && + a.x + a.width + 8 - 0.1 > b.x && + a.y < b.y + b.height + 8 - 0.1 && + a.y + a.height + 8 - 0.1 > b.y + function findSpace(label: Label, obstacles: Label[]) { + const xs = [ + label.x, + 10, + bounds.width - label.width - 10, + ...obstacles.flatMap((other) => [ + other.x - label.width - 8, + other.x + other.width + 8, + ]), + ] + const ys = [ + label.y, + 10, + bounds.height - label.height - 66, + ...obstacles.flatMap((other) => [ + other.y - label.height - 8, + other.y + other.height + 8, + ]), + ] + let best = { x: label.x, y: label.y, distance: Infinity } + for (const x of xs) + for (const y of ys) { + const candidate = { ...label, x, y } + constrain(candidate) + if (obstacles.some((other) => overlaps(candidate, other))) continue + const distance = + (candidate.x - label.x) ** 2 + (candidate.y - label.y) ** 2 + if (distance < best.distance) + best = { x: candidate.x, y: candidate.y, distance } + } + label.x = best.x + label.y = best.y + } + labels.forEach(constrain) + const settled = labels.filter((label) => !label.fresh) + for (const label of labels + .filter((label) => label.fresh) + .sort((a, b) => b.width - a.width || a.id.localeCompare(b.id))) { + // Only the arriving row finds a new slot. Established rows stay put. + findSpace(label, settled) + settled.push(label) + } + for (let pass = 0; pass < 8; pass++) { + for (let i = 0; i < labels.length; i++) + for (let j = i + 1; j < labels.length; j++) { + const a = labels[i], + b = labels[j] + if (!overlaps(a, b)) continue + const overlapX = + Math.min(a.x + a.width, b.x + b.width) - Math.max(a.x, b.x) + 8 + const overlapY = + Math.min(a.y + a.height, b.y + b.height) - Math.max(a.y, b.y) + 8 + const share = b.width / (a.width + b.width) + if (overlapX < overlapY) { + const direction = a.x + a.width / 2 <= b.x + b.width / 2 ? -1 : 1 + a.x += direction * overlapX * share + b.x -= direction * overlapX * (1 - share) + } else { + const direction = a.y + a.height / 2 <= b.y + b.height / 2 ? -1 : 1 + a.y += direction * overlapY * share + b.y -= direction * overlapY * (1 - share) + } + constrain(a) + constrain(b) + } + } + // If the screen edge blocks a local separation, relocate only the smaller + // blocked row, rather than repacking the whole visible hemisphere. + for (let i = 0; i < labels.length; i++) { + const label = labels[i] + if (labels.some((other) => other !== label && overlaps(label, other))) { + findSpace( + label, + labels.filter((other) => other !== label), + ) + } + } + let moving = false + const dt = Math.min(elapsed, 64) / 1000, + frequency = 14 + const decay = Math.exp(-frequency * dt) + for (const label of labels) { + let position = positions.get(label.id) + if (!position?.visible) { + position = { + x: label.x, + y: label.y + 10, + vx: 0, + vy: 0, + offsetX: label.x - label.anchorX, + offsetY: label.y - label.anchorY, + visible: true, + } + positions.set(label.id, position) + } + position.offsetX = label.x - label.anchorX + position.offsetY = label.y - label.anchorY + const dx = position.x - label.x, + dy = position.y - label.y + const stepX = (position.vx + frequency * dx) * dt + const stepY = (position.vy + frequency * dy) * dt + position.x = label.x + (dx + stepX) * decay + position.y = label.y + (dy + stepY) * decay + position.vx = (position.vx - frequency * stepX) * decay + position.vy = (position.vy - frequency * stepY) * decay + moving ||= + Math.abs(dx) + + Math.abs(dy) + + Math.abs(position.vx) + + Math.abs(position.vy) > + 0.05 + label.card.style.transform = `translate(${position.x}px, ${position.y}px)` + label.line.setAttribute('x1', String(label.anchorX)) + label.line.setAttribute('y1', String(label.anchorY)) + label.line.setAttribute('x2', String(position.x + label.width / 2)) + label.line.setAttribute('y2', String(position.y + label.height)) + } + return moving } -function formatTooltip(point: ChartPoint) { - return point.datum.members - .map((member) => `${member.name}\n${member.location?.name}`) - .join('\n\n') +type MaintainersMapProps = { + maintainers: Maintainer[] + selectedLibraries?: LibraryId[] } export function MaintainersMap({ maintainers, selectedLibraries, -}: { - maintainers: Maintainer[] - selectedLibraries?: LibraryId[] -}) { +}: MaintainersMapProps) { + const prefix = useId().replace(/[^a-zA-Z0-9_-]/g, '') const [host, setHost] = useState((): Element | null => null) - const [transform, setTransform] = useState(zoomIdentity) + const [surface, setSurface] = useState((): HTMLDivElement | null => null) + const [globe, setGlobe] = useState((): Globe | null => null) + const [reducedMotion, setReducedMotion] = useState(false) + const [scale, setScale] = useState(initialView.scale) + const [selectedId, setSelectedId] = useState('') const [behavior] = useState(() => zoom()) - const [selectedGithub, setSelectedGithub] = useState( - (): Maintainer['github'] | undefined => undefined, + const [profilePositions] = useState( + (): Map => new Map(), + ) + const view = useRef({ ...initialView }) + const target = useRef({ ...initialView }) + const interacting = useRef(false) + const dirty = useRef(true) + + const groups = useMemo(() => { + const result: MaintainerGroup[] = [] + for (const member of maintainers) { + if (!member.location) continue + const { latitude, longitude } = member.location + const nearby = result.find( + (group) => + geoDistance( + [group.location[1], group.location[0]], + [longitude, latitude], + ) < + 0.12 / scale, + ) + if (nearby) nearby.members.push(member) + else + result.push({ + id: `${prefix}-${member.github.toLowerCase()}`, + location: [latitude, longitude], + members: [member], + color: '', + }) + } + for (const group of result) { + const categories = new Set( + group.members.map((member) => { + const library = [ + ...(member.creatorOf ?? []), + ...(member.maintainerOf ?? []), + ...(member.contributorOf ?? []), + ...(member.consultantOf ?? []), + ].find( + (id) => + !selectedLibraries?.length || selectedLibraries.includes(id), + ) + return library ? categoryOf(library) : undefined + }), + ) + const category = + categories.size === 1 ? categories.values().next().value : undefined + group.color = category + ? `var(--color-category-${category})` + : 'var(--color-text-secondary)' + } + return result + }, [maintainers, selectedLibraries, prefix, scale]) + const selected = groups.find((group) => group.id === selectedId) + const locatedCount = groups.reduce( + (count, group) => count + group.members.length, + 0, ) + + useEffect(() => { + if (!surface) return + const canvas = document.createElement('canvas') + canvas.style.cssText = 'display:block;width:100%;height:100%' + canvas.setAttribute('aria-hidden', 'true') + surface.append(canvas) + const instance = createGlobe(canvas, { + width: surface.clientWidth, + height: surface.clientHeight, + devicePixelRatio: Math.min(window.devicePixelRatio, 2), + ...view.current, + dark: 1, + diffuse: 1.4, + mapSamples: 24000, + mapBrightness: 6, + mapBaseBrightness: 0, + baseColor: [0.55, 0.65, 0.72], + markerColor: [1, 0.57, 0.37], + glowColor: [0.12, 0.17, 0.2], + markerElevation: 0.015, + }) + setGlobe(instance) + const resize = new ResizeObserver(() => { + instance.update({ + width: surface.clientWidth, + height: surface.clientHeight, + }) + dirty.current = true + }) + resize.observe(surface) + const updateTheme = () => { + const dark = document.documentElement.classList.contains('dark') + instance.update({ + dark: dark ? 1 : 0, + baseColor: dark ? [0.55, 0.65, 0.72] : [1, 1, 1], + glowColor: dark ? [0.12, 0.17, 0.2] : [0.9, 0.91, 0.92], + }) + dirty.current = true + } + updateTheme() + const theme = new MutationObserver(updateTheme) + theme.observe(document.documentElement, { + attributes: true, + attributeFilter: ['class'], + }) + return () => { + resize.disconnect() + theme.disconnect() + instance.destroy() + surface.replaceChildren() + } + }, [surface]) + + useEffect(() => { + if (!globe) return + const markers: Marker[] = groups.map((group) => ({ + id: group.id, + location: group.location, + size: group.members.length > 1 ? 0.035 : 0.022, + })) + globe.update({ markers }) + dirty.current = true + }, [globe, groups]) + + useEffect(() => { + const preference = window.matchMedia('(prefers-reduced-motion: reduce)') + const update = () => setReducedMotion(preference.matches) + update() + preference.addEventListener('change', update) + return () => preference.removeEventListener('change', update) + }, []) + + useEffect(() => { + if (!host || !globe) return + const container = host + const instance = globe + let visible = false, + lastFrame = performance.now(), + frame = 0 + let layoutMoving = true + const observer = new IntersectionObserver(([entry]) => { + visible = entry.isIntersecting + dirty.current = true + }) + observer.observe(host) + dirty.current = true + function animate(now: number) { + const elapsed = now - lastFrame + if (elapsed >= 1000 / 30) { + lastFrame = now + if (visible && !document.hidden) { + const readingProfile = container.querySelector( + '[data-globe-profile]:hover, [data-globe-profile]:focus-within', + ) + if (!reducedMotion && !interacting.current && !readingProfile) { + target.current.phi += Math.min(elapsed, 100) * 0.00015 + } + const current = view.current, + next = target.current + const moving = + Math.abs(current.phi - next.phi) + + Math.abs(current.theta - next.theta) + + Math.abs(current.scale - next.scale) > + 0.00001 + const redraw = moving || dirty.current + if (redraw) { + const ease = 1 - Math.exp(-Math.min(elapsed, 100) / 90) + current.phi += (next.phi - current.phi) * ease + current.theta += (next.theta - current.theta) * ease + current.scale += (next.scale - current.scale) * ease + instance.update(current) + } + if (redraw || layoutMoving) + layoutMoving = placeProfiles(container, profilePositions, elapsed) + dirty.current = false + } + } + frame = requestAnimationFrame(animate) + } + frame = requestAnimationFrame(animate) + return () => { + observer.disconnect() + cancelAnimationFrame(frame) + } + }, [host, globe, reducedMotion, groups, profilePositions]) + useEffect(() => { if (!host) return const selection = select(host) + let previous = zoomIdentity behavior - .scaleExtent([1, 128]) + .scaleExtent([1, 6]) .extent((): [[number, number], [number, number]] => [ [0, 0], [host.clientWidth, host.clientHeight], @@ -235,117 +429,228 @@ export function MaintainersMap({ .filter( (event: MouseEvent) => !event.button && + !( + event.target instanceof Element && + event.target.closest('button, [data-globe-profile]') + ) && (event.type !== 'wheel' || event.ctrlKey || event.metaKey), ) - .on('zoom', (event: D3ZoomEvent) => - setTransform(event.transform), - ) + .on('start', () => { + interacting.current = true + }) + .on('zoom', (event: D3ZoomEvent) => { + const next = event.transform + if (next.k === previous.k) { + target.current.phi += + (next.x - previous.x) / (host.clientHeight * 0.4 * next.k) + target.current.theta = Math.max( + -1.2, + Math.min( + 1.2, + target.current.theta + + (next.y - previous.y) / (host.clientHeight * 0.4 * next.k), + ), + ) + view.current.phi = target.current.phi + view.current.theta = target.current.theta + } + target.current.scale = next.k + setScale(next.k) + previous = next + dirty.current = true + }) + .on('end', () => { + interacting.current = false + }) selection.call(behavior) - const resize = new ResizeObserver(() => { - behavior.translateExtent([ - [0, 0], - [host.clientWidth, host.clientHeight], - ]) - selection.call(behavior.scaleBy, 1) - }) - resize.observe(host) + const mobile = window.matchMedia('(max-width: 639px)') + const setStartingZoom = () => { + const startingScale = mobile.matches ? 1.2 : initialView.scale + selection.call(behavior.transform, zoomIdentity.scale(startingScale)) + view.current.scale = startingScale + dirty.current = true + } + setStartingZoom() + mobile.addEventListener('change', setStartingZoom) return () => { - resize.disconnect() + mobile.removeEventListener('change', setStartingZoom) selection.on('.zoom', null) } }, [host, behavior]) - const definition = useMemo( - () => createMaintainersMapChart(maintainers, selectedLibraries, transform), - [maintainers, selectedLibraries, transform], - ) - function changeZoom(factor: number) { - if (!host) return - const location = - maintainers.find((member) => member.github === selectedGithub) - ?.location ?? maintainers.find((member) => member.location)?.location - const projected = - location && - geoEqualEarth().fitExtent( - [ - [8, 8], - [host.clientWidth - 8, host.clientHeight - 8], - ], - { type: 'Sphere' }, - )([location.longitude, location.latitude]) - const k = Math.max(1, Math.min(128, transform.k * factor)) - const anchor = - projected ?? - transform.invert([host.clientWidth / 2, host.clientHeight / 2]) - const next = zoomIdentity - .translate( - host.clientWidth / 2 - anchor[0] * k, - host.clientHeight / 2 - anchor[1] * k, + + function focus(group: MaintainerGroup) { + 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), ) - .scale(k) - select(host).call( - behavior.transform, - behavior.constrain()( - next, - [ - [0, 0], - [host.clientWidth, host.clientHeight], - ], - behavior.translateExtent(), - ), - ) + target.current.theta = (group.location[0] * Math.PI) / 180 + setSelectedId(group.id) + dirty.current = true } function reset() { - if (host) select(host).call(behavior.transform, zoomIdentity) + const startingScale = window.matchMedia('(max-width: 639px)').matches + ? 1.2 + : initialView.scale + if (host) + select(host).call(behavior.transform, zoomIdentity.scale(startingScale)) + target.current = { ...initialView, scale: startingScale } + setSelectedId('') + dirty.current = true } - const hasLocations = maintainers.some((maintainer) => maintainer.location) + // The composite globe needs a focus target for its keyboard rotation controls. + /* oxlint-disable jsx-a11y/no-noninteractive-tabindex */ return (
-
-

- Around the world -

+ +
+
+

+ Around the world +

+

+ {locatedCount} shared location{locatedCount === 1 ? '' : 's'} +

+
-
+
{ + if (event.key === 'Escape') { + setSelectedId('') + return + } + if (event.target !== event.currentTarget || !event.shiftKey) return + const directions: Record = { + ArrowLeft: [-0.15, 0], + ArrowRight: [0.15, 0], + ArrowUp: [0, -0.15], + ArrowDown: [0, 0.15], + } + const direction = directions[event.key] + if (!direction) return + event.preventDefault() + target.current.phi += direction[0] + target.current.theta = Math.max( + -1.2, + Math.min(1.2, target.current.theta + direction[1]), + ) + dirty.current = true + }} + className="relative isolate aspect-square overflow-hidden rounded-xl border border-gray-200 bg-gray-50/50 outline-offset-4 sm:aspect-[3/2] dark:border-gray-800 dark:bg-gray-900/30" + >
{ - if (!host || !event.shiftKey) return - const directions: Record = { - ArrowLeft: [40, 0], - ArrowRight: [-40, 0], - ArrowUp: [0, 40], - ArrowDown: [0, -40], - } - const direction = directions[event.key] - if (!direction) return - event.preventDefault() - event.stopPropagation() - select(host).call( - behavior.translateBy, - direction[0] / transform.k, - direction[1] / transform.k, - ) - }} - className="touch-none rounded-xl bg-gray-50 text-gray-300 dark:bg-gray-900/50 dark:text-gray-700" + ref={setSurface} + className="absolute inset-0 touch-none cursor-grab active:cursor-grabbing" + /> +
+ {groups.map(({ id }) => ( + + ))} + + {groups.map((group, index) => ( + { + anchor?.style.setProperty( + 'visibility', + `var(--cobe-visible-${group.id}, hidden)`, + ) + }} + aria-hidden="true" + className="pointer-events-none absolute size-px" + style={{ + positionAnchor: `--cobe-${group.id}`, + left: 'anchor(center)', + top: 'anchor(center)', + }} + > + + + ))} + + {groups.map((group) => ( +
+
+ {group.members.map((member) => ( + +
{member.name}
+
+ {member.location?.name} +
+
+ } + > + + + ))} +
+
+ ))} +
-

- Made with{' '} - - Natural Earth - - . -

+ + Made with COBE ↗ +
-

- Drag to pan. Use Ctrl or ⌘ and scroll to zoom, or pinch on touch - screens. Select a pin, then use + to zoom toward it. Use Shift and arrow - keys to pan. +

+ Drag to rotate. Use Ctrl or ⌘ and scroll to zoom, or pinch on touch + screens. Release to resume auto-rotation. Hover over a profile to pause + and read their name; select one to meet the maintainers nearby. Use + Shift and arrow keys to rotate.

- {!hasLocations && ( + {selected && ( +
+
+
+

+ {selected.members.length === 1 + ? 'Meet the maintainer' + : `${selected.members.length} maintainers nearby`} +

+

+ Shared locations from this cluster. +

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

No shared locations for the selected maintainers and contributors.

From 34f86a54c539220e4b90452460581d773ea15c40 Mon Sep 17 00:00:00 2001 From: Jonghyeon Ko Date: Sat, 7 Nov 2026 09:40:30 +0900 Subject: [PATCH 2/2] fix: tighten mobile maintainer profile spacing --- src/components/MaintainersMap.tsx | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/src/components/MaintainersMap.tsx b/src/components/MaintainersMap.tsx index 3e0286abc..36525a657 100644 --- a/src/components/MaintainersMap.tsx +++ b/src/components/MaintainersMap.tsx @@ -35,6 +35,7 @@ function placeProfiles( elapsed: number, ) { const bounds = host.getBoundingClientRect() + const gap = window.matchMedia('(max-width: 639px)').matches ? 4 : 8 const labels = [...host.querySelectorAll('[data-globe-profile]')].flatMap( (card) => { if (!(card instanceof HTMLElement)) return [] @@ -90,18 +91,18 @@ function placeProfiles( label.y = Math.max(10, Math.min(bounds.height - label.height - 66, label.y)) } const overlaps = (a: Label, b: Label) => - a.x < b.x + b.width + 8 - 0.1 && - a.x + a.width + 8 - 0.1 > b.x && - a.y < b.y + b.height + 8 - 0.1 && - a.y + a.height + 8 - 0.1 > b.y + a.x < b.x + b.width + gap - 0.1 && + a.x + a.width + gap - 0.1 > b.x && + a.y < b.y + b.height + gap - 0.1 && + a.y + a.height + gap - 0.1 > b.y function findSpace(label: Label, obstacles: Label[]) { const xs = [ label.x, 10, bounds.width - label.width - 10, ...obstacles.flatMap((other) => [ - other.x - label.width - 8, - other.x + other.width + 8, + other.x - label.width - gap, + other.x + other.width + gap, ]), ] const ys = [ @@ -109,8 +110,8 @@ function placeProfiles( 10, bounds.height - label.height - 66, ...obstacles.flatMap((other) => [ - other.y - label.height - 8, - other.y + other.height + 8, + other.y - label.height - gap, + other.y + other.height + gap, ]), ] let best = { x: label.x, y: label.y, distance: Infinity } @@ -143,9 +144,9 @@ function placeProfiles( b = labels[j] if (!overlaps(a, b)) continue const overlapX = - Math.min(a.x + a.width, b.x + b.width) - Math.max(a.x, b.x) + 8 + Math.min(a.x + a.width, b.x + b.width) - Math.max(a.x, b.x) + gap const overlapY = - Math.min(a.y + a.height, b.y + b.height) - Math.max(a.y, b.y) + 8 + Math.min(a.y + a.height, b.y + b.height) - Math.max(a.y, b.y) + gap const share = b.width / (a.width + b.width) if (overlapX < overlapY) { const direction = a.x + a.width / 2 <= b.x + b.width / 2 ? -1 : 1