aboutsummaryrefslogtreecommitdiff
path: root/components/navbar.tsx
blob: 9a3f9ffd64987bf60184c68732201bc6d9e6c036 (plain)
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
import { CSSProperties, Component } from "react";
/* import axios from "axios"; */

import { LogoDark } from "../components/logo";

import Home from '@material-ui/icons/Home';
import VideogameAssetIcon from '@material-ui/icons/VideogameAsset';
import ExtensionIcon from '@material-ui/icons/Extension';
import SearchIcon from '@material-ui/icons/Search';
import SettingsIcon from '@material-ui/icons/Settings';
import PersonIcon from '@material-ui/icons/Person';
import {AccountAvatar} from "./account";

var NavBarItemStyle: CSSProperties = {
	margin: 12,
	marginBottom: 16,
	display: "block"
}

export class NavBar extends Component {
	state: {
		loggedIn: boolean
	} = {
		loggedIn: false
	}
	
	constructor(props: {}) {
		super(props);

		if (typeof window === "undefined") return; // return if run on server
		this.state.loggedIn = document.cookie.includes("token");
	}

	render () {
		return <div className="navbar" style={{
			width: 48,
			height: "100%",

			lineHeight: 0,

			backgroundColor: "var(--background)",
			display: "inline-block",

			position: "fixed",
			top: 0,
			left: 0,

			overflow: "hidden",
			whiteSpace: "nowrap"
		}}>
			<div style={NavBarItemStyle}><LogoDark/></div>
			<a href="/" style={NavBarItemStyle}><Home/></a>
			<a href="/game" style={NavBarItemStyle}><VideogameAssetIcon/></a>
			<a href="/" style={NavBarItemStyle}><ExtensionIcon/></a>
			<a href="/" style={NavBarItemStyle}><SearchIcon/></a>

			<div style={{
				position: "absolute",
				bottom: -4,
				left: 0,
				backgroundColor: "var(--background)"
			}}>
			<a href={this.state.loggedIn ? "/account" : "/login"} style={NavBarItemStyle}>
				{
					this.state.loggedIn ?
					<AccountAvatar size={24} dummy round/> :
					<PersonIcon/>
				}
			</a>
				<a href="/settings" style={NavBarItemStyle}><SettingsIcon/></a>
			</div>
		</div>
	}
}