blob: a736c3758ca97b9ffb12932e56cb1def313859bb [file] [log] [blame]
pineafana5ce9102021-09-02 17:21:31 +01001import { Component } from "react";
2import Styles from '../styles/navbar.module.css';
3
4class NavBar extends Component {
5 constructor(props) {
6 super(props);
7 this.state = {
8 isOpen: false
9 }
Samuel Shuert604e31d2021-09-02 16:06:20 -050010 this.isTouchDevice = false
pineafana5ce9102021-09-02 17:21:31 +010011 }
Samuel Shuert604e31d2021-09-02 16:06:20 -050012
13 componentDidMount() {
14 let hasTouchScreen = false;
15 if ("maxTouchPoints" in navigator) {
16 hasTouchScreen = navigator.maxTouchPoints > 0;
17 } else if ("msMaxTouchPoints" in navigator) {
18 hasTouchScreen = navigator.msMaxTouchPoints > 0;
19 } else {
20 const mQ = window.matchMedia && matchMedia("(pointer:coarse)");
21 if (mQ && mQ.media === "(pointer:coarse)") {
22 hasTouchScreen = !!mQ.matches;
23 } else if ("orientation" in window) {
24 hasTouchScreen = true;
25 } else {
26 var UA = navigator.userAgent;
27 hasTouchScreen = /\b(BlackBerry|webOS|iPhone|IEMobile)\b/i.test(UA) || /\b(Android|Windows Phone|iPad|iPod)\b/i.test(UA);
28 }
29 }
30 if (hasTouchScreen) {
31 this.isTouchDevice = true
32 } else {
33 this.isTouchDevice = false
34 }
35 }
36
37 onEnter() {
38 if ( !this.isTouchDevice ) {
39 return this.toggleVertical(this, true)
40 }
41 }
42
43 onLeave() {
44 return this.toggleVertical(this, false)
45 }
46
47 onClick() {
48 if ( this.isTouchDevice ) {
49 return this.toggleVertical(this)
50 }
51 }
pineafana5ce9102021-09-02 17:21:31 +010052
53 toggleVertical(prevState, force=null) {
54 this.setState(prevState => ({
55 isOpen: (force === null) ? !prevState.isOpen : force
56 }));
57 }
58
59 render() {
60 return (
61 <>
Samuel Shuert604e31d2021-09-02 16:06:20 -050062 <div className={Styles.container + " " + (this.state.isOpen ? Styles.containerOpen : null)} onMouseLeave={() => {this.onLeave()}}>
pineafana5ce9102021-09-02 17:21:31 +010063 <div className={Styles.group}>
Samuel Shuert604e31d2021-09-02 16:06:20 -050064 <img className={Styles.headerIcon} src="/Icons/CMP.svg" onMouseEnter={() => {this.onEnter()}} onClick={() => {this.onClick()}}/>
65 <a href="/#"><img className={Styles.icon} src="/Icons/CMP.svg"/></a>
66 <a href="/gps#"><img className={Styles.icon} src="/Icons/GS.svg"/></a>
67 <a href="/rsm#"><img className={Styles.icon} src="/Icons/RM.svg"/></a>
68 <a href="/clicksforms#"><img className={Styles.icon} src="/Icons/CF.svg"/></a>
69 {/* <a href="/castaway#"><img className={Styles.icon} src="/Icons/CA.svg"/></a> */}
Samuel Shuert52f37772021-09-02 12:29:40 -050070 {/* <a href="https://clcks.dev"><img className={Styles.icon} src="/Icons/CL.svg"/></a> */}
pineafana5ce9102021-09-02 17:21:31 +010071 </div>
72 <div className={Styles.group}>
Samuel Shuert604e31d2021-09-02 16:06:20 -050073 <a href="/#"><img className={Styles.icon} src="/Icons/CMP.svg"/></a>
pineafana5ce9102021-09-02 17:21:31 +010074 </div>
75 </div>
76 </>
77 )
78 }
79}
80
81export default NavBar;