Skip to content

Commit

Permalink
Better hover colors
Browse files Browse the repository at this point in the history
  • Loading branch information
7ingyu committed Dec 2, 2023
1 parent 55cfc20 commit 9361e3e
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 10 deletions.
27 changes: 23 additions & 4 deletions src/App.css
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ table, td, th {
position: relative;
background-color: blue;
margin-bottom: 0.25rem;
border-radius: 0.25rem;
}

.gamecell > button {
Expand All @@ -47,18 +48,36 @@ table, td, th {
border: none;
}

.gamecell > button:hover {
background-color: palegoldenrod;
.row.red > .gamecell > button:hover:not([disabled]) {
background-color: rgb(255, 197, 197);
}

.row.yellow > .gamecell > button:hover:not([disabled]) {
background-color: rgb(255, 255, 205);
}

.gamecell > button.yellow {
background-color: yellow;
background-color: rgb(255, 255, 130);
}

.gamecell > button.red {
background-color: red;
background-color: rgb(255, 106, 106);
}

.msg {
margin-bottom: 0.5rem;
background-color: blue;
padding: 0.5rem;
color: white;
border-radius: 0.25rem;
}

.msg.red {
font-weight: bold;
color: rgb(255, 106, 106);
}

.msg.yellow {
font-weight: bold;
color: yellow;
}
5 changes: 2 additions & 3 deletions src/components/Board.jsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { useState, useEffect } from 'react';
import getWinner from '../utils/detectWin';

import Cell from './Cell'

export default function Board (
Expand Down Expand Up @@ -56,10 +55,10 @@ export default function Board (

return (
<>
<div className="msg">{msg}</div>
<div className={`msg${frozen && turn ? turn === 2 ? ' red' : turn === 1 ? ' yellow' : '' : ''}`}>{msg}</div>
<div className="gameboard">
{board.map((row, r) => (
<div className="row" key={`row-${r}`}>
<div className={`row ${turn === 1 ? 'red' : turn === 2 ? 'yellow' : ''}`} key={`row-${r}`}>
{row.map((cell, c) =>
<Cell
key={`cell-${r}-${c}`}
Expand Down
6 changes: 3 additions & 3 deletions src/utils/detectWin.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
export default function detectWin (board) {
// horizontals
console.log('checking horizontals')
// console.log('checking horizontals')
for (let r = 0; r < board.length; r++) {
let count = 0
let player = 0
Expand All @@ -20,7 +20,7 @@ export default function detectWin (board) {
}

// verticals
console.log('checking verticals')
// console.log('checking verticals')
for (let c = 0; c < board[0].length; c++) {
let count = 0
let player = 0
Expand All @@ -39,7 +39,7 @@ export default function detectWin (board) {
}

// diagonals
console.log('checking diagonals')
// console.log('checking diagonals')
let startRow = 0
while (startRow < 4) {
let count = 0
Expand Down

0 comments on commit 9361e3e

Please sign in to comment.