Skip to content

Commit 4031da4

Browse files
committed
better ux for menus and stuff
1 parent 7ad7624 commit 4031da4

File tree

1 file changed

+32
-1
lines changed

1 file changed

+32
-1
lines changed

flok/index.html

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,10 @@
143143
justify-content: center;
144144
align-items: center;
145145
}
146+
147+
details button {
148+
text-align: left;
149+
}
146150
</style>
147151

148152
<main>
@@ -158,6 +162,7 @@
158162
flex-direction: column;
159163
">
160164
<button id="reload-button">🔄 Reload</button>
165+
<button id="about-button">ℹ️ About</button>
161166
<button id="mcplant-button">🍔 McPlant</button>
162167
<!-- ⟳ <li>McPlant</li>
163168
<li>Linda McCartney</li>
@@ -208,6 +213,7 @@ <h2>welcome to pastagang!</h2>
208213

209214
const mcplantButton = document.getElementById("mcplant-button");
210215
mcplantButton.addEventListener("click", () => {
216+
closeBurgerMenu();
211217
alert("You eat the McPlant. It tastes just like a regular burger.");
212218
});
213219

@@ -288,19 +294,44 @@ <h2>welcome to pastagang!</h2>
288294
}, 1000);
289295
}
290296

297+
const aboutButton = document.getElementById("about-button");
298+
aboutButton.addEventListener("click", () => {
299+
closeBurgerMenu();
300+
openWelcomeDialog();
301+
});
302+
303+
function openWelcomeDialog() {
304+
document.getElementById("key-information").showModal();
305+
iframe.style.display = "none";
306+
dialogHolder.style.display = "flex";
307+
coolButton.focus();
308+
}
309+
291310
function closeWelcomeDialog() {
292311
document.getElementById("key-information").close();
293312
iframe.style.display = "block";
294313
dialogHolder.style.display = "none";
295314
iframe.focus();
296315
}
297316

317+
addEventListener("keydown", (e) => {
318+
if (e.key === "Escape") {
319+
closeWelcomeDialog();
320+
}
321+
});
322+
323+
function closeBurgerMenu() {
324+
const details = document.querySelector(".burger-menu");
325+
details.removeAttribute("open");
326+
}
327+
298328
coolButton.addEventListener("click", closeWelcomeDialog);
299329

300330
dialogHolder.addEventListener("click", (e) => {
301331
if (e.target !== dialogHolder) {
302332
return;
303333
}
304-
coolButton.focus();
334+
// coolButton.focus();
335+
closeWelcomeDialog();
305336
});
306337
</script>

0 commit comments

Comments
 (0)