Skip to content

Commit 8ec824b

Browse files
author
Dan Ames
committed
Sudoku Tiles: gray dot on starting tiles, gray out locked colors in keyboard
Made-with: Cursor
1 parent 586ff2c commit 8ec824b

1 file changed

Lines changed: 23 additions & 12 deletions

File tree

games/sudoku_tiles/index.html

Lines changed: 23 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -92,20 +92,27 @@
9292
position: relative;
9393
}
9494

95-
.tile.locked::after {
95+
.tile.given::after {
9696
content: '';
9797
position: absolute;
9898
top: 50%;
9999
left: 50%;
100100
transform: translate(-50%, -50%);
101-
width: 25%;
102-
height: 25%;
103-
min-width: 4px;
104-
min-height: 4px;
105-
background: #000;
101+
width: 20%;
102+
height: 20%;
103+
min-width: 3px;
104+
min-height: 3px;
105+
background: #787878;
106106
border-radius: 50%;
107107
}
108108

109+
.key-btn.locked {
110+
opacity: 0.35;
111+
filter: grayscale(0.6);
112+
cursor: default;
113+
pointer-events: none;
114+
}
115+
109116
.keyboard {
110117
display: flex;
111118
align-items: center;
@@ -243,7 +250,7 @@ <h1>Sudoku Tiles</h1>
243250

244251
<footer class="footer">
245252
<p class="footer-instructions">
246-
Tap a color or X to select, then tap a cell to place or delete. When all 9 tiles of a color are correct, they lock (black dot).
253+
Tap a color or X to select, then tap a cell to place or delete. Starting tiles have a gray dot. When all 9 tiles of a color are correct, that color grays out in the keyboard.
247254
</p>
248255
<p><a href="../../justforfun.html">Return to Dan Ames Just for Fun Page</a></p>
249256
<p class="footer-legal">
@@ -272,7 +279,6 @@ <h2>Congratulations!</h2>
272279
function renderBoard() {
273280
board.innerHTML = '';
274281
const grid = SudokuTiles.getGrid();
275-
const locked = SudokuTiles.getLockedColors();
276282

277283
for (let r = 0; r < 9; r++) {
278284
for (let c = 0; c < 9; c++) {
@@ -286,7 +292,7 @@ <h2>Congratulations!</h2>
286292
const tile = document.createElement('div');
287293
tile.className = 'tile';
288294
tile.style.backgroundColor = SudokuTiles.getColor(val);
289-
if (locked.has(val)) tile.classList.add('locked');
295+
if (SudokuTiles.isGiven(r, c)) tile.classList.add('given');
290296
cell.appendChild(tile);
291297
}
292298

@@ -314,14 +320,18 @@ <h2>Congratulations!</h2>
314320
deleteBtn.addEventListener('click', (e) => { e.preventDefault(); selectTool('delete'); });
315321
keyboard.appendChild(deleteBtn);
316322

323+
const locked = SudokuTiles.getLockedColors();
317324
const colors = SudokuTiles.getColors();
318325
colors.forEach((color, i) => {
319326
const btn = document.createElement('button');
320327
btn.type = 'button';
321-
btn.className = 'key-btn' + (selectedTool === i + 1 ? ' selected' : '');
328+
const value = i + 1;
329+
btn.className = 'key-btn' + (selectedTool === value ? ' selected' : '') + (locked.has(value) ? ' locked' : '');
322330
btn.style.backgroundColor = color;
323-
btn.dataset.tool = i + 1;
324-
btn.addEventListener('click', (e) => { e.preventDefault(); selectTool(i + 1); });
331+
btn.dataset.tool = value;
332+
if (!locked.has(value)) {
333+
btn.addEventListener('click', (e) => { e.preventDefault(); selectTool(value); });
334+
}
325335
keyboard.appendChild(btn);
326336
});
327337
}
@@ -341,6 +351,7 @@ <h2>Congratulations!</h2>
341351
SudokuTiles.placeTile(row, col, selectedTool);
342352
}
343353
renderBoard();
354+
renderKeyboard();
344355

345356
if (SudokuTiles.isComplete()) {
346357
winOverlay.classList.add('visible');

0 commit comments

Comments
 (0)