2020-03-19 17:33:57 +11:00
|
|
|
import React from "react";
|
2020-03-20 11:05:40 +11:00
|
|
|
import { Image, Flex, Box } from "theme-ui";
|
2020-03-19 17:33:57 +11:00
|
|
|
|
2020-03-20 11:05:40 +11:00
|
|
|
import Token from "../components/Token";
|
|
|
|
|
|
|
|
|
|
function Map({ imageSource, tokens }) {
|
2020-03-19 17:33:57 +11:00
|
|
|
return (
|
2020-03-20 11:05:40 +11:00
|
|
|
<Flex
|
|
|
|
|
className="map"
|
|
|
|
|
sx={{ justifyContent: "center", flexGrow: 1 }}
|
|
|
|
|
bg="background"
|
|
|
|
|
>
|
|
|
|
|
<Box
|
|
|
|
|
sx={{
|
|
|
|
|
position: "absolute",
|
|
|
|
|
top: 0,
|
|
|
|
|
left: 0,
|
|
|
|
|
right: 0,
|
|
|
|
|
userSelect: "none"
|
|
|
|
|
}}
|
|
|
|
|
>
|
|
|
|
|
{Object.values(tokens).map(token => (
|
|
|
|
|
<Box
|
|
|
|
|
key={token.id}
|
|
|
|
|
sx={{
|
|
|
|
|
position: "absolute",
|
|
|
|
|
transform: `translate(${token.x}px, ${token.y}px)`
|
|
|
|
|
}}
|
|
|
|
|
>
|
|
|
|
|
<Token image={token.image} className="map-token" />
|
|
|
|
|
</Box>
|
|
|
|
|
))}
|
|
|
|
|
</Box>
|
2020-03-19 17:33:57 +11:00
|
|
|
<Image src={imageSource} sx={{ objectFit: "contain" }} />
|
|
|
|
|
</Flex>
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export default Map;
|