-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Henry Gressmann <mail@henrygressmann.de>
- Loading branch information
1 parent
d054736
commit 46e5097
Showing
8 changed files
with
110 additions
and
3 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
.reset { | ||
all: unset; | ||
} | ||
|
||
.geo { | ||
opacity: 0.9; | ||
&:hover { | ||
opacity: 1; | ||
} | ||
} | ||
|
||
div.tooltip { | ||
background-color: var(--pico-secondary-background); | ||
padding: 0.4rem 0.5rem; | ||
border-radius: 0.4rem; | ||
min-width: 7rem; | ||
|
||
h2 { | ||
margin-bottom: 0.3rem; | ||
font-size: 1rem; | ||
color: var(--pico-contrast); | ||
} | ||
|
||
h3 { | ||
font-size: 1rem; | ||
display: flex; | ||
justify-content: space-between; | ||
margin: 0; | ||
color: var(--pico-contrast); | ||
font-weight: 800; | ||
align-items: center; | ||
|
||
span { | ||
color: var(--pico-h3-color); | ||
padding: 0.1rem 0.2rem; | ||
font-weight: 500; | ||
border-radius: 0.2rem; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
import styles from "./worldmap.module.css"; | ||
import geo from "../../../data/geo.json"; | ||
import { ComposableMap, Geographies, Geography } from "react-simple-maps"; | ||
import { Tooltip } from "react-tooltip"; | ||
import { useState } from "react"; | ||
|
||
type Geo = { | ||
name: string; | ||
iso: string; | ||
}; | ||
|
||
export const WorldMap = () => { | ||
const [currentGeo, setCurrentGeo] = useState<Geo | null>(null); | ||
|
||
return ( | ||
<div className={styles.worldmap} data-tooltip-float={true} data-tooltip-id="map"> | ||
<ComposableMap projection="geoMercator"> | ||
<Geographies geography={geo}> | ||
{({ geographies }) => | ||
geographies.map((geo) => { | ||
console.log(geo); | ||
|
||
return ( | ||
<Geography | ||
className={styles.geo} | ||
onMouseEnter={() => { | ||
setCurrentGeo({ | ||
name: geo.properties.name, | ||
iso: geo.properties.iso, | ||
}); | ||
}} | ||
onMouseLeave={() => { | ||
setCurrentGeo(null); | ||
}} | ||
key={geo.rsmKey} | ||
geography={geo} | ||
/> | ||
); | ||
}) | ||
} | ||
</Geographies> | ||
</ComposableMap> | ||
<Tooltip id="map" className={styles.reset} classNameArrow={styles.reset} disableStyleInjection> | ||
{currentGeo && ( | ||
<div className={styles.tooltip} data-theme="dark"> | ||
<h2>{currentGeo.name}</h2> | ||
<h3> | ||
{currentGeo.iso} <span>asdf</span> | ||
</h3> | ||
</div> | ||
)} | ||
</Tooltip> | ||
</div> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters