Skip to content

📈 Open source, privacy-first web analytics — a cookie-less Google Analytics alternative with built-in error tracking and performance monitoring. Self-host it or use our cloud. Get started for free!

fix eslint complaints

Blue Mousee4b629cf7711
diff --git a/src/pages/Project/View/InteractiveMap.jsx b/src/pages/Project/View/InteractiveMap.jsx
index 148745d0a..ca5c9ba4f 100644
--- a/src/pages/Project/View/InteractiveMap.jsx
+++ b/src/pages/Project/View/InteractiveMap.jsx
@@ -25,24 +25,21 @@ countries.registerLocale(countriesZh)
countries.registerLocale(countriesSv)
const InteractiveMap = ({ data, onClickCountry, total }) => {
-
const { t, i18n: { language } } = useTranslation('common')
const [hoverShow, setHoverShow] = useState(false)
const [dataHover, setDataHover] = useState(null)
const [cursorPosition, setCursorPosition] = useState(null)
-
- const onMouseMove = (e) => {
- let rect = e.currentTarget.getBoundingClientRect()
-
- let x = e.clientX - rect.left
- let y = e.clientY - rect.top
- setCursorPosition({pageX: x, pageY: y})
+ const onMouseMove = (e) => {
+ const rect = e.currentTarget.getBoundingClientRect()
+ const pageX = e.clientX - rect.left
+ const pageY = e.clientY - rect.top
+ setCursorPosition({ pageX, pageY })
}
return (
<div className='relative'>
- <svg id='map' viewBox='0 0 1050 650' className='w-full h-full' onMouseMove={(e) => {onMouseMove(e)}}>
+ <svg id='map' viewBox='0 0 1050 650' className='w-full h-full' onMouseMove={(e) => { onMouseMove(e) }}>
<g>
{_map(countriesList, (item, index) => {
const perc = ((data[index] / total) * 100) || 0
@@ -61,33 +58,38 @@ const InteractiveMap = ({ data, onClickCountry, total }) => {
})}
d={item.d}
onClick={() => perc !== 0 && onClickCountry(index)}
- onMouseEnter={(e) => {
+ onMouseEnter={() => {
setHoverShow(true)
setDataHover({
countries: countries.getName(index, language),
- data: data[index] || 0
+ data: data[index] || 0,
})
}}
onMouseLeave={() => {
setHoverShow(false)
}}
- >
- </path>
+ />
)
})}
</g>
</svg>
<div>
{hoverShow && (
- <div className="border-2 text-xs dark:bg-gray-800 dark:shadow-gray-850 dark:border-gray-850 dark:text-gray-200 p-1 rounded-md" style={{
- zIndex: 9999,
- position: 'absolute',
- top: cursorPosition.pageY+20,
- left: cursorPosition.pageX
- }}>
- <strong>{dataHover.countries}</strong>
- <br />
- {t('project.unique')}: <strong className="dark:text-indigo-400">{dataHover.data}</strong>
+ <div
+ className='border-2 absolute z-30 text-xs dark:bg-gray-800 dark:shadow-gray-850 dark:border-gray-850 dark:text-gray-200 p-1 rounded-md'
+ style={{
+ top: cursorPosition.pageY + 20,
+ left: cursorPosition.pageX - 20,
+ }}
+ >
+ <strong>{dataHover.countries}</strong>
+ <br />
+ {t('project.unique')}
+ :
+ &nbsp;
+ <strong className='dark:text-indigo-400'>
+ {dataHover.data}
+ </strong>
</div>
)}
</div>