Files
grungnet/src/components/map/dice/SelectDiceButton.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

43 lines
947 B
JavaScript

import React, { useState } from "react";
import { IconButton } from "theme-ui";
import SelectDiceIcon from "../../../icons/SelectDiceIcon";
import SelectDiceModal from "../../../modals/SelectDiceModal";
function SelectDiceButton({ onDiceChange, currentDice }) {
const [isModalOpen, setIsModalOpen] = useState(false);
function openModal() {
setIsModalOpen(true);
}
function closeModal() {
setIsModalOpen(false);
}
function handleDone(dice) {
onDiceChange(dice);
closeModal();
}
return (
<>
<IconButton
aria-label="Select Dice Style"
title="Select Dice Style"
color="hsl(210, 50%, 96%)"
onClick={openModal}
>
<SelectDiceIcon />
</IconButton>
<SelectDiceModal
isOpen={isModalOpen}
onRequestClose={closeModal}
defaultDice={currentDice}
onDone={handleDone}
/>
</>
);
}
export default SelectDiceButton;