Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 23 additions & 9 deletions src/components/Game.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,28 @@ import { useContext, useEffect, useMemo, useState } from "react";
import Divider from "@material-ui/core/Divider";
import Paper from "@material-ui/core/Paper";
import Typography from "@material-ui/core/Typography";
import { animated, useTransition } from "@react-spring/web";
import { makeStyles } from "@material-ui/core/styles";
import { animated, to, useTransition } from "@react-spring/web";

import ResponsiveSetCard from "../components/ResponsiveSetCard";
import { SettingsContext } from "../context";
import useDimensions from "../hooks/useDimensions";
import useKeydown, { getModifierState } from "../hooks/useKeydown";

const useStyles = makeStyles({
staticCard: {
position: "absolute",
},
movingCard: {
position: "absolute",
pointerEvents: "none",
zIndex: 1,
"& > div": {
backgroundColor: "transparent !important",
},
},
});

const gamePadding = 8;

function addLastSet(board, lastSet) {
Expand All @@ -36,6 +51,7 @@ function Game({
showShortcuts,
remaining = -1,
}) {
const classes = useStyles();
const { keyboardLayout, layoutOrientation, cardOrientation } =
useContext(SettingsContext);
const isHorizontal = cardOrientation === "horizontal";
Expand Down Expand Up @@ -229,14 +245,12 @@ function Game({
card && (
<animated.div
key={card}
style={{
position: "absolute",
zIndex: style.opacity.to((x) => (x === 1 ? "auto" : 1)),
pointerEvents: style.opacity.to((x) =>
x === 1 ? "auto" : "none"
),
...style,
}}
className={to([style.left, style.top], () =>
style.left.idle && style.top.idle
? classes.staticCard
: classes.movingCard
)}
style={style}
>
{showShortcuts ? (
<div
Expand Down