Added hover to some components
parent
3084365cf7
commit
1b5bae32a7
29
src/App.jsx
29
src/App.jsx
|
|
@ -51,8 +51,14 @@ export default function App() {
|
||||||
|
|
||||||
function Field({ row, col, style, disabled }) {
|
function Field({ row, col, style, disabled }) {
|
||||||
const [pointer, setPointer] = useState(false);
|
const [pointer, setPointer] = useState(false);
|
||||||
|
const [color, setColor] = useState("white");
|
||||||
|
|
||||||
const styling = {
|
const styling = {
|
||||||
backgroundColor: style.backgroundColor,
|
backgroundColor: !pointer
|
||||||
|
? style.backgroundColor
|
||||||
|
: params.currentPlayer === "red" && row === 0
|
||||||
|
? color
|
||||||
|
: params.currentPlayer === "yellow" && row === 0 && color,
|
||||||
cursor: pointer && "pointer",
|
cursor: pointer && "pointer",
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -62,13 +68,28 @@ function Field({ row, col, style, disabled }) {
|
||||||
row={row}
|
row={row}
|
||||||
col={col}
|
col={col}
|
||||||
style={styling}
|
style={styling}
|
||||||
onClick={() => clickHandlerTurn(col, params)}
|
onClick={async () => {
|
||||||
|
await clickHandlerTurn(col, params);
|
||||||
|
if (params.gamemode === 2) {
|
||||||
|
params.currentPlayer === "red"
|
||||||
|
? setColor("lightcoral")
|
||||||
|
: setColor("#f2f28d");
|
||||||
|
}
|
||||||
|
}}
|
||||||
disabled={disabled}
|
disabled={disabled}
|
||||||
onMouseEnter={() => {
|
onMouseEnter={() => {
|
||||||
!disabled && !params.gameOver && setPointer(true);
|
params.gameOver && setPointer(false);
|
||||||
|
|
||||||
|
if (!disabled && !params.gameOver) {
|
||||||
|
setPointer(true);
|
||||||
|
}
|
||||||
|
params.currentPlayer === "red"
|
||||||
|
? setColor("lightcoral")
|
||||||
|
: setColor("#f2f28d");
|
||||||
}}
|
}}
|
||||||
onMouseLeave={() => {
|
onMouseLeave={() => {
|
||||||
params.gameOver && setPointer(false);
|
setColor(style.backgroundColor);
|
||||||
|
setPointer(false);
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -96,6 +96,16 @@ function botChoice(colorBoard) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function colFull(col, colorBoard) {
|
||||||
|
for (let row = 5; row >= 0; row--) {
|
||||||
|
if (colorBoard[row][col] === "white") {
|
||||||
|
return false;
|
||||||
|
} else {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
export async function clickHandlerTurn(col, params) {
|
export async function clickHandlerTurn(col, params) {
|
||||||
const iMax = params.gamemode === 1 ? 2 : 1;
|
const iMax = params.gamemode === 1 ? 2 : 1;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -77,4 +77,12 @@ body {
|
||||||
|
|
||||||
.message {
|
.message {
|
||||||
font-size: larger;
|
font-size: larger;
|
||||||
|
}
|
||||||
|
|
||||||
|
.heading{
|
||||||
|
transition: font-size 1s ease-out 100ms;
|
||||||
|
}
|
||||||
|
|
||||||
|
.heading:hover{
|
||||||
|
font-size:3em;
|
||||||
}
|
}
|
||||||
Loading…
Reference in New Issue