-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
cf835b6
commit 75a0f0f
Showing
2 changed files
with
52 additions
and
16 deletions.
There are no files selected for viewing
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 |
---|---|---|
@@ -1,18 +1,39 @@ | ||
import { useState } from "react"; | ||
import { Typography } from "@material-tailwind/react"; | ||
import { Typography, Button } from "@material-tailwind/react"; | ||
import { Tooltip } from "react-tooltip"; | ||
import { useCountries } from "use-react-countries"; | ||
import { MapChart } from "./MapChart.tsx"; | ||
|
||
export function Component() { | ||
const [content, setContent] = useState(""); | ||
const [selectedTooltipContent, setSelectedTooltipContent] = useState(""); | ||
const [selectedCountry, setSelectedCountry] = useState(""); | ||
|
||
const { countries } = useCountries(); | ||
const countyDetails = countries.find(({ name }: { name: string }) => name.toLowerCase() === selectedCountry.toLowerCase()); | ||
|
||
console.log(countries); | ||
|
||
return ( | ||
<div className="flex h-full w-full flex-col items-center"> | ||
<Typography variant="h1" className="mt-10 md:mt-10 mb-6 text-3xl md:text-5xl">Map</Typography> | ||
|
||
<MapChart setTooltipContent={setContent} /> | ||
|
||
<Tooltip id="country-tooltip">{content}</Tooltip> | ||
<Typography variant="h1" className="mb-6 mt-10 text-3xl md:mt-10 md:text-5xl"> | ||
Map | ||
</Typography> | ||
|
||
<Tooltip id="country-tooltip">{selectedTooltipContent}</Tooltip> | ||
<MapChart setSelectedCountry={setSelectedCountry} setTooltipContent={setSelectedTooltipContent} /> | ||
|
||
{selectedCountry && ( | ||
<> | ||
<div className="mb-4 mt-8 flex items-center gap-8"> | ||
<Typography variant="h2" className="text-2xl flex items-center gap-2"> | ||
<img src={countyDetails.flags.svg} alt={selectedCountry} className="h-5 w-5 rounded-full object-cover" /> | ||
|
||
{selectedCountry} | ||
</Typography> | ||
<Button className="h-10">View country information</Button> | ||
</div> | ||
</> | ||
)} | ||
</div> | ||
); | ||
} |