From 52fe1508d4b19fb99f8a105e4663e9fcc0ac2301 Mon Sep 17 00:00:00 2001 From: Amal Date: Wed, 26 Apr 2023 12:18:04 +0530 Subject: [PATCH 1/2] test --- src/pages/FloodFill/index.js | 230 ++++++++++++++++++++--------------- 1 file changed, 129 insertions(+), 101 deletions(-) diff --git a/src/pages/FloodFill/index.js b/src/pages/FloodFill/index.js index 1c7e4f4..dba2ca5 100644 --- a/src/pages/FloodFill/index.js +++ b/src/pages/FloodFill/index.js @@ -1,109 +1,137 @@ - -import React, { useState, useEffect } from 'react' -import './FloodFill.css' -import { startFloodFill } from './algorithm' -import Container from '../../components/Container/index' -import Menu from '../../components/Menu/index' -import { ReactComponent as GithubLogo } from '../../images/github-logo.svg'; +import React, { useState, useEffect } from "react"; +import "./FloodFill.css"; +import { startFloodFill } from "./algorithm"; +import Container from "../../components/Container/index"; +import Menu from "../../components/Menu/index"; +import { ReactComponent as GithubLogo } from "../../images/github-logo.svg"; const FloodFill = () => { - const [image, setImage] = useState([[]]) - const [flooding, setFlooding] = useState(false) - const [fillType, setFillType] = useState("RANDOM") - const [dimension, setDimension] = useState(20) - const [connectedNeighbours, setConnectedNeighbours] = useState(4) + const [image, setImage] = useState([[]]); + const [flooding, setFlooding] = useState(false); + const [fillType, setFillType] = useState("RANDOM"); + const [dimension, setDimension] = useState(20); + const [connectedNeighbours, setConnectedNeighbours] = useState(4); - const onDimensionChange = (size) => { - let row = [], newImage = [] - for (let index = 0; index < size; index++) { - row = [] - for (let index = 0; index < size; index++) { - row[index] = fillType === "RANDOM" ? (Math.round(Math.random()) ? "#000" : "red") : "red" - } - newImage[index] = row - } - setImage(newImage) + const onDimensionChange = (size) => { + let row = [], + newImage = []; + for (let index = 0; index < size; index++) { + row = []; + for (let index = 0; index < size; index++) { + row[index] = + fillType === "RANDOM" + ? Math.round(Math.random()) + ? "#000" + : "red" + : "red"; + } + newImage[index] = row; } + setImage(newImage); + }; - useEffect(() => { - onDimensionChange(dimension) - }, [dimension, fillType]) + useEffect(() => { + onDimensionChange(dimension); + }, [dimension, fillType]); - const onCellClick = async (a, b) => { - if (flooding) return - setFlooding(true) - const finish = await startFloodFill(JSON.parse(JSON.stringify(image)), image[a][b] === "white" ? "#0cff0c" : "white", image[a][b], [a, b], setImage, Number(connectedNeighbours)) - if (finish) { - setFlooding(false) - } + const onCellClick = async (a, b) => { + if (flooding) return; + setFlooding(true); + const finish = await startFloodFill( + JSON.parse(JSON.stringify(image)), + image[a][b] === "white" ? "#0cff0c" : "white", + image[a][b], + [a, b], + setImage, + Number(connectedNeighbours) + ); + if (finish) { + setFlooding(false); } - return ( - <> - -

- Flood Fill -

-

Click on a tile to start.

-
- - {image.map((row, a) => {row.map((cellColor, b) => )})} -
{ - onCellClick(a, b) - }}>
-
- {flooding &&

Flooding...

} -
- {!flooding && -
- - -
-
- - -
-
- - -
-
- - - -
-
- -
-
} - - ) -} + }; + return ( + <> + +

Flood Fill

+

Click on a tile to start.

+
+ + {image.map((row, a) => ( + + {row.map((cellColor, b) => ( + + ))} + + ))} +
{ + onCellClick(a, b); + }} + >
+
+ {flooding &&

Flooding...

} +
+ {!flooding && ( + +
+ + +
+
+ + +
+
+ + +
+
+ + + +
+
+ +
+
+ )} + + ); +}; -export default FloodFill \ No newline at end of file +export default FloodFill; From 59f3f645d52a81ff4963b02d10c6f49260f87444 Mon Sep 17 00:00:00 2001 From: Amal Date: Wed, 26 Apr 2023 12:20:04 +0530 Subject: [PATCH 2/2] test --- .github/workflows/test.yml | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 .github/workflows/test.yml diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..908e754 --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,2 @@ +- name: Check Signed Commits in PR + uses: 1Password/check-signed-commits-action@v1