-
Notifications
You must be signed in to change notification settings - Fork 39
Expand file tree
/
Copy pathHeader.svelte
More file actions
51 lines (43 loc) · 1.56 KB
/
Header.svelte
File metadata and controls
51 lines (43 loc) · 1.56 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
<script>
import NavItems from './nav/NavItems.svelte';
import NavItemsMobile from './nav/NavItemsMobile.svelte';
let showMobileNav = false
let bodyElement = document.querySelector('body');
let htmlElement = document.querySelector('html');
function handleToggleClick(e) {
showMobileNav = !showMobileNav
}
if (showMobileNav) {
bodyElement.classList.add('c-mobile-nav-active');
htmlElement.classList.add('u-no-scroll');
} else {
bodyElement.classList.remove('c-mobile-nav-active');
htmlElement.classList.remove('u-no-scroll');
}
</script>
<header class="c-header">
<div class="c-container-horizontal">
<a href="/" class="c-logo">
<img src="/images/logo.svg" alt="Routify">
</a>
<nav class="c-navigation">
<NavItems />
</nav>
<a href="#nav"
class="c-navigation-toggle"
class:c-navigation-toggle--active={showMobileNav === !showMobileNav}
on:click|preventDefault={handleToggleClick}
>
<svg width="40" height="40" viewBox="0 0 40 40">
<rect fill="#000" width="18" height="2" x="11" y="19" class="c-navigation-toggle__line1"></rect>
<rect fill="#000" width="18" height="2" x="11" y="19" class="c-navigation-toggle__line2"></rect>
<rect fill="#000" width="18" height="2" x="11" y="19" class="c-navigation-toggle__line3"></rect>
</svg>
</a>
</div>
</header>
<div class="c-navigation-mobile-holder" class:c-navigation-mobile-holder--active={showMobileNav}>
<nav>
<NavItemsMobile bind:showMobileNav />
</nav>
</div>