Skip to content

Commit e14233b

Browse files
authored
update mobile view
1 parent dd018d1 commit e14233b

2 files changed

Lines changed: 129 additions & 11 deletions

File tree

_layouts/default.html

Lines changed: 37 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,10 @@
2222
<header class="gh-head">
2323
<div class="gh-head-inner">
2424
<div class="gh-head-brand">
25-
<a href="/">
26-
<img src="/images/work-for-free.png" alt="Work For Free">
27-
25+
<a href="/" class="gh-navigation-logo">
26+
<img src="/images/work-for-free.png" alt="Work For Free" class="gh-navigation-logo is-title">
2827
</a>
28+
<button class="mobile-menu-toggle" aria-label="Menu"></button>
2929
</div>
3030

3131
<div class="gh-head-menu">
@@ -127,5 +127,39 @@ <h3>Subscribe to get updates</h3>
127127
</div>
128128
</footer>
129129
</div>
130+
131+
<script>
132+
document.addEventListener('DOMContentLoaded', function() {
133+
const mobileMenuToggle = document.querySelector('.mobile-menu-toggle');
134+
const mobileMenu = document.querySelector('.gh-head-menu');
135+
136+
if (mobileMenuToggle) {
137+
mobileMenuToggle.addEventListener('click', function() {
138+
mobileMenu.classList.toggle('active');
139+
this.setAttribute('aria-expanded',
140+
mobileMenu.classList.contains('active') ? 'true' : 'false');
141+
142+
// Change toggle icon based on state
143+
if (mobileMenu.classList.contains('active')) {
144+
this.textContent = '✕';
145+
} else {
146+
this.textContent = '';
147+
this.classList.remove('open');
148+
}
149+
});
150+
}
151+
152+
// Close mobile menu when clicking outside
153+
document.addEventListener('click', function(event) {
154+
if (!event.target.closest('.gh-head-menu') &&
155+
!event.target.closest('.mobile-menu-toggle') &&
156+
mobileMenu.classList.contains('active')) {
157+
mobileMenu.classList.remove('active');
158+
mobileMenuToggle.setAttribute('aria-expanded', 'false');
159+
mobileMenuToggle.textContent = '';
160+
}
161+
});
162+
});
163+
</script>
130164
</body>
131165
</html>

css/main.css

Lines changed: 92 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ body {
5555
margin: 0 0 1.5rem 0;
5656
display: flex;
5757
align-items: center;
58+
position: relative;
5859
}
5960

6061
.gh-head-brand a {
@@ -63,10 +64,33 @@ body {
6364
display: flex;
6465
align-items: center;
6566
gap: 0.5rem;
67+
max-width: 100%;
68+
}
69+
70+
/* .gh-head-brand a img {
71+
max-height: 45px;
72+
max-width: 320px;
73+
object-fit: contain;
74+
margin: 0 auto;
75+
} */
76+
77+
.gh-navigation-logo {
78+
display: block;
79+
width: auto;
80+
height: auto;
81+
max-width: 100%;
6682
}
6783

68-
.gh-head-logo {
69-
display: none; /* Hide the actual image */
84+
/* .gh-navigation-logo.is-title {
85+
max-height: 45px;
86+
width: auto;
87+
} */
88+
89+
@media (max-width: 768px) {
90+
.gh-navigation-logo.is-title {
91+
max-width: 70%;
92+
height: auto;
93+
}
7094
}
7195

7296
.gh-head-title {
@@ -377,30 +401,90 @@ body {
377401
margin: 8px 0;
378402
}
379403

380-
/* Mobile responsiveness */
404+
/* Mobile navigation and responsiveness */
405+
.mobile-menu-toggle {
406+
display: none;
407+
background: none;
408+
border: none;
409+
color: var(--heading-color);
410+
font-size: 1.8rem;
411+
cursor: pointer;
412+
padding: 5px;
413+
}
414+
415+
.mobile-menu-toggle:before {
416+
content: "☰";
417+
}
418+
381419
@media (max-width: 768px) {
420+
.gh-head {
421+
padding: 1rem 0;
422+
}
423+
382424
.gh-head-inner {
383425
flex-direction: column;
384426
align-items: center;
385427
}
386428

387429
.gh-head-brand {
388430
margin-bottom: 1rem;
431+
width: 100%;
432+
display: flex;
433+
justify-content: center;
434+
}
435+
436+
.mobile-menu-toggle {
437+
display: block;
438+
position: absolute;
439+
right: 20px;
440+
top: 20px;
389441
}
390442

391443
.gh-head-menu {
392444
width: 100%;
393-
overflow-x: auto;
445+
max-height: 0;
446+
overflow: hidden;
447+
transition: max-height 0.3s ease-in-out;
394448
}
395449

450+
.gh-head-menu.active {
451+
max-height: 500px;
452+
}
453+
396454
.gh-head-menu ul {
397-
padding-bottom: 0.5rem;
398-
flex-wrap: wrap;
399-
justify-content: center;
455+
flex-direction: column;
456+
padding: 0;
457+
width: 100%;
400458
}
401459

402460
.gh-head-menu li {
403-
margin: 0.5rem;
461+
margin: 0;
462+
padding: 0;
463+
width: 100%;
464+
text-align: center;
465+
border-top: 1px solid var(--border-color);
466+
}
467+
468+
.gh-head-menu li a {
469+
display: block;
470+
padding: 12px;
471+
}
472+
473+
.drop-down > ul > li > ul {
474+
position: static;
475+
box-shadow: none;
476+
padding: 0;
477+
width: 100%;
478+
}
479+
480+
.drop-down > ul > li > ul > li {
481+
margin: 0;
482+
border-top: 1px solid var(--border-color);
483+
}
484+
485+
.drop-down > ul > li > ul > li a {
486+
padding-left: 25px;
487+
background-color: #f9f9f9;
404488
}
405489

406490
.gh-post-title {

0 commit comments

Comments
 (0)