milsaware/wordled

Redundant colors in keyboard.className

Closed this issue · 1 comments

Monty commented

When my simple change to use 3 keyboard colors didn't work, I sniffed around the code used to color keys.

While this works for two colors, it doesn't look like best practice to me, even though I don't know much abut Javascript.

keyboard.className += ' blockGreen';
keyboard.className = keyboardKey_s blockGreen blockGreen blockGreen blockGreen

I've updated the game.js to check if the classNames don't exist before setting them so they're not set multiple times. One way to add in the extra colours on the keyboard would be to check to see if the letters are in identical places, same as how the board does it, if they're not then change the class to blockGold if it's not already blockGreen