diff --git a/src/components/Cell/Cell.module.css b/src/components/Cell/Cell.module.css
index 5f008ed..06de68a 100644
--- a/src/components/Cell/Cell.module.css
+++ b/src/components/Cell/Cell.module.css
@@ -21,7 +21,7 @@
border: var(--border-width) solid var(--border-color);
}
- .cell[data-status='empty'] & {
+ .cell[data-status='all_match'] & {
border: var(--border-width) dotted var(--border-color);
}
diff --git a/src/components/Cell/Cell.tsx b/src/components/Cell/Cell.tsx
index a760a16..79aaf29 100644
--- a/src/components/Cell/Cell.tsx
+++ b/src/components/Cell/Cell.tsx
@@ -1,64 +1,30 @@
-import { useEffect, useState } from 'react';
-import { CellStatus, GameCell } from '@/globals';
-import { getMatches } from '@/helpers/game.helpers';
+import { CellStatus } from '@/globals';
+
import { AnimatePresence, motion } from 'motion/react';
import VisuallyHidden from '../VisuallyHidden';
import styles from './Cell.module.css';
+import { staggeredScaleRotate } from './animations';
type CellProps = {
id: string;
- disabled: boolean;
status: CellStatus;
pieces: string[];
- previous: GameCell | undefined;
- updateCellsState: (id: string, matches?: string[]) => void;
+ onClick: (id: string) => void;
};
-function Cell({
- id,
- disabled,
- status,
- pieces,
- previous,
- updateCellsState,
-}: CellProps) {
- const [showNoMatch, setShowNoMatch] = useState(false);
-
- useEffect(() => {
- if (setShowNoMatch) {
- const timerId = setTimeout(() => {
- setShowNoMatch(false);
- }, 2500);
- return () => clearTimeout(timerId);
- }
- }, [showNoMatch]);
-
- function handleClick() {
- // do nothing if same cell is clicked twice OR game is over
- if (status === 'active' || disabled) return;
-
- // only one cell has been clicked, comparison can't be run
- if (!previous) {
- updateCellsState(id);
- return;
- }
-
- const matches = getMatches(previous.pieces, pieces);
- if (matches.length === 0) {
- setShowNoMatch(true);
- }
-
- updateCellsState(id, matches);
- }
+function Cell({ id, status, pieces, onClick }: CellProps) {
+ const showNoMatch = status === 'no_match';
return (
-
+
{showNoMatch &&
no match
}
-