forked from Real-Dev-Squad/website-dashboard
-
Notifications
You must be signed in to change notification settings - Fork 0
/
navbar.global.js
62 lines (59 loc) · 2.01 KB
/
navbar.global.js
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
52
53
54
55
56
57
58
59
60
61
62
const addNavbartoPage = async () => {
const navbar = document?.getElementById('tasksNav');
const navbarParams = new URLSearchParams(window?.location?.search);
navbar.innerHTML = `
<div class="logo">
<a href="/index.html">
<img src="/images/[email protected]" alt="logo" />
</a>
</div>
<div class="nav-links">
<div class="hamburger">
<div class="line"></div>
<div class="line"></div>
<div class="line"></div>
</div>
<div class="links">
<a href="https://welcome.realdevsquad.com/">Welcome</a>
<a href="https://www.realdevsquad.com/events">Events</a>
<a href="https://members.realdevsquad.com/">Members</a>
<a href="https://status.realdevsquad.com/tasks">Status</a>
</div>
</div>
<div class="sign-in-btn">
<button onclick="goToAuthPage()">
Sign In <span>With GitHub</span>
<img src="/images/github.png" class="user-avatar" />
</button>
</div>
<div class="user-info">
<span id="user-name"></span>
<span>
<img id="user-img" src="" alt="" />
</span>
</div>
<div id="dropdown"></div>
`;
const hamburgerDiv = document.querySelector('.hamburger');
const navLinks = document.querySelector('.links');
let toggle = true;
hamburgerDiv?.addEventListener('click', function () {
if (toggle) {
navLinks.classList.add('active');
toggle = false;
} else {
navLinks.classList.remove('active');
toggle = true;
}
});
if (navbarParams?.get('dev') === 'true') {
let navActive = document?.querySelector('.nav-links');
const navLinks = document?.querySelector('.links');
document?.addEventListener('click', function (event) {
if (!navActive?.contains(event.target)) {
navLinks?.classList?.remove('active');
toggle = true;
}
});
}
};