Skip to content

Commit dd7c7a8

Browse files
Merge pull request #180 from phel-lang/minor-fixes
Hide toolbar on mobile resolution
2 parents 082ef57 + 69d873c commit dd7c7a8

File tree

5 files changed

+42
-9
lines changed

5 files changed

+42
-9
lines changed

css/base.css

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,12 @@ body {
4242
color var(--duration-normal) var(--ease-out);
4343
}
4444

45+
@media (max-width: 767px) {
46+
body {
47+
padding-top: 0;
48+
}
49+
}
50+
4551
/* Reset spacing */
4652
* + * {
4753
margin-top: 1.5em;

css/components/header.css

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,10 @@
3535
}
3636

3737
@media (max-width: 767px) {
38+
.site-header {
39+
position: relative;
40+
}
41+
3842
.site-header__container {
3943
padding: 0 var(--space-md);
4044
gap: var(--space-sm);

css/components/layout.css

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,12 @@
77
transition: background-color var(--duration-normal) var(--ease-out);
88
}
99

10+
@media (max-width: 767px) {
11+
.layout-container {
12+
margin-top: var(--header-height);
13+
}
14+
}
15+
1016
/* One Column Layout - Modern Content */
1117
.one-column-layout {
1218
margin: 0 auto;

css/components/search.css

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
height: 16px;
3737
color: var(--color-light-link);
3838
flex-shrink: 0;
39+
pointer-events: none;
3940
}
4041

4142
.site-header__search-trigger .search-trigger-text {
@@ -45,6 +46,7 @@
4546
overflow: hidden;
4647
text-overflow: ellipsis;
4748
font-weight: 400;
49+
pointer-events: none;
4850
}
4951

5052
.site-header__search-trigger .search-shortcut {
@@ -383,29 +385,29 @@
383385

384386
@media (max-width: 768px) {
385387
.search-modal {
386-
padding: 16px;
388+
padding: 8px;
387389
align-items: flex-start;
388390
}
389391

390392
.search-modal__container {
391393
max-width: 100%;
392394
width: 100%;
393395
height: auto;
394-
max-height: calc(100dvh - 32px);
395-
max-height: calc(var(--vh, 1vh) * 100 - 32px); /* Fallback for browsers without dvh support */
396+
max-height: calc(100dvh - 12px);
397+
max-height: calc(var(--vh, 1vh) * 100 - 12px); /* Fallback for browsers without dvh support */
396398
}
397399

398400
.search-modal__content {
399401
border-radius: var(--radius-lg);
400402
height: auto;
401-
max-height: calc(100dvh - 32px);
402-
max-height: calc(var(--vh, 1vh) * 100 - 32px);
403+
max-height: calc(100dvh - 12px);
404+
max-height: calc(var(--vh, 1vh) * 100 - 12px);
403405
}
404406

405407
/* When results are visible, expand to full height */
406408
.search-modal__content:has(.search-modal__results[style*="display: block"]) {
407-
height: calc(100dvh - 32px);
408-
height: calc(var(--vh, 1vh) * 100 - 32px);
409+
height: calc(100dvh - 12px);
410+
height: calc(var(--vh, 1vh) * 100 - 12px);
409411
}
410412

411413
.search-modal__input-wrapper {

static/back_to_top.js

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,26 @@
11
// Get the button:
22
let mybutton = document.getElementById("back-to-top-button");
33

4-
// When the user scrolls down 300px from the top of the document, show the button
4+
// Track last scroll position for detecting scroll direction
5+
let lastScrollTop = 0;
6+
let isScrollingUp = false;
7+
8+
// When the user scrolls, check position and direction
59
window.onscroll = function() {scrollFunction()};
610

711
function scrollFunction() {
8-
if (document.body.scrollTop > 300 || document.documentElement.scrollTop > 300) {
12+
const currentScrollTop = document.body.scrollTop || document.documentElement.scrollTop;
13+
14+
// Determine scroll direction
15+
if (currentScrollTop < lastScrollTop) {
16+
isScrollingUp = true;
17+
} else {
18+
isScrollingUp = false;
19+
}
20+
lastScrollTop = currentScrollTop <= 0 ? 0 : currentScrollTop;
21+
22+
// Show button only when scrolling up AND past 300px (all resolutions)
23+
if (currentScrollTop > 300 && isScrollingUp) {
924
mybutton.classList.add("visible");
1025
} else {
1126
mybutton.classList.remove("visible");

0 commit comments

Comments
 (0)