Skip to content

Commit a035c8e

Browse files
committed
Fix Tic Tac Toe strike alignment and improve marker styling
1 parent d02f937 commit a035c8e

3 files changed

Lines changed: 42 additions & 36 deletions

File tree

web-app/css/styles.css

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4714,13 +4714,16 @@ html[data-theme="dark"] body {
47144714
background: rgba(224,92,111,.07) !important;
47154715
animation: tttPop .22s cubic-bezier(.34,1.56,.64,1) !important;
47164716
cursor: default !important;
4717+
font-weight: 800 !important;
4718+
47174719
}
47184720
.ttt-wrap .ttt-cell--o {
47194721
color: var(--ttt-o) !important;
47204722
border-color: rgba(59,184,214,.3) !important;
47214723
background: rgba(59,184,214,.07) !important;
47224724
animation: tttPop .22s cubic-bezier(.34,1.56,.64,1) !important;
47234725
cursor: default !important;
4726+
font-weight: 800 !important;
47244727
}
47254728
.ttt-wrap .ttt-cell--win {
47264729
animation: tttWin .45s ease forwards !important;
@@ -4743,13 +4746,14 @@ html[data-theme="dark"] body {
47434746
.ttt-win-svg {
47444747
position: absolute;
47454748
inset: 0;
4746-
width: 100%;
4747-
height: 100%;
4749+
width: calc(100% + 8px);
4750+
height: calc(100% + 8px);
47484751
pointer-events: none;
47494752
overflow: visible;
47504753
opacity: 0;
47514754
transition: opacity .25s;
47524755
z-index: 2;
4756+
display: block;
47534757
}
47544758
.ttt-win-svg--visible { opacity: 1; }
47554759
#ttt-win-line {

web-app/js/projects.js

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2962,7 +2962,9 @@ function getTicTacToeHTML() {
29622962
</div>
29632963
29642964
<!-- Board -->
2965-
<div class="ttt-board" id="ttt-board">
2965+
<div style="position:relative;">
2966+
<div id="ttt-board">
2967+
29662968
${[0,1,2,3,4,5,6,7,8].map(i =>
29672969
`<button class="ttt-cell" data-i="${i}" aria-label="Cell ${i+1}"></button>`
29682970
).join('')}
@@ -2974,7 +2976,7 @@ function getTicTacToeHTML() {
29742976
stroke="var(--ttt-accent)" stroke-width="0.18"
29752977
stroke-linecap="round" opacity="0"/>
29762978
</svg>
2977-
2979+
</div>
29782980
<!-- Result overlay -->
29792981
<div class="ttt-result-overlay" id="ttt-result-overlay" style="display:none">
29802982
<div class="ttt-result-card">
@@ -3186,7 +3188,7 @@ function initTicTacToe() {
31863188

31873189
function refreshTurnBanner() {
31883190
const name = current === "X" ? p1 : p2;
3189-
const sym = current === "X" ? "" : "";
3191+
const sym = current === "X" ? "X" : "O";
31903192
const symEl = document.getElementById("ttt-turn-sym");
31913193
const nameEl = document.getElementById("ttt-turn-name");
31923194
const banner = document.getElementById("ttt-turn-banner");
@@ -3214,7 +3216,7 @@ function initTicTacToe() {
32143216
board[i] = sym;
32153217
const cell = document.querySelector(`.ttt-cell[data-i="${i}"]`);
32163218
if (!cell) return;
3217-
cell.textContent = sym === "X" ? "❌" : "⭕";
3219+
cell.textContent = sym;
32183220
cell.classList.add(sym === "X" ? "ttt-cell--x" : "ttt-cell--o");
32193221
cell.disabled = true;
32203222
}
@@ -3299,18 +3301,18 @@ function initTicTacToe() {
32993301
// ── Win-line SVG ──
33003302
// Grid cells are (col, row) 0-indexed; centre of cell = col+0.5, row+0.5
33013303
function drawWinLine(comboIdx) {
3302-
const line = document.getElementById("ttt-win-line");
3303-
const svg = document.getElementById("ttt-win-svg");
3304-
if (!line || !svg) return;
3305-
3306-
const [[c1,r1],[c2,r2]] = WIN_COORDS[comboIdx];
3307-
line.setAttribute("x1", c1 + 0.5);
3308-
line.setAttribute("y1", r1 + 0.5);
3309-
line.setAttribute("x2", c2 + 0.5);
3310-
line.setAttribute("y2", r2 + 0.5);
3311-
line.setAttribute("opacity", "1");
3312-
svg.classList.add("ttt-win-svg--visible");
3313-
}
3304+
const line = document.getElementById("ttt-win-line");
3305+
const svg = document.getElementById("ttt-win-svg");
3306+
if (!line || !svg) return;
3307+
3308+
const [[c1,r1],[c2,r2]] = WIN_COORDS[comboIdx];
3309+
line.setAttribute("x1", c1 + 0.5);
3310+
line.setAttribute("y1", r1 + 0.5);
3311+
line.setAttribute("x2", c2 + 0.5);
3312+
line.setAttribute("y2", r2 + 0.5);
3313+
line.setAttribute("opacity", "1");
3314+
svg.classList.add("ttt-win-svg--visible");
3315+
}
33143316

33153317
function clearWinLine() {
33163318
const line = document.getElementById("ttt-win-line");

web-app/js/projects/tic-tac-toe.js

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,8 @@ function getTicTacToeHTML() {
8888
</div>
8989
9090
<!-- Board -->
91-
<div class="ttt-board" id="ttt-board">
91+
<div style="position:relative;">
92+
<div id="ttt-board">
9293
${[0,1,2,3,4,5,6,7,8].map(i =>
9394
`<button class="ttt-cell" data-i="${i}" aria-label="Cell ${i+1}"></button>`
9495
).join('')}
@@ -100,7 +101,7 @@ function getTicTacToeHTML() {
100101
stroke="var(--ttt-accent)" stroke-width="0.18"
101102
stroke-linecap="round" opacity="0"/>
102103
</svg>
103-
104+
</div>
104105
<!-- Result overlay -->
105106
<div class="ttt-result-overlay" id="ttt-result-overlay" style="display:none">
106107
<div class="ttt-result-card">
@@ -314,7 +315,7 @@ function initTicTacToe() {
314315

315316
function refreshTurnBanner() {
316317
const name = current === "X" ? p1 : p2;
317-
const sym = current === "X" ? "" : "";
318+
const sym = current === "X" ? "X" : "O";
318319
const symEl = document.getElementById("ttt-turn-sym");
319320
const nameEl = document.getElementById("ttt-turn-name");
320321
const banner = document.getElementById("ttt-turn-banner");
@@ -342,7 +343,7 @@ function initTicTacToe() {
342343
board[i] = sym;
343344
const cell = document.querySelector(`.ttt-cell[data-i="${i}"]`);
344345
if (!cell) return;
345-
cell.textContent = sym === "X" ? "❌" : "⭕";
346+
cell.textContent = sym;
346347
cell.classList.add(sym === "X" ? "ttt-cell--x" : "ttt-cell--o");
347348
cell.disabled = true;
348349
}
@@ -427,20 +428,19 @@ function initTicTacToe() {
427428
// ── Win-line SVG ──
428429
// Grid cells are (col, row) 0-indexed; centre of cell = col+0.5, row+0.5
429430
function drawWinLine(comboIdx) {
430-
const line = document.getElementById("ttt-win-line");
431-
const svg = document.getElementById("ttt-win-svg");
432-
if (!line || !svg) return;
433-
434-
const [[c1,r1],[c2,r2]] = WIN_COORDS[comboIdx];
435-
line.setAttribute("x1", c1 + 0.5);
436-
line.setAttribute("y1", r1 + 0.5);
437-
line.setAttribute("x2", c2 + 0.5);
438-
line.setAttribute("y2", r2 + 0.5);
439-
line.setAttribute("opacity", "1");
440-
svg.classList.add("ttt-win-svg--visible");
441-
}
442-
443-
function clearWinLine() {
431+
const line = document.getElementById("ttt-win-line");
432+
const svg = document.getElementById("ttt-win-svg");
433+
if (!line || !svg) return;
434+
435+
const [[c1,r1],[c2,r2]] = WIN_COORDS[comboIdx];
436+
line.setAttribute("x1", c1 + 0.5);
437+
line.setAttribute("y1", r1 + 0.5);
438+
line.setAttribute("x2", c2 + 0.5);
439+
line.setAttribute("y2", r2 + 0.5);
440+
line.setAttribute("opacity", "1");
441+
svg.classList.add("ttt-win-svg--visible");
442+
}
443+
function clearWinLine() {
444444
const line = document.getElementById("ttt-win-line");
445445
const svg = document.getElementById("ttt-win-svg");
446446
if (line) line.setAttribute("opacity","0");

0 commit comments

Comments
 (0)