Updated dice tray icon and fixed map interaction with select dice modal open

This commit is contained in:
Mitchell McCaffrey
2020-05-26 15:43:46 +10:00
parent 84b198c851
commit dec8fd3c2e
4 changed files with 114 additions and 85 deletions

View File

@@ -0,0 +1,42 @@
import React, { useState, useContext } from "react";
import { IconButton } from "theme-ui";
import SelectDiceIcon from "../../../icons/SelectDiceIcon";
import SelectDiceModal from "../../../modals/SelectDiceModal";
import MapInteractionContext from "../../../contexts/MapInteractionContext";
function SelectDiceButton({ onDiceChange, currentDice }) {
const [isModalOpen, setIsModalOpen] = useState(false);
const { setPreventMapInteraction } = useContext(MapInteractionContext);
function openModal() {
setIsModalOpen(true);
setPreventMapInteraction(true);
}
function closeModal() {
setIsModalOpen(false);
setPreventMapInteraction(false);
}
function handleDone(dice) {
onDiceChange(dice);
closeModal();
}
return (
<>
<IconButton color="hsl(210, 50%, 96%)" onClick={openModal}>
<SelectDiceIcon />
</IconButton>
<SelectDiceModal
isOpen={isModalOpen}
onRequestClose={closeModal}
defaultDice={currentDice}
onDone={handleDone}
/>
</>
);
}
export default SelectDiceButton;