import React, { useState } from 'react'; import ReactTooltip from 'react-tooltip'; import classNames from 'classnames'; import tinycolor from 'tinycolor2'; import { ComposableMap, Geographies, Geography, ZoomableGroup } from 'react-simple-maps'; import styles from './WorldMap.module.css'; const geoUrl = '/world-110m.json'; export default function WorldMap({ data, className, baseColor = '#e9f3fd', fillColor = '#f5f5f5', strokeColor = '#2680eb', hoverColor = '#2680eb', }) { const [tooltip, setTooltip] = useState(); function getFillColor(code) { if (code === 'AQ') return '#ffffff'; const country = data?.find(({ x }) => x === code); return country ? tinycolor(baseColor).darken(country.z) : fillColor; } function getStrokeColor(code) { return code === 'AQ' ? '#ffffff' : strokeColor; } function getHoverColor(code) { return code === 'AQ' ? '#ffffff' : hoverColor; } function handleHover({ ISO_A2: code, NAME: name }) { const country = data?.find(({ x }) => x === code); setTooltip(`${name}: ${country?.y || 0} visitors`); } return (