Fixed dice select double click select and scaling
This commit is contained in:
parent
2e404b24e0
commit
c9993605c4
@ -55,11 +55,7 @@ function Tile({
|
|||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
onSelect();
|
onSelect();
|
||||||
}}
|
}}
|
||||||
onDoubleClick={(e) => {
|
onDoubleClick={onDoubleClick}
|
||||||
if (canEdit) {
|
|
||||||
onDoubleClick(e);
|
|
||||||
}
|
|
||||||
}}
|
|
||||||
>
|
>
|
||||||
<UIImage
|
<UIImage
|
||||||
sx={{
|
sx={{
|
||||||
|
@ -2,7 +2,7 @@ import React from "react";
|
|||||||
|
|
||||||
import Tile from "../Tile";
|
import Tile from "../Tile";
|
||||||
|
|
||||||
function DiceTile({ dice, isSelected, onDiceSelect, onDone, large }) {
|
function DiceTile({ dice, isSelected, onDiceSelect, onDone, size }) {
|
||||||
return (
|
return (
|
||||||
<Tile
|
<Tile
|
||||||
src={dice.preview}
|
src={dice.preview}
|
||||||
@ -10,7 +10,7 @@ function DiceTile({ dice, isSelected, onDiceSelect, onDone, large }) {
|
|||||||
isSelected={isSelected}
|
isSelected={isSelected}
|
||||||
onSelect={() => onDiceSelect(dice)}
|
onSelect={() => onDiceSelect(dice)}
|
||||||
onDoubleClick={() => onDone(dice)}
|
onDoubleClick={() => onDone(dice)}
|
||||||
large={large}
|
size={size}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -1,21 +1,27 @@
|
|||||||
import React from "react";
|
import React from "react";
|
||||||
import { Flex } from "theme-ui";
|
import { Flex } from "theme-ui";
|
||||||
import SimpleBar from "simplebar-react";
|
import SimpleBar from "simplebar-react";
|
||||||
import { useMedia } from "react-media";
|
|
||||||
|
|
||||||
import DiceTile from "./DiceTile";
|
import DiceTile from "./DiceTile";
|
||||||
|
|
||||||
|
import useResponsiveLayout from "../../hooks/useResponsiveLayout";
|
||||||
|
|
||||||
function DiceTiles({ dice, onDiceSelect, selectedDice, onDone }) {
|
function DiceTiles({ dice, onDiceSelect, selectedDice, onDone }) {
|
||||||
const isSmallScreen = useMedia({ query: "(max-width: 500px)" });
|
const layout = useResponsiveLayout();
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<SimpleBar style={{ maxHeight: "300px" }}>
|
<SimpleBar
|
||||||
|
style={{ height: layout.screenSize === "large" ? "600px" : "400px" }}
|
||||||
|
>
|
||||||
<Flex
|
<Flex
|
||||||
p={2}
|
p={2}
|
||||||
|
pb={4}
|
||||||
bg="muted"
|
bg="muted"
|
||||||
sx={{
|
sx={{
|
||||||
flexWrap: "wrap",
|
flexWrap: "wrap",
|
||||||
borderRadius: "4px",
|
borderRadius: "4px",
|
||||||
|
minHeight: layout.screenSize === "large" ? "600px" : "400px",
|
||||||
|
alignContent: "flex-start",
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{dice.map((dice) => (
|
{dice.map((dice) => (
|
||||||
@ -25,7 +31,7 @@ function DiceTiles({ dice, onDiceSelect, selectedDice, onDone }) {
|
|||||||
isSelected={selectedDice && dice.key === selectedDice.key}
|
isSelected={selectedDice && dice.key === selectedDice.key}
|
||||||
onDiceSelect={onDiceSelect}
|
onDiceSelect={onDiceSelect}
|
||||||
onDone={onDone}
|
onDone={onDone}
|
||||||
large={isSmallScreen}
|
size={layout.tileSize}
|
||||||
/>
|
/>
|
||||||
))}
|
))}
|
||||||
</Flex>
|
</Flex>
|
||||||
|
@ -29,7 +29,7 @@ function MapTile({
|
|||||||
isSelected={isSelected}
|
isSelected={isSelected}
|
||||||
onSelect={() => onMapSelect(map)}
|
onSelect={() => onMapSelect(map)}
|
||||||
onEdit={() => onMapEdit(map.id)}
|
onEdit={() => onMapEdit(map.id)}
|
||||||
onDoubleClick={onDone}
|
onDoubleClick={() => canEdit && onDone()}
|
||||||
size={size}
|
size={size}
|
||||||
canEdit={canEdit}
|
canEdit={canEdit}
|
||||||
badges={badges}
|
badges={badges}
|
||||||
|
@ -6,13 +6,17 @@ import DiceTiles from "../components/dice/DiceTiles";
|
|||||||
|
|
||||||
import { dice } from "../dice";
|
import { dice } from "../dice";
|
||||||
|
|
||||||
|
import useResponsiveLayout from "../hooks/useResponsiveLayout";
|
||||||
|
|
||||||
function SelectDiceModal({ isOpen, onRequestClose, onDone, defaultDice }) {
|
function SelectDiceModal({ isOpen, onRequestClose, onDone, defaultDice }) {
|
||||||
const [selectedDice, setSelectedDice] = useState(defaultDice);
|
const [selectedDice, setSelectedDice] = useState(defaultDice);
|
||||||
|
const layout = useResponsiveLayout();
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Modal
|
<Modal
|
||||||
isOpen={isOpen}
|
isOpen={isOpen}
|
||||||
onRequestClose={onRequestClose}
|
onRequestClose={onRequestClose}
|
||||||
style={{ maxWidth: "542px", width: "calc(100% - 16px)" }}
|
style={{ maxWidth: layout.modalSize, width: "calc(100% - 16px)" }}
|
||||||
>
|
>
|
||||||
<Flex
|
<Flex
|
||||||
sx={{
|
sx={{
|
||||||
|
Loading…
Reference in New Issue
Block a user