-
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.
- Loading branch information
Showing
9 changed files
with
202 additions
and
13 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
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
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
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
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,28 @@ | ||
.guess { | ||
display: flex; | ||
margin: auto; | ||
justify-content: center; | ||
gap: 5px; | ||
margin: 10px auto; | ||
} | ||
|
||
.empty-letter-box { | ||
display: flex; | ||
align-items: center; | ||
justify-content: center; | ||
border: 2px solid var(--gray); | ||
width: 30px; | ||
height: 30px; | ||
margin: 0; | ||
} | ||
|
||
.guess-letter-box { | ||
display: flex; | ||
align-items: center; | ||
justify-content: center; | ||
border: 2px solid var(--gray); | ||
width: 30px; | ||
height: 30px; | ||
margin: 0; | ||
} | ||
|
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,56 @@ | ||
import React from "react"; | ||
import "./GameSpace.css"; | ||
|
||
function EmptyGuess() { | ||
return ( | ||
<> | ||
{Array(5) | ||
.fill("\u00A0") | ||
.map((_, i) => ( | ||
<p className="empty-letter-box" key={i}> | ||
| ||
</p> | ||
))} | ||
</> | ||
); | ||
} | ||
|
||
function PlayerGuess({ playerGuess }) { | ||
const colorMap = { | ||
0: "var(--gray)", | ||
1: "var(--yellow)", | ||
2: "var(--green)", | ||
3: "var(--dark-gray)", | ||
}; | ||
|
||
return ( | ||
<> | ||
{playerGuess.map((char, i) => ( | ||
<p | ||
className="guess-letter-box" | ||
style={{ backgroundColor: colorMap[char.state] || "var(--gray)" }} | ||
key={i} | ||
> | ||
{char.char.toUpperCase()} | ||
</p> | ||
))} | ||
</> | ||
); | ||
} | ||
|
||
export function GameSpace({ playerGuesses }) { | ||
return ( | ||
<div> | ||
{[...Array(6)].map((_, i) => ( | ||
<div className="guess" key={i}> | ||
{/* Checks if the guess exists and renders it or an empty cell */} | ||
{playerGuesses[i] ? ( | ||
<PlayerGuess playerGuess={playerGuesses[i]} /> | ||
) : ( | ||
<EmptyGuess /> | ||
)} | ||
</div> | ||
))} | ||
</div> | ||
); | ||
} |
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
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
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