Files
grungnet/src/components/map/MapDice.js
Mitchell McCaffrey 0d37f8c6e3 Changed map interaction to ignore events not on the canvas
This removes the need for calling prevent interaction all over the code also allowed pointer events to go through the empty parts of the dice tray
2020-05-27 15:26:42 +10:00

47 lines
1.2 KiB
JavaScript

import React, { useState } from "react";
import { Flex, IconButton } from "theme-ui";
import ExpandMoreDiceIcon from "../../icons/ExpandMoreDiceIcon";
import DiceTrayOverlay from "./dice/DiceTrayOverlay";
import { DiceLoadingProvider } from "../../contexts/DiceLoadingContext";
function MapDice() {
const [isExpanded, setIsExpanded] = useState(false);
return (
<Flex
sx={{
position: "absolute",
top: 0,
left: 0,
bottom: 0,
flexDirection: "column",
alignItems: "flex-start",
pointerEvents: "none",
}}
ml={1}
>
<IconButton
aria-label={isExpanded ? "Hide Dice Tray" : "Show Dice Tray"}
title={isExpanded ? "Hide Dice Tray" : "Show Dice Tray"}
onClick={() => setIsExpanded(!isExpanded)}
sx={{
display: "block",
backgroundColor: "overlay",
borderRadius: "50%",
pointerEvents: "all",
}}
m={2}
>
<ExpandMoreDiceIcon isExpanded={isExpanded} />
</IconButton>
<DiceLoadingProvider>
<DiceTrayOverlay isOpen={isExpanded} />
</DiceLoadingProvider>
</Flex>
);
}
export default MapDice;