blob: f7ef4e1aeb4164d5b1eaba9825a52f6c52b187d0 [file] [log] [blame]
pineafan54a1e552021-09-03 17:51:18 +01001import React, { Component } from "react";
pineafana5ce9102021-09-02 17:21:31 +01002import Styles from '../styles/navbar.module.css';
Skyler Turner16c08d32021-11-04 20:06:50 +00003import ThemeChangeButton from './ThemeChangeButton';
pineafandf39fd42021-09-04 16:05:27 +01004
pineafana5ce9102021-09-02 17:21:31 +01005
6class NavBar extends Component {
7 constructor(props) {
8 super(props);
9 this.state = {
pineafandf39fd42021-09-04 16:05:27 +010010 isOpen: false,
pineafana5ce9102021-09-02 17:21:31 +010011 }
Samuel Shuert604e31d2021-09-02 16:06:20 -050012 this.isTouchDevice = false
pineafan54a1e552021-09-03 17:51:18 +010013 this.hoverSensor = React.createRef();
pineafana5ce9102021-09-02 17:21:31 +010014 }
pineafan54a1e552021-09-03 17:51:18 +010015
Samuel Shuert604e31d2021-09-02 16:06:20 -050016 componentDidMount() {
17 let hasTouchScreen = false;
18 if ("maxTouchPoints" in navigator) {
19 hasTouchScreen = navigator.maxTouchPoints > 0;
20 } else if ("msMaxTouchPoints" in navigator) {
21 hasTouchScreen = navigator.msMaxTouchPoints > 0;
22 } else {
23 const mQ = window.matchMedia && matchMedia("(pointer:coarse)");
24 if (mQ && mQ.media === "(pointer:coarse)") {
25 hasTouchScreen = !!mQ.matches;
26 } else if ("orientation" in window) {
27 hasTouchScreen = true;
28 } else {
29 var UA = navigator.userAgent;
30 hasTouchScreen = /\b(BlackBerry|webOS|iPhone|IEMobile)\b/i.test(UA) || /\b(Android|Windows Phone|iPad|iPod)\b/i.test(UA);
31 }
32 }
33 if (hasTouchScreen) {
34 this.isTouchDevice = true
35 } else {
36 this.isTouchDevice = false
37 }
38 }
39
Samuel Shuert604e31d2021-09-02 16:06:20 -050040 onClick() {
41 if ( this.isTouchDevice ) {
42 return this.toggleVertical(this)
43 }
44 }
pineafana5ce9102021-09-02 17:21:31 +010045
46 toggleVertical(prevState, force=null) {
47 this.setState(prevState => ({
48 isOpen: (force === null) ? !prevState.isOpen : force
49 }));
50 }
51
52 render() {
53 return (
54 <>
pineafand494b852021-09-03 19:49:49 +010055 <div ref={this.hoverSensor} className={this.isTouchDevice ? (Styles.container + " " + (this.state.isOpen ? Styles.containerOpen : null)) : Styles.containerDesktop + " " + Styles.container}>
pineafana5ce9102021-09-02 17:21:31 +010056 <div className={Styles.group}>
pineafanf97734b2021-11-23 21:11:00 +000057 <img alt="CMP" className={Styles.headerIcon} src="https://assets.clicksminuteper.net/company/logo/circle.svg" onClick={() => {this.onClick()}}/>
pineafana841c762021-11-14 21:21:04 +000058 <a href="/#"><img alt="Home" className={Styles.icon} src="https://assets.clicksminuteper.net/web/icons/home.svg"/></a>
pineafanf97734b2021-11-23 21:11:00 +000059 <a href="/gps#"><img alt="GPS" className={Styles.icon} src="https://assets.clicksminuteper.net/bots/gps/circle.svg"/></a>
60 <a href="/rsm#"><img alt="RSM" className={Styles.icon} src="https://assets.clicksminuteper.net/bots/rsm/circle.svg"/></a>
61 <a href="/clicksforms#"><img alt="ClicksForms" className={Styles.icon} src="https://assets.clicksminuteper.net/bots/clicksforms/circle.svg"/></a>
Samuel Shuert604e31d2021-09-02 16:06:20 -050062 {/* <a href="/castaway#"><img className={Styles.icon} src="/Icons/CA.svg"/></a> */}
Samuel Shuert52f37772021-09-02 12:29:40 -050063 {/* <a href="https://clcks.dev"><img className={Styles.icon} src="/Icons/CL.svg"/></a> */}
pineafana5ce9102021-09-02 17:21:31 +010064 </div>
65 <div className={Styles.group}>
Skyler Turner16c08d32021-11-04 20:06:50 +000066 <ThemeChangeButton/>
pineafana5ce9102021-09-02 17:21:31 +010067 </div>
68 </div>
69 </>
70 )
71 }
72}
73
pineafana5ce9102021-09-02 17:21:31 +010074export default NavBar;