Skip to content

Commit

Permalink
dark mode button now changes text
Browse files Browse the repository at this point in the history
  • Loading branch information
PaulKappmeyer committed Oct 25, 2023
1 parent 6ad8aec commit d1d57b9
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion snake.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ let conatinerDiv;

let running = true;
let darkMode = false;
let darkModeButton;
const DARK_MODE_BACKGROUND = "#282828";
const DARK_MODE_TEXT_FILL = "#FFFFFF";
const LIGHT_MODE_BACKGROUND = "#FFFFFF"; //"#DCDCDC";
Expand All @@ -26,7 +27,7 @@ function setup() {

snake = new Snake();

darkModeButton = createButton("dark mode");
darkModeButton = createButton("light mode");
darkModeButton.mousePressed(toggleDarkMode);
darkModeButton.parent(container);
darkModeButton.position(width + 5, 0);
Expand All @@ -41,8 +42,10 @@ function setup() {
function toggleDarkMode() {
darkMode = !darkMode;
if (darkMode == true) {
darkModeButton.elt.innerHTML = "light mode";
conatinerDiv.style('background-color', DARK_MODE_BACKGROUND);
} else {
darkModeButton.elt.innerHTML = "dark mode";
conatinerDiv.style('background-color', LIGHT_MODE_BACKGROUND);
}
}
Expand Down

0 comments on commit d1d57b9

Please sign in to comment.