Skip to content

Commit 6fcffec

Browse files
author
Simon L. Lange
committed
Bellcom theme: Simple mobile navigation functionality
1 parent 66a868e commit 6fcffec

File tree

5 files changed

+42
-25
lines changed

5 files changed

+42
-25
lines changed

web/themes/custom/subsites/bellcom_theme/assets/css/bundle.css

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -991,21 +991,15 @@ video {
991991
position: fixed;
992992
height: 100vh;
993993
background-color: white;
994-
right: 0;
995-
bottom: 0;
994+
right: -85%;
995+
top: 80px;
996996
display: flex;
997997
align-items: center;
998998
transition: 0.3s ease-in
999999
}
10001000

10011001

10021002
}
1003-
.header .header__inner-wrapper .region--header nav #closeBtn {
1004-
position: absolute;
1005-
top: 20px;
1006-
right: 20px;
1007-
font-size: 32px;
1008-
}
10091003
@media only screen and (max-width: 768px) {
10101004
.header .header__inner-wrapper .region--header nav {
10111005
height: 80%;
@@ -1049,6 +1043,12 @@ video {
10491043
transition: transform 0.25s ease-out;
10501044
background-color: black;
10511045
}
1046+
.region.region--header.is-open {
1047+
right: 0 !important;
1048+
}
1049+
body.is-fixed {
1050+
position: fixed;
1051+
}
10521052
.hero-wrapper {
10531053
min-height: 70vh;
10541054
width: 100%;

web/themes/custom/subsites/bellcom_theme/assets/js/bundle.js

Lines changed: 12 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

web/themes/custom/subsites/bellcom_theme/src/js/main.js

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,18 @@ document.addEventListener('DOMContentLoaded', () => {
77

88

99
const hamburgerBtn = document.querySelector('.hamburger');
10-
11-
const menuElement = document.querySelector('.region--header');
10+
const menuElement = document.querySelector('.region.region--header');
11+
const bodyElement = document.querySelector('body');
1212

1313
hamburgerBtn.addEventListener('click', () => {
14-
menuElement.classList.add('is-open');
14+
menuElement.classList.toggle('is-open');
15+
bodyElement.classList.toggle('is-fixed');
1516
});
17+
18+
window.onresize = function () {
19+
var w = window.outerWidth;
20+
if (w > 768) {
21+
menuElement.classList.remove('is-open');
22+
bodyElement.classList.remove('is-fixed');
23+
}
24+
};

web/themes/custom/subsites/bellcom_theme/src/scss/components/header.scss

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,8 @@
5050
position: fixed;
5151
height: 100vh;
5252
background-color: white;
53-
right: 0;
54-
bottom: 0;
53+
right: -85%;
54+
top: 80px;
5555
display: flex;
5656
align-items: center;
5757
transition: 0.3s ease-in;
@@ -63,13 +63,6 @@
6363

6464
nav {
6565

66-
#closeBtn {
67-
position: absolute;
68-
top: 20px;
69-
right: 20px;
70-
font-size: 32px;
71-
}
72-
7366
@media only screen and (max-width: 768px) {
7467
height: 80%;
7568
margin: 0 50px;
@@ -117,3 +110,10 @@
117110
}
118111
}
119112

113+
.region.region--header.is-open {
114+
right: 0 !important;
115+
}
116+
117+
body.is-fixed {
118+
position: fixed;
119+
}

web/themes/custom/subsites/bellcom_theme/templates/menu.html.twig

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,8 @@
2626
We call a macro which calls itself to render the full tree.
2727
@see https://twig.symfony.com/doc/1.x/tags/macro.html
2828
#}
29-
<div id="closeBtn"><i class="fa-solid fa-xmark"></i></div>
30-
{{ menus.menu_links(items, attributes, 0) }}
3129

30+
{{ menus.menu_links(items, attributes, 0) }}
3231
{% macro menu_links(items, attributes, menu_level) %}
3332
{% import _self as menus %}
3433
{% if items %}

0 commit comments

Comments
 (0)