Skip to content

Commit

Permalink
Motion
Browse files Browse the repository at this point in the history
  • Loading branch information
ClanCo committed Nov 14, 2024
1 parent ce6ae12 commit 3d8f437
Show file tree
Hide file tree
Showing 4 changed files with 158 additions and 173 deletions.
3 changes: 1 addition & 2 deletions client/src/hooks/useGame.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import { useDojo } from "@/dojo/useDojo";
import { useEffect, useMemo } from "react";
import { useMemo } from "react";
import { getEntityIdFromKeys } from "@dojoengine/utils";
import { useComponentValue } from "@dojoengine/react";
import { Entity } from "@dojoengine/recs";
import useDeepMemo from "./useDeepMemo";
import { consoleTSLog } from "@/utils/logger";

export const useGame = ({
gameId,
Expand Down
20 changes: 7 additions & 13 deletions client/src/ui/components/BackgroundBoard.tsx
Original file line number Diff line number Diff line change
@@ -1,32 +1,26 @@
import { ReactNode } from "react";
import { motion, MotionProps } from "framer-motion";

interface BackgroundImageProps {
children: ReactNode;
imageBackground: string;
animate?: MotionProps["animate"];
initial?: MotionProps["initial"];
transition?: MotionProps["transition"];
}

const BackgroundBoard: React.FC<BackgroundImageProps> = ({
children,
imageBackground,
animate,
initial,
transition,
}) => {
return (
<div className="relative w-full grow h-full overflow-hidden">
<motion.div
className="absolute top-0 left-0 w-full h-full bg-cover bg-center bg-no-repeat"
style={{ backgroundImage: `url(${imageBackground})` }}
initial={initial || {}}
animate={animate || {}}
transition={transition || {}}
/>
{children}
</div>
<motion.div
className="absolute top-0 left-0 w-full h-full bg-cover bg-center bg-no-repeat"
style={{ backgroundImage: `url(${imageBackground})` }}
initial={initial || {}}
animate={animate || {}}
transition={transition || {}}
/>
);
};

Expand Down
12 changes: 4 additions & 8 deletions client/src/ui/components/GameBoard.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,4 @@
import React, {
useState,
useCallback,
useEffect,
useMemo,
useRef,
useLayoutEffect,
} from "react";
import React, { useState, useCallback, useEffect, useMemo } from "react";
import { Card } from "@/ui/elements/card";
import { useDojo } from "@/dojo/useDojo";
import { GameBonus } from "../containers/GameBonus";
Expand Down Expand Up @@ -195,10 +188,13 @@ const GameBoard: React.FC<GameBoardProps> = ({
useEffect(() => {
// Reset the isTxProcessing state and the bonus state when the grid changes
// meaning the tx as been processed, and the client state updated
consoleTSLog("success", "Game board is trigger");
setBonus(BonusType.None);
setBonusDescription("");
}, [initialGrid]);

consoleTSLog("info", "Rendering GameBoard component");

const memoizedInitialData = useMemo(() => {
consoleTSLog("success", "Transforming data in gameboard");
return transformDataContractIntoBlock(initialGrid);
Expand Down
Loading

0 comments on commit 3d8f437

Please sign in to comment.