-
Notifications
You must be signed in to change notification settings - Fork 1
/
header.js
191 lines (182 loc) · 5.96 KB
/
header.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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
// @ts-check
import { Component } from 'react'
import styles from './Header.module.css'
import { FrontEndController } from '../controller/frontEndController'
import Link from 'next/link';
import Image from 'next/image';
// @ts-ignore
import Logo from '../public/Logo.png'
// @ts-ignore
import LogoName from '../public/Logo_Schrift_Weiss.png'
/**
* @class Header Component Class
* @component
* @category Components
*/
export class Header extends Component {
isVisible = false;
/**
* Generates the JSX Output for the Client
* @returns JSX Output
*/
render() {
// Nav-Bar element for note list
let notes;
if (this.props.hideLogout) {
notes = <div></div>
} else {
notes = <Link href={'/'} passHref>
<div className={styles.nav}>
<span>
Notizen
</span>
</div>
</Link>
}
// Nav-Bar element for profile
let username;
if (this.props.hideLogout) {
username = <div></div>
} else {
username = <Link href={'/profile'} passHref>
<div className={styles.nav}>
<span>
{this.props.username}
</span>
</div>
</Link>
}
// Nav-Bar element for login
let loginButton;
if (this.props.hideLogin) {
loginButton = <></>
} else {
loginButton = <Link href={'/login'} passHref>
<button>
Login
</button>
</Link>
}
// Nav-Bar element for logout
let logoutButton;
if (this.props.hideLogout) {
logoutButton = <></>
} else {
logoutButton = <>
<button
onClick={() => {
FrontEndController.logoutUser();
location.reload();
}
}>
Logout
</button>
</>
}
return (
<div>
<nav>
<div className={styles.navBar}>
{/* Menu Icon for mobile device view */}
<div
className={`${styles.navElement} ${styles.menuIcon}`}
id={styles.menuIcon}
onClick={() => {
if (this.isVisible) {
// slide side-nav to the left (hide)
document.getElementById("menu").classList.remove(`${styles.showHeader}`)
// rotate spans for menu icon (parallel lines)
document.getElementById("spanOne").classList.remove(`${styles.span}`)
document.getElementById("spanTwo").classList.remove(`${styles.span}`)
document.getElementById("spanTwo").classList.remove(`${styles.spanTwo}`)
document.getElementById("spanThree").classList.remove(`${styles.span}`)
document.getElementById("spanThree").classList.remove(`${styles.spanThree}`)
this.isVisible = false;
} else {
// slide side-nav to the right (view)
document.getElementById("menu").classList.add(`${styles.showHeader}`)
// rotate spans for menu close icon (x)
document.getElementById("spanOne").classList.add(`${styles.span}`)
document.getElementById("spanTwo").classList.add(`${styles.span}`)
document.getElementById("spanTwo").classList.add(`${styles.spanTwo}`)
document.getElementById("spanThree").classList.add(`${styles.span}`)
document.getElementById("spanThree").classList.add(`${styles.spanThree}`)
this.isVisible = true;
}
}}>
{/* Three bars that make up the menu-icon */}
<span id="spanOne"></span>
<span id="spanTwo"></span>
<span id="spanThree"></span>
</div>
{/* Logo for Top-Nav-Bar in mobile view */}
<Link href={'/'} passHref>
<div className={styles.logoName}>
<Image
src={LogoName}
alt='Logo_Schrift_Weiss.png missing.'
objectFit='contain'
sizes='fitContent'
layout="fill">
</Image>
</div>
</Link>
{/* Nav-Bar elements (top and left-side) */}
<div
className={styles.menu}
id="menu">
<Link href={'/'} passHref>
<div className={styles.navLogo}>
<Image
src={Logo}
alt='Logo_Schrift_Weiss.png missing.'
objectFit='contain'
sizes='fitContent'
layout="fill">
</Image>
</div>
</Link>
<Link href={'/'} passHref>
<div className={styles.navLogoName}>
<Image
src={LogoName}
alt='Logo_Schrift_Weiss.png missing.'
objectFit='contain'
sizes='fitContent'
layout="fill">
</Image>
</div>
</Link>
{notes}
<Link href={'/getting-started'} passHref>
<div className={styles.nav}>
<span>
Getting Started
</span>
</div>
</Link>
<Link href={'/impressum'} passHref>
<div className={styles.nav}>
<span>
Impressum
</span>
</div>
</Link>
<div className={styles.pcSpacing}>
{/* Spacing for PC (top bar) View */}
</div>
{username}
<div className={styles.mobileSpacing}>
{/* Spacing for Mobile (side bar) View */}
</div>
<div className={`${styles.nav} ${styles.button}`}>
{loginButton}
{logoutButton}
</div>
</div>
</div>
</nav>
</div>
)
}
}