Skip to content

Commit b84d48d

Browse files
committed
refactor(guess-the-word): use data attributes for styling of hints
1 parent 89e239f commit b84d48d

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

vanilla/guess-the-word/src/styles/hints.css

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,9 @@
4242
text-align: center;
4343
border-color: var(--slate-600);
4444
}
45-
.hint--correct {
45+
.hint[data-state="correct"] {
4646
border-color: var(--difficulty-easy);
4747
}
48-
.hint--wrong {
48+
.hint[data-state="wrong"] {
4949
border-color: var(--rose-600);
5050
}

vanilla/guess-the-word/src/ui/hints/add.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ export const addHint = (enteredLetter, { letterIndex, isCorrect }) => {
3232
const $allHintsLetter = $allHintsGroup.children[letterIndex];
3333

3434
$allHintsLetter.textContent = enteredLetter;
35-
$allHintsLetter.classList.add(`hint--${isCorrect ? "correct" : "wrong"}`);
35+
$allHintsLetter.setAttribute("data-state", isCorrect ? "correct" : "wrong");
3636

3737
if (isCorrect) {
3838
const $correctHintsGroup = /** @type {HTMLLIElement} */ (
@@ -41,6 +41,6 @@ export const addHint = (enteredLetter, { letterIndex, isCorrect }) => {
4141
const $correctHintsLetter = $correctHintsGroup.children[letterIndex];
4242

4343
$correctHintsLetter.textContent = enteredLetter;
44-
$correctHintsLetter.classList.add("hint--correct");
44+
$correctHintsLetter.setAttribute("data-state", "correct");
4545
}
4646
};

0 commit comments

Comments
 (0)