css for prettier game board

main
Inga 🏳‍🌈 5 days ago
parent de52499d6f
commit e822191944
  1. 4
      src/backend/components/boardgame.tsx
  2. 6
      src/backend/main/index.tsx
  3. 3
      src/frontend/components/board-game.ts
  4. BIN
      src/frontend/static/o.png
  5. 55
      src/frontend/static/style.css
  6. BIN
      src/frontend/static/x.png

@ -24,7 +24,7 @@ const getCellHtml = ({
const { isDisabled, nextGameState, text } = getCellDisplayData({ gameState, currentOutcome, row, column }); const { isDisabled, nextGameState, text } = getCellDisplayData({ gameState, currentOutcome, row, column });
return ( return (
<button {...getSubmitAttributes(key, nextGameState)} disabled={isDisabled}> <button {...getSubmitAttributes(key, nextGameState)} disabled={isDisabled} className={`square-${text}`}>
{text} {text}
</button> </button>
); );
@ -55,7 +55,7 @@ export const getBoardgameHtml = (key: string, gameState: BoardgameStateType, rul
Current player: <span class="current-player-name">{gameState.currentPlayerName}</span> Current player: <span class="current-player-name">{gameState.currentPlayerName}</span>
</p> </p>
<table class="game-board"> <table class="game-board-table">
<tbody class="game-board"> <tbody class="game-board">
{sequence(gameState.rows).map((row) => ( {sequence(gameState.rows).map((row) => (
<tr> <tr>

@ -32,7 +32,7 @@ export const mainPageHandler: RequestHandler = (req, res) => {
<title>Hi</title> <title>Hi</title>
</head> </head>
<body> <body>
<section> <section class="counters">
<p> <p>
Just a small demo of progressive form and tracker web components. Just a small demo of progressive form and tracker web components.
<br /> <br />
@ -72,8 +72,8 @@ export const mainPageHandler: RequestHandler = (req, res) => {
))} ))}
</ul> </ul>
</section> </section>
<section>{board1}</section> <section class="game1">{board1}</section>
<section>{board2}</section> <section class="game2">{board2}</section>
</body> </body>
</html>, </html>,
); );

@ -74,6 +74,9 @@ export class BoardGameComponent extends HTMLElement {
if (button.innerText !== text) { if (button.innerText !== text) {
button.innerText = text; button.innerText = text;
} }
if (button.className !== `square-${text}`) {
button.className = `square-${text}`;
}
} }
} }
} }

Binary file not shown.

After

Width:  |  Height:  |  Size: 955 B

@ -1,3 +1,24 @@
body {
display: grid;
grid-template-columns: 1fr 1fr;
grid-template-rows: min-content 1fr;
grid-template-areas:
"counters counters"
"game1 game2";
}
section.counters {
grid-area: counters;
}
section.game1 {
grid-area: game1;
}
section.game2 {
grid-area: game2;
}
.counter { .counter {
font-weight: bold; font-weight: bold;
color: red; color: red;
@ -18,3 +39,37 @@ board-game:not(.game-in-progress) .when-game-in-progress,
board-game:not(.game-not-in-progress) .when-game-not-in-progress { board-game:not(.game-not-in-progress) .when-game-not-in-progress {
display: none; display: none;
} }
table.game-board-table {
border: solid 7px transparent;
border-collapse: collapse;
}
table.game-board-table tbody.game-board td {
border: solid 6px black;
padding: 3px
}
tbody.game-board button,
tbody.game-board button:disabled,
tbody.game-board button:hover {
width: 4em;
height: 4em;
border: none;
background-color: transparent;
color:transparent;
}
tbody.game-board button.square-X {
background-image: url("x.png");
background-size: 100% 100%;
}
tbody.game-board button.square-O {
background-image: url("o.png");
background-size: 100% 100%;
}
tbody.game-board button.square-_ {
cursor: pointer;
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Loading…
Cancel
Save