diff --git a/src/components/Tile.js b/src/components/Tile.js index 0a98a85..3640c37 100644 --- a/src/components/Tile.js +++ b/src/components/Tile.js @@ -55,11 +55,7 @@ function Tile({ e.stopPropagation(); onSelect(); }} - onDoubleClick={(e) => { - if (canEdit) { - onDoubleClick(e); - } - }} + onDoubleClick={onDoubleClick} > onDiceSelect(dice)} onDoubleClick={() => onDone(dice)} - large={large} + size={size} /> ); } diff --git a/src/components/dice/DiceTiles.js b/src/components/dice/DiceTiles.js index 92cd598..86ef58a 100644 --- a/src/components/dice/DiceTiles.js +++ b/src/components/dice/DiceTiles.js @@ -1,21 +1,27 @@ import React from "react"; import { Flex } from "theme-ui"; import SimpleBar from "simplebar-react"; -import { useMedia } from "react-media"; import DiceTile from "./DiceTile"; +import useResponsiveLayout from "../../hooks/useResponsiveLayout"; + function DiceTiles({ dice, onDiceSelect, selectedDice, onDone }) { - const isSmallScreen = useMedia({ query: "(max-width: 500px)" }); + const layout = useResponsiveLayout(); return ( - + {dice.map((dice) => ( @@ -25,7 +31,7 @@ function DiceTiles({ dice, onDiceSelect, selectedDice, onDone }) { isSelected={selectedDice && dice.key === selectedDice.key} onDiceSelect={onDiceSelect} onDone={onDone} - large={isSmallScreen} + size={layout.tileSize} /> ))} diff --git a/src/components/map/MapTile.js b/src/components/map/MapTile.js index a81abdf..f09a620 100644 --- a/src/components/map/MapTile.js +++ b/src/components/map/MapTile.js @@ -29,7 +29,7 @@ function MapTile({ isSelected={isSelected} onSelect={() => onMapSelect(map)} onEdit={() => onMapEdit(map.id)} - onDoubleClick={onDone} + onDoubleClick={() => canEdit && onDone()} size={size} canEdit={canEdit} badges={badges} diff --git a/src/modals/SelectDiceModal.js b/src/modals/SelectDiceModal.js index 81ecb50..693331e 100644 --- a/src/modals/SelectDiceModal.js +++ b/src/modals/SelectDiceModal.js @@ -6,13 +6,17 @@ import DiceTiles from "../components/dice/DiceTiles"; import { dice } from "../dice"; +import useResponsiveLayout from "../hooks/useResponsiveLayout"; + function SelectDiceModal({ isOpen, onRequestClose, onDone, defaultDice }) { const [selectedDice, setSelectedDice] = useState(defaultDice); + const layout = useResponsiveLayout(); + return (