Skip to content

Commit 46be742

Browse files
Dark mode - Dismiss try again
1 parent 40c4bdb commit 46be742

2 files changed

Lines changed: 78 additions & 2 deletions

File tree

Game2048/Scripts/keyboard_input_manager.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,9 +68,15 @@ class KeyboardInputManager {
6868
self.restart(event);
6969
}
7070

71-
// Enter key to keep playing (dismiss win screen)
71+
// Enter key to keep playing (dismiss win screen) or retry after game over
7272
if (event.key === "Enter") {
73-
self.emit("keepPlaying");
73+
const messageContainer = document.querySelector(".game-message");
74+
75+
if (messageContainer && messageContainer.classList.contains("game-over")) {
76+
self.restart(event);
77+
} else {
78+
self.emit("keepPlaying");
79+
}
7480
}
7581
}
7682
});

Game2048/Styles/main.scss

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,15 @@ $grid-background: #bbada0;
1010
$cell-background: rgba(238, 228, 218, 0.35);
1111
$button-background: #8f7a66;
1212
$score-label-color: #eee4da;
13+
$dark-background-color: #0f0d0c;
14+
$dark-text-color: #f4ede3;
15+
$dark-link-color: #f4cfa5;
16+
$dark-grid-background: #2f2621;
17+
$dark-cell-background: rgba(255, 255, 255, 0.07);
18+
$dark-button-background: #d2864c;
19+
$dark-score-label-color: #f1dfc9;
20+
$dark-overlay-background: rgba(12, 10, 9, 0.72);
21+
$dark-overlay-win: rgba(227, 185, 80, 0.4);
1322

1423
// Tile colors
1524
$tile-2-bg: #eee4da;
@@ -645,3 +654,64 @@ $tile-offset: 121px;
645654
margin-top: 30px !important;
646655
}
647656
}
657+
658+
@media (prefers-color-scheme: dark) {
659+
html, body {
660+
background: $dark-background-color;
661+
color: $dark-text-color;
662+
}
663+
664+
a {
665+
color: $dark-link-color;
666+
}
667+
668+
hr {
669+
border-bottom: 1px solid rgba(244, 237, 227, 0.15);
670+
}
671+
672+
h1.title {
673+
color: $dark-text-color;
674+
}
675+
676+
.score-container,
677+
.best-container {
678+
background: $dark-grid-background;
679+
color: $dark-text-color;
680+
681+
&:after {
682+
color: $dark-score-label-color;
683+
}
684+
685+
.score-addition {
686+
color: $dark-text-color;
687+
}
688+
}
689+
690+
.restart-button {
691+
background: $dark-button-background;
692+
color: $dark-text-color;
693+
}
694+
695+
.game-container {
696+
background: $dark-grid-background;
697+
}
698+
699+
.grid-cell {
700+
background: $dark-cell-background;
701+
}
702+
703+
.game-message {
704+
background: $dark-overlay-background;
705+
color: $dark-text-color;
706+
707+
a {
708+
background: $dark-button-background;
709+
color: $dark-text-color;
710+
}
711+
712+
&.game-won {
713+
background: $dark-overlay-win;
714+
color: $dark-text-color;
715+
}
716+
}
717+
}

0 commit comments

Comments
 (0)