Skip to content

Commit 44b8921

Browse files
committed
feat: push nav buttons to the bottom
and fix some scroll/sizing weirdness
1 parent c143715 commit 44b8921

4 files changed

Lines changed: 27 additions & 14 deletions

File tree

out/mobile-menu.js

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
document.querySelectorAll("nav img, nav a").forEach(e => {
22
e.addEventListener("click", () => {
3-
const navElement = document.querySelector("nav");
4-
navElement.classList.toggle("visible");
5-
setTimeout(() => {
6-
navElement.scrollTo({ top: 0, behavior: "smooth" }); // Reset scroll position
7-
}, 0);
3+
if (window.innerWidth < 800) {
4+
const navElement = document.querySelector("nav");
5+
navElement.classList.toggle("visible");
6+
setTimeout(() => {
7+
navElement.scrollTo({ top: 0, behavior: "smooth" }); // Reset scroll position
8+
}, 0);
9+
}
810
})
911
});
1012

out/scroll.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,4 +48,5 @@ const updateScroll = () => {
4848

4949
updateScroll();
5050
main.addEventListener("scroll", updateScroll);
51+
nav.addEventListener("scroll", updateScroll);
5152
window.addEventListener("resize", updateScroll);

out/style.css

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ nav {
2424
position: absolute;
2525
width: 100vw;
2626
height: calc(15px + 48px); /* Set the height relative to the padding to only show the menu icon */
27+
max-height: max-content;
2728
box-sizing: border-box;
2829

2930
padding: 15px 30px;
@@ -42,18 +43,20 @@ nav {
4243
overscroll-behavior: none;
4344
}
4445

45-
/* FIXME: Maybe push these links to the bottom of the screen if we have space on desktop? */
46+
/* Push the nav links block to the bottom of the nav when
47+
there is extra vertical space. */
4648
#nav-links {
4749
position: relative;
4850
width: 100%;
49-
margin-top: 0.3em;
5051
text-align: center;
5152
font-size: 2em;
53+
margin-top: auto;
54+
text-align: center;
5255
}
5356

5457
#nav-links a {
5558
color: inherit;
56-
padding: 0.2em 0.5em;
59+
padding: 0.2em 0.2em;
5760
margin: auto;
5861
}
5962

@@ -70,7 +73,6 @@ nav h2 {
7073

7174
/* This class gets applied when the menu is opened on mobile */
7275
nav.visible {
73-
height: 100vh;
7476
overflow: scroll;
7577
}
7678

@@ -209,11 +211,17 @@ table.commands tr:nth-child(1) {
209211

210212
/* Large screens only */
211213
@media (min-width: 800px) {
212-
/* ""Undo"" all the mobile styling */
214+
body {
215+
grid-template-columns: max-content 1fr;
216+
}
217+
213218
nav {
219+
display: flex;
220+
flex-direction: column;
214221
position: unset;
215-
width: unset;
216-
height: unset;
222+
width: auto;
223+
height: 100vh;
224+
max-height: unset;
217225
overflow: auto;
218226
}
219227

template.html

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,10 @@
1212

1313
<body>
1414
<nav>
15-
<img src="/menu-icon.svg" alt="Menu" width="48px" height="48px">
16-
<h2>Portal 2 Rules</h2>
15+
<div>
16+
<img src="/menu-icon.svg" alt="Menu" width="48px" height="48px">
17+
<h2>Portal 2 Rules</h2>
18+
</div>
1719
{{NAV_MENU}}
1820
</nav>
1921
<main>

0 commit comments

Comments
 (0)