diff --git a/android-chrome-192x192.png b/android-chrome-192x192.png
deleted file mode 100644
index e95f94a..0000000
Binary files a/android-chrome-192x192.png and /dev/null differ
diff --git a/android-chrome-512x512.png b/android-chrome-512x512.png
deleted file mode 100644
index 1cc7d16..0000000
Binary files a/android-chrome-512x512.png and /dev/null differ
diff --git a/apple-touch-icon.png b/apple-touch-icon.png
deleted file mode 100644
index 8325167..0000000
Binary files a/apple-touch-icon.png and /dev/null differ
diff --git a/favicon/android-chrome-192x192.png b/favicon/android-chrome-192x192.png
new file mode 100644
index 0000000..2259549
Binary files /dev/null and b/favicon/android-chrome-192x192.png differ
diff --git a/favicon/android-chrome-512x512.png b/favicon/android-chrome-512x512.png
new file mode 100644
index 0000000..274a06f
Binary files /dev/null and b/favicon/android-chrome-512x512.png differ
diff --git a/favicon/apple-touch-icon.png b/favicon/apple-touch-icon.png
new file mode 100644
index 0000000..15f4b95
Binary files /dev/null and b/favicon/apple-touch-icon.png differ
diff --git a/browserconfig.xml b/favicon/browserconfig.xml
similarity index 56%
rename from browserconfig.xml
rename to favicon/browserconfig.xml
index b3930d0..28c1987 100644
--- a/browserconfig.xml
+++ b/favicon/browserconfig.xml
@@ -2,8 +2,8 @@
-
- #da532c
+
+ #00aba9
diff --git a/favicon-16x16.png b/favicon/favicon-16x16.png
similarity index 65%
rename from favicon-16x16.png
rename to favicon/favicon-16x16.png
index 59b6c55..9111372 100644
Binary files a/favicon-16x16.png and b/favicon/favicon-16x16.png differ
diff --git a/favicon-32x32.png b/favicon/favicon-32x32.png
similarity index 77%
rename from favicon-32x32.png
rename to favicon/favicon-32x32.png
index 9ef36de..4590ec2 100644
Binary files a/favicon-32x32.png and b/favicon/favicon-32x32.png differ
diff --git a/favicon.ico b/favicon/favicon.ico
similarity index 100%
rename from favicon.ico
rename to favicon/favicon.ico
diff --git a/mstile-144x144.png b/favicon/mstile-144x144.png
similarity index 92%
rename from mstile-144x144.png
rename to favicon/mstile-144x144.png
index 947a51d..d451299 100644
Binary files a/mstile-144x144.png and b/favicon/mstile-144x144.png differ
diff --git a/mstile-150x150.png b/favicon/mstile-150x150.png
similarity index 93%
rename from mstile-150x150.png
rename to favicon/mstile-150x150.png
index 43c4970..5703c05 100644
Binary files a/mstile-150x150.png and b/favicon/mstile-150x150.png differ
diff --git a/mstile-310x150.png b/favicon/mstile-310x150.png
similarity index 94%
rename from mstile-310x150.png
rename to favicon/mstile-310x150.png
index eccfd77..98d7e11 100644
Binary files a/mstile-310x150.png and b/favicon/mstile-310x150.png differ
diff --git a/mstile-310x310.png b/favicon/mstile-310x310.png
similarity index 96%
rename from mstile-310x310.png
rename to favicon/mstile-310x310.png
index f231e0b..8db83c8 100644
Binary files a/mstile-310x310.png and b/favicon/mstile-310x310.png differ
diff --git a/mstile-70x70.png b/favicon/mstile-70x70.png
similarity index 90%
rename from mstile-70x70.png
rename to favicon/mstile-70x70.png
index dec8ca1..0b1a34f 100644
Binary files a/mstile-70x70.png and b/favicon/mstile-70x70.png differ
diff --git a/favicon/safari-pinned-tab.svg b/favicon/safari-pinned-tab.svg
new file mode 100644
index 0000000..7d9fa80
--- /dev/null
+++ b/favicon/safari-pinned-tab.svg
@@ -0,0 +1,32 @@
+
+
+
diff --git a/site.webmanifest b/favicon/site.webmanifest
similarity index 73%
rename from site.webmanifest
rename to favicon/site.webmanifest
index b20abb7..5eb5e44 100644
--- a/site.webmanifest
+++ b/favicon/site.webmanifest
@@ -3,12 +3,12 @@
"short_name": "",
"icons": [
{
- "src": "/android-chrome-192x192.png",
+ "src": "/favicon/android-chrome-192x192.png",
"sizes": "192x192",
"type": "image/png"
},
{
- "src": "/android-chrome-512x512.png",
+ "src": "/favicon/android-chrome-512x512.png",
"sizes": "512x512",
"type": "image/png"
}
diff --git a/index.css b/index.css
index 4a6a85b..efa3252 100644
--- a/index.css
+++ b/index.css
@@ -56,8 +56,17 @@ header p {
align-items: center;
font-size: 2rem;
font-weight: 800;
+ color: white;
+}
+.board .row .cell.unguessed {
+ color: black;
transform: scale(-1, 1);
}
+.board .row .cell.guessed {
+ color: black;
+ transform: scale(-1, 1);
+ transition: all 0.3s;
+}
.board .row .cell.correct {
background-color: #6aaa64;
color: #fff;
@@ -100,6 +109,21 @@ header p {
transition: all 0.3s;
transform: scale(-1, 1);
}
+.letters .row .letter.correct {
+ background-color: #6aaa64 !important;
+ color: #fff;
+ border: none;
+}
+.letters .row .letter.present {
+ background-color: #c9b458;
+ color: #fff;
+ border: none;
+}
+.letters .row .letter.absent {
+ background-color: #787c7e;
+ color: #fff;
+ border: none;
+}
.letters .row #backspace {
width: 5rem;
}
@@ -111,6 +135,15 @@ header p {
width: 5rem;
}
+.toast {
+ background: black !important;
+ color: white;
+ font-family: "Raleway", sans-serif;
+ font-weight: 600;
+ border-radius: 5px !important;
+ transform: scale(-1, 1) !important;
+}
+
footer {
font-family: "Playfair Display", serif;
font-size: 1rem;
diff --git a/index.css.map b/index.css.map
index fb88072..d980035 100644
--- a/index.css.map
+++ b/index.css.map
@@ -1 +1 @@
-{"version":3,"sources":["index.sass","index.css"],"names":[],"mappings":"AAWA;EACE,UAAA;EACA,SAAA;EACA,sBAAA;ACVF;;ADYA;EACE,YAAA;EACA,aAAA;EAEA,aAAA;EACA,sBAAA;EACA,uBAAA;EACA,mBAAA;EAEA,yBAAA;KAAA,sBAAA;UAAA,iBAAA;ACXF;;ADaA;EACE,sCA5BM;EA6BN,iBAAA;EACA,gBAAA;EACA,mBAAA;EACA,uBAAA;ACVF;ADYE;EACE,iBAAA;EACA,gBAAA;EACA,mBAAA;ACVJ;;ADYA;EACE,aAAA;EACA,sBAAA;EACA,mBAAA;EACA,WAAA;EACA,kCA3CW;ACkCb;;ADWA;EACE,aAAA;EACA,sBAAA;EACA,WAAA;ACRF;ADUE;EACE,aAAA;EACA,mBAAA;EACA,WAAA;ACRJ;ADUI;EACE,WAAA;EACA,YAAA;EACA,yBAAA;EACA,aAAA;EACA,uBAAA;EACA,mBAAA;EACA,eAAA;EACA,gBAAA;EACA,uBAAA;ACRN;ADUM;EACE,yBAhEQ;EAiER,WAAA;EACA,YAAA;ACRR;ADUM;EACE,yBAtEQ;EAuER,WAAA;EACA,YAAA;ACRR;ADUM;EACE,yBAzEO;EA0EP,WAAA;EACA,YAAA;ACRR;;ADUA;EACE,aAAA;EACA,sBAAA;EACA,SAAA;EACA,iBAAA;EACA,gBAAA;ACPF;ADSE;EACE,aAAA;EACA,mBAAA;EACA,uBAAA;EACA,SAAA;ACPJ;ADSI;EACE,WAAA;EACA,YAAA;EACA,uBAAA;EACA,aAAA;EACA,uBAAA;EACA,mBAAA;EACA,eAAA;EACA,gBAAA;EACA,eAAA;EACA,oBAAA;EACA,uBAAA;ACPN;ADSI;EACE,WAAA;ACPN;ADSM;EACE,uBAAA;EACA,UAAA;ACPR;ADUI;EACE,WAAA;ACRN;;ADUA;EACE,sCAxHM;EAyHN,eAAA;EACA,gBAAA;EACA,gBAAA;ACPF;ADSE;EACE,WAAA;EACA,qBAAA;EACA,gBAAA;EACA,oBAAA;ACPJ;ADSI;EACE,WAAA;ACPN","file":"index.css"}
\ No newline at end of file
+{"version":3,"sources":["index.sass","index.css"],"names":[],"mappings":"AAWA;EACE,UAAA;EACA,SAAA;EACA,sBAAA;ACVF;;ADYA;EACE,YAAA;EACA,aAAA;EAEA,aAAA;EACA,sBAAA;EACA,uBAAA;EACA,mBAAA;EAEA,yBAAA;KAAA,sBAAA;UAAA,iBAAA;ACXF;;ADaA;EACE,sCA5BM;EA6BN,iBAAA;EACA,gBAAA;EACA,mBAAA;EACA,uBAAA;ACVF;ADYE;EACE,iBAAA;EACA,gBAAA;EACA,mBAAA;ACVJ;;ADYA;EACE,aAAA;EACA,sBAAA;EACA,mBAAA;EACA,WAAA;EACA,kCA3CW;ACkCb;;ADWA;EACE,aAAA;EACA,sBAAA;EACA,WAAA;ACRF;ADUE;EACE,aAAA;EACA,mBAAA;EACA,WAAA;ACRJ;ADUI;EACE,WAAA;EACA,YAAA;EACA,yBAAA;EACA,aAAA;EACA,uBAAA;EACA,mBAAA;EACA,eAAA;EACA,gBAAA;EACA,YAAA;ACRN;ADUM;EACE,YAAA;EACA,uBAAA;ACRR;ADUM;EACE,YAAA;EACA,uBAAA;EACA,oBAAA;ACRR;ADUM;EACE,yBAzEQ;EA0ER,WAAA;EACA,YAAA;ACRR;ADUM;EACE,yBA/EQ;EAgFR,WAAA;EACA,YAAA;ACRR;ADUM;EACE,yBAlFO;EAmFP,WAAA;EACA,YAAA;ACRR;;ADUA;EACE,aAAA;EACA,sBAAA;EACA,SAAA;EACA,iBAAA;EACA,gBAAA;ACPF;ADSE;EACE,aAAA;EACA,mBAAA;EACA,uBAAA;EACA,SAAA;ACPJ;ADSI;EACE,WAAA;EACA,YAAA;EACA,uBAAA;EACA,aAAA;EACA,uBAAA;EACA,mBAAA;EACA,eAAA;EACA,gBAAA;EACA,eAAA;EACA,oBAAA;EACA,uBAAA;ACPN;ADSM;EACE,oCAAA;EACA,WAAA;EACA,YAAA;ACPR;ADSM;EACE,yBApHY;EAqHZ,WAAA;EACA,YAAA;ACPR;ADSM;EACE,yBAvHW;EAwHX,WAAA;EACA,YAAA;ACPR;ADSI;EACE,WAAA;ACPN;ADSM;EACE,uBAAA;EACA,UAAA;ACPR;ADUI;EACE,WAAA;ACRN;;ADUA;EACE,4BAAA;EACA,YAAA;EACA,kCAjJW;EAkJX,gBAAA;EACA,6BAAA;EACA,kCAAA;ACPF;;ADSA;EACE,sCAxJM;EAyJN,eAAA;EACA,gBAAA;EACA,gBAAA;ACNF;ADQE;EACE,WAAA;EACA,qBAAA;EACA,gBAAA;EACA,oBAAA;ACNJ;ADQI;EACE,WAAA;ACNN","file":"index.css"}
\ No newline at end of file
diff --git a/index.html b/index.html
index 3915aa7..1efbfb3 100644
--- a/index.html
+++ b/index.html
@@ -1,13 +1,34 @@
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
eldroW
@@ -19,6 +40,11 @@
href="https://fonts.googleapis.com/css2?family=Playfair+Display:ital,wght@0,400..900;1,400..900&family=Raleway:ital,wght@0,100..900;1,100..900&display=swap"
rel="stylesheet"
/>
+
@@ -29,18 +55,18 @@
-
Y
-
R
-
R
-
U
-
C
+
+
+
+
+
-
R
-
E
-
T
-
A
-
W
+
+
+
+
+
-
ENTER
+
ENTER
M
N
B
@@ -132,6 +158,12 @@
+
+
+
diff --git a/index.js b/index.js
index 96a45ee..bb36d9d 100644
--- a/index.js
+++ b/index.js
@@ -1,40 +1,205 @@
const LENGTH = 5;
const GUESSES = LENGTH + 1;
+let guesses = [];
+let running = true;
+let currentGuess = "";
+let lockedGuess = "";
+let runningAnim = false;
+
let hashDate = (date) => {
return date.getFullYear() + date.getMonth() + date.getDate();
};
-const currentWord = ANSWERS[hashDate(new Date()) % ANSWERS.length];
+const currentWord =
+ ANSWERS[hashDate(new Date()) % ANSWERS.length].toUpperCase();
-// initialize board
+let startGame = () => {
+ guesses = [];
+ let boardElement = document.getElementById("board");
-let guesses = [];
-let boardElement = document.getElementById("board");
+ boardElement.innerHTML = "";
-boardElement.innerHTML = "";
+ for (let i = 0; i < GUESSES; i++) {
+ let row = document.createElement("div");
+ row.classList.add("row");
+ row.id = "row" + i;
+ boardElement.appendChild(row);
-for (let i = 0; i < GUESSES; i++) {
- let row = document.createElement("div");
- row.classList.add("row");
- row.id = "row" + i;
- boardElement.appendChild(row);
-
- for (let i = 0; i < LENGTH; i++) {
- let cell = document.createElement("div");
- cell.classList.add("cell");
- cell.id = "cell" + i;
- row.appendChild(cell);
+ for (let j = 0; j < LENGTH; j++) {
+ let cell = document.createElement("div");
+ cell.classList.add("cell");
+ cell.id = "row" + i + "cell" + j;
+ cell.classList.add("unguessed");
+ row.appendChild(cell);
+ }
}
-}
-let running = true;
-let currentGuess = "";
+ running = true;
+ currentGuess = "";
+};
+
+startGame();
let updateBoard = () => {
- let row = document.getElementById("row" + guesses.length);
- for (let i = LENGTH; i > 0; i--) {
- let cell = document.getElementById("cell" + i);
+ if (runningAnim) return;
+ for (let i = 0; i < LENGTH; i++) {
+ let cell = document.getElementById(
+ "row" + guesses.length + "cell" + (LENGTH - i - 1)
+ );
cell.innerHTML = currentGuess[i] || "";
}
};
+
+let addLetter = (letter) => {
+ if (currentGuess.length < LENGTH) currentGuess += letter;
+};
+
+let handleButtonPress = (button) => {
+ if (!running || runningAnim) {
+ return;
+ }
+
+ if (button.id === "backspace") {
+ currentGuess = currentGuess.slice(0, -1);
+ } else if (button.id === "enter") {
+ handleGuess();
+ } else {
+ addLetter(button.id);
+ }
+
+ updateBoard();
+};
+
+onkeyup = (event) => {
+ if (!running || runningAnim) {
+ return;
+ }
+
+ if (event.key === "Backspace") {
+ currentGuess = currentGuess.slice(0, -1);
+ } else if (event.key === "Enter") {
+ handleGuess();
+ } else {
+ addLetter(event.key.toUpperCase());
+ }
+
+ updateBoard();
+};
+
+let buttons = document.getElementsByClassName("letter");
+
+for (let button of buttons) {
+ button.addEventListener("click", () => {
+ handleButtonPress(button);
+ });
+}
+
+let handleGuess = () => {
+ if (currentGuess.length !== LENGTH) {
+ Toastify({
+ text: "Not enough letters",
+ duration: 1000,
+ newWindow: false,
+ close: false,
+ gravity: "top",
+ position: "center",
+ stopOnFocus: false,
+ className: "toast",
+ }).showToast();
+
+ return;
+ }
+
+ if (!WORDS.includes(currentGuess.toLowerCase())) {
+ Toastify({
+ text: "Not in word list",
+ duration: 1000,
+ newWindow: false,
+ close: false,
+ gravity: "top",
+ position: "center",
+ stopOnFocus: false,
+ className: "toast",
+ }).showToast();
+
+ return;
+ }
+
+ lockedGuess = currentGuess;
+ runningAnim = true;
+ currentGuess = "";
+
+ for (let i = 0; i < LENGTH; i++) {
+ let cell = document.getElementById(
+ "row" + guesses.length + "cell" + (LENGTH - i - 1)
+ );
+
+ setTimeout(() => {
+ cell.classList.remove("unguessed");
+ }, 50 * (LENGTH - i));
+
+ setTimeout(() => {
+ cell.classList.add("guessed");
+
+ if (lockedGuess[i] === currentWord[i]) {
+ cell.classList.add("correct");
+ document
+ .getElementById(lockedGuess[i].toUpperCase())
+ .classList.add("correct");
+ } else if (currentWord.includes(lockedGuess[i])) {
+ cell.classList.add("present");
+ document
+ .getElementById(lockedGuess[i].toUpperCase())
+ .classList.add("present");
+ } else {
+ cell.classList.add("absent");
+ document
+ .getElementById(lockedGuess[i].toUpperCase())
+ .classList.add("absent");
+ }
+ }, 300 * (i + 1) + 300);
+ }
+
+ if (lockedGuess === currentWord) {
+ running = false;
+ setTimeout(() => {
+ Toastify({
+ text: "You win!",
+ duration: 1000,
+ newWindow: false,
+ close: false,
+ gravity: "top",
+ position: "center",
+ stopOnFocus: false,
+ className: "toast",
+ }).showToast();
+ confetti({
+ particleCount: 100,
+ spread: 70,
+ origin: { y: 0.6 },
+ });
+ }, 2000);
+ } else if (guesses.length === GUESSES) {
+ running = false;
+
+ setTimeout(() => {
+ Toastify({
+ text: "You lose!",
+ duration: 1000,
+ newWindow: false,
+ close: false,
+ gravity: "top",
+ position: "center",
+ stopOnFocus: false,
+ className: "toast",
+ }).showToast();
+ }, 2000);
+ }
+ setTimeout(() => {
+ guesses.push(lockedGuess);
+ lockedGuess = "";
+ runningAnim = false;
+ updateBoard();
+ }, 2000);
+};
diff --git a/index.sass b/index.sass
index facdefd..dd6dd66 100644
--- a/index.sass
+++ b/index.sass
@@ -63,7 +63,16 @@ header
align-items: center
font-size: 2rem
font-weight: 800
- transform: scale(-1, 1)
+ color: white
+
+ &.unguessed
+ color: black
+ transform: scale(-1, 1)
+
+ &.guessed
+ color: black
+ transform: scale(-1, 1)
+ transition: all 0.3s
&.correct
background-color: $color-correct
@@ -106,6 +115,21 @@ header
transition: all 0.3s
transform: scale(-1, 1)
+ &.correct
+ background-color: $key-color-correct !important
+ color: #fff
+ border: none
+
+ &.present
+ background-color: $key-color-present
+ color: #fff
+ border: none
+
+ &.absent
+ background-color: $key-color-absent
+ color: #fff
+ border: none
+
#backspace
width: 5rem
@@ -117,6 +141,14 @@ header
#enter
width: 5rem
+.toast
+ background: black !important
+ color: white
+ font-family: $sans-serif
+ font-weight: 600
+ border-radius: 5px !important
+ transform: scale(-1, 1) !important
+
footer
font-family: $serif
font-size: 1rem
diff --git a/safari-pinned-tab.svg b/safari-pinned-tab.svg
deleted file mode 100644
index 2eee1af..0000000
--- a/safari-pinned-tab.svg
+++ /dev/null
@@ -1,32 +0,0 @@
-
-
-