Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions app/page.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,7 @@ export default function Home() {
onSelectDev={handleSelectDev}
onSelectCountry={handleSelectCountry}
onClearCountry={handleClearCountry}
tooltipDisabled={Boolean(selectedDev || compareDevs.length === 2)}
/>
<Leaderboard
developers={filtered}
Expand Down
29 changes: 24 additions & 5 deletions components/Globe.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ const Globe = forwardRef(function Globe({
onSelectDev,
onSelectCountry,
onClearCountry,
tooltipDisabled = false,
}, ref) {
const globeEl = useRef();
const tooltipRef = useRef(null);
Expand Down Expand Up @@ -225,10 +226,21 @@ const Globe = forwardRef(function Globe({
if (controls) controls.autoRotate = on && !selectedCountry;
}, [selectedCountry]);

useEffect(() => {
if (!tooltipDisabled) return;
tooltipRef.current?.classList.remove('visible');
setHoverCountry(null);
}, [tooltipDisabled]);

const handleHover = useCallback((point) => {
const tooltip = tooltipRef.current;
if (!tooltip) return;

if (tooltipDisabled) {
tooltip.classList.remove('visible');
return;
}

if (point) {
tooltip.innerHTML = `
<div class="tooltip__header">
Expand All @@ -255,7 +267,7 @@ const Globe = forwardRef(function Globe({
tooltip.classList.remove('visible');
setAutoRotate(true);
}
}, [setAutoRotate]);
}, [setAutoRotate, tooltipDisabled]);

const handleClick = useCallback((point) => {
if (point) onSelectDev(point);
Expand All @@ -282,10 +294,17 @@ const Globe = forwardRef(function Globe({
}, [hoverCountry, selectedFeature]);

const handleCountryHover = useCallback((feat) => {
setHoverCountry(feat || null);
const tooltip = tooltipRef.current;
if (!tooltip) return;

if (tooltipDisabled) {
setHoverCountry(null);
tooltip.classList.remove('visible');
return;
}

setHoverCountry(feat || null);

if (feat) {
const name = featureName(feat);
const safeName = String(name).replace(/[&<>"']/g, ch => ({ '&': '&amp;', '<': '&lt;', '>': '&gt;', '"': '&quot;', "'": '&#39;' }[ch]));
Expand All @@ -301,7 +320,7 @@ const Globe = forwardRef(function Globe({
tooltip.classList.remove('visible');
setAutoRotate(true);
}
}, [devCountByCountry, setAutoRotate]);
}, [devCountByCountry, setAutoRotate, tooltipDisabled]);

const handleCountryClick = useCallback((feat) => {
if (!feat) return;
Expand Down Expand Up @@ -330,14 +349,14 @@ const Globe = forwardRef(function Globe({
// Track mouse for tooltip
useEffect(() => {
const handler = (e) => {
if (tooltipRef.current) {
if (tooltipRef.current && !tooltipDisabled) {
tooltipRef.current.style.left = (e.clientX + 12) + 'px';
tooltipRef.current.style.top = (e.clientY + 12) + 'px';
}
};
document.addEventListener('mousemove', handler);
return () => document.removeEventListener('mousemove', handler);
}, []);
}, [tooltipDisabled]);

return (
<>
Expand Down
2 changes: 1 addition & 1 deletion components/Header.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export default function Header({ onHome, theme, onToggleTheme, user, onLogout, o
<div className="header__brand" onClick={onHome} style={{ cursor: 'pointer' }}>
<img src="/devglobe.png" alt="DevGlobe" className="header__logo" />
<h1 className="header__title">DevGlobe</h1>
<span className="header__subtitle">Visualizing the World's Top Open-Source Contributors</span>
<span className="header__subtitle">Where Developers and AI Agents Connect</span>
</div>
<div className="header__actions">
<button
Expand Down
Loading