Skip to content

Commit 2b79a80

Browse files
authored
Make moving cards background transparent (#183)
1 parent 5b7ff22 commit 2b79a80

File tree

1 file changed

+23
-9
lines changed

1 file changed

+23
-9
lines changed

src/components/Game.js

Lines changed: 23 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,28 @@ import { useContext, useEffect, useMemo, useState } from "react";
33
import Divider from "@material-ui/core/Divider";
44
import Paper from "@material-ui/core/Paper";
55
import Typography from "@material-ui/core/Typography";
6-
import { animated, useTransition } from "@react-spring/web";
6+
import { makeStyles } from "@material-ui/core/styles";
7+
import { animated, to, useTransition } from "@react-spring/web";
78

89
import ResponsiveSetCard from "../components/ResponsiveSetCard";
910
import { SettingsContext } from "../context";
1011
import useDimensions from "../hooks/useDimensions";
1112
import useKeydown, { getModifierState } from "../hooks/useKeydown";
1213

14+
const useStyles = makeStyles({
15+
staticCard: {
16+
position: "absolute",
17+
},
18+
movingCard: {
19+
position: "absolute",
20+
pointerEvents: "none",
21+
zIndex: 1,
22+
"& > div": {
23+
backgroundColor: "transparent !important",
24+
},
25+
},
26+
});
27+
1328
const gamePadding = 8;
1429

1530
function addLastSet(board, lastSet) {
@@ -36,6 +51,7 @@ function Game({
3651
showShortcuts,
3752
remaining = -1,
3853
}) {
54+
const classes = useStyles();
3955
const { keyboardLayout, layoutOrientation, cardOrientation } =
4056
useContext(SettingsContext);
4157
const isHorizontal = cardOrientation === "horizontal";
@@ -229,14 +245,12 @@ function Game({
229245
card && (
230246
<animated.div
231247
key={card}
232-
style={{
233-
position: "absolute",
234-
zIndex: style.opacity.to((x) => (x === 1 ? "auto" : 1)),
235-
pointerEvents: style.opacity.to((x) =>
236-
x === 1 ? "auto" : "none"
237-
),
238-
...style,
239-
}}
248+
className={to([style.left, style.top], () =>
249+
style.left.idle && style.top.idle
250+
? classes.staticCard
251+
: classes.movingCard
252+
)}
253+
style={style}
240254
>
241255
{showShortcuts ? (
242256
<div

0 commit comments

Comments
 (0)