2020-05-21 22:57:44 +10:00
|
|
|
import React, { useContext } from "react";
|
|
|
|
|
import { Box, IconButton } from "theme-ui";
|
|
|
|
|
|
|
|
|
|
import RemoveTokenIcon from "../../icons/RemoveTokenIcon";
|
|
|
|
|
|
|
|
|
|
import MapInteractionContext from "../../contexts/MapInteractionContext";
|
|
|
|
|
|
|
|
|
|
function TokenDragOverlay({ onTokenStateRemove }) {
|
|
|
|
|
const { setPreventMapInteraction } = useContext(MapInteractionContext);
|
|
|
|
|
|
|
|
|
|
function handleTokenRemove() {
|
|
|
|
|
onTokenStateRemove();
|
|
|
|
|
setPreventMapInteraction(false);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<Box
|
|
|
|
|
sx={{
|
|
|
|
|
position: "absolute",
|
2020-05-22 13:44:17 +10:00
|
|
|
bottom: "24px",
|
2020-05-21 22:57:44 +10:00
|
|
|
left: "50%",
|
|
|
|
|
borderRadius: "50%",
|
2020-05-22 13:44:17 +10:00
|
|
|
transform: "translateX(-50%) scale(1.5)",
|
2020-05-21 22:57:44 +10:00
|
|
|
transition: "transform 250ms ease",
|
|
|
|
|
":hover": {
|
2020-05-22 13:44:17 +10:00
|
|
|
transform: "translateX(-50%) scale(2.0)",
|
2020-05-21 22:57:44 +10:00
|
|
|
},
|
|
|
|
|
}}
|
|
|
|
|
bg="overlay"
|
|
|
|
|
onMouseUp={handleTokenRemove}
|
|
|
|
|
onTouchEnd={handleTokenRemove}
|
|
|
|
|
>
|
|
|
|
|
<IconButton>
|
|
|
|
|
<RemoveTokenIcon />
|
|
|
|
|
</IconButton>
|
|
|
|
|
</Box>
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export default TokenDragOverlay;
|