forked from b00tc4mp/eurofirms-bootcamp-202402
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add minesweeper to shapes, fix tic-tac-toe b00tc4mp#200
- Loading branch information
Showing
5 changed files
with
85 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
function App() { | ||
const matrix = new Array(8) | ||
|
||
for (let i = 0; i < matrix.length; i++) { | ||
const cell = { | ||
isBomb: false, | ||
isClicked: false, | ||
bombAside: 0, | ||
} | ||
|
||
matrix[i] = new Array(8).fill(cell) | ||
} | ||
|
||
const [board, setBoard] = React.useState(matrix) | ||
|
||
return <> | ||
<header>Mine Sweeper</header> | ||
<main> | ||
<div className="board" style={{ | ||
gridTemplate: `repeat(${matrix.length},1fr) / repeat(${matrix.length},1fr) ` | ||
}} | ||
> | ||
{board.map((row, i) => row.map((cell, j) => <div key={`${i}-${j}`} className={cell.isClicked ? 'clicked-cell' : 'no-clicked-cell'}> | ||
<button className="cell-button" onClick={() => handleCellClick(i, j)}></button> | ||
</div> | ||
)).flat(Infinity)} | ||
</div> | ||
|
||
</main> | ||
<footer></footer> | ||
</> | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
.board { | ||
display: grid; | ||
border: 2px solid black; | ||
width: 400px; | ||
height: 400px; | ||
gap: 1px; | ||
} | ||
|
||
.clicked-cell { | ||
background-color: transparent; | ||
} | ||
|
||
.no-clicked-cell { | ||
background-color: gray; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
|
||
<head> | ||
<meta charset="UTF-8"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
<title>Mine sweeper</title> | ||
<link rel="stylesheet" href="index.css"> | ||
</head> | ||
|
||
<body> | ||
<div id="root"></div> | ||
<script src="https://unpkg.com/react@18/umd/react.development.js" crossorigin></script> | ||
<script src="https://unpkg.com/react-dom@18/umd/react-dom.development.js" crossorigin></script> | ||
|
||
<script src="https://cdnjs.cloudflare.com/ajax/libs/babel-standalone/7.24.3/babel.min.js" | ||
integrity="sha512-ew/qzOMK7mnWiZ395TTbZ+YVD6e7dOROUcXXzSjyxPmL9oNf5gp8DJp46uarrTKch5aUhR/NS8qtCh6hnaTMCw==" | ||
crossorigin="anonymous" referrerpolicy="no-referrer"></script> | ||
|
||
<script src="App.jsx" type="text/babel"></script> | ||
<script src="index.jsx" type="text/babel"></script> | ||
|
||
</body> | ||
|
||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
const root = ReactDOM.createRoot(document.querySelector('#root')) | ||
|
||
root.render(<App />) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters