blob: 38c12754d21eb098d98b4f4412c52d65f04ab34d [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';
pineafandf39fd42021-09-04 16:05:27 +01003import Cookies from 'js-cookie';
Skyler Turner16c08d32021-11-04 20:06:50 +00004import ThemeChangeButton from './ThemeChangeButton';
pineafandf39fd42021-09-04 16:05:27 +01005// import { setInfo } from "../redux/actions/main"
pineafan8808b712021-09-04 16:11:30 +01006// import { connect } from "react-redux";
pineafandf39fd42021-09-04 16:05:27 +01007// import { makeStore } from "../redux/store";
8
9// const store = makeStore();
pineafana5ce9102021-09-02 17:21:31 +010010
11class NavBar extends Component {
12 constructor(props) {
13 super(props);
14 this.state = {
pineafandf39fd42021-09-04 16:05:27 +010015 isOpen: false,
16 cookie: 'light'
pineafana5ce9102021-09-02 17:21:31 +010017 }
Samuel Shuert604e31d2021-09-02 16:06:20 -050018 this.isTouchDevice = false
pineafan54a1e552021-09-03 17:51:18 +010019 this.hoverSensor = React.createRef();
pineafana5ce9102021-09-02 17:21:31 +010020 }
pineafan54a1e552021-09-03 17:51:18 +010021
Samuel Shuert604e31d2021-09-02 16:06:20 -050022 componentDidMount() {
23 let hasTouchScreen = false;
24 if ("maxTouchPoints" in navigator) {
25 hasTouchScreen = navigator.maxTouchPoints > 0;
26 } else if ("msMaxTouchPoints" in navigator) {
27 hasTouchScreen = navigator.msMaxTouchPoints > 0;
28 } else {
29 const mQ = window.matchMedia && matchMedia("(pointer:coarse)");
30 if (mQ && mQ.media === "(pointer:coarse)") {
31 hasTouchScreen = !!mQ.matches;
32 } else if ("orientation" in window) {
33 hasTouchScreen = true;
34 } else {
35 var UA = navigator.userAgent;
36 hasTouchScreen = /\b(BlackBerry|webOS|iPhone|IEMobile)\b/i.test(UA) || /\b(Android|Windows Phone|iPad|iPod)\b/i.test(UA);
37 }
38 }
39 if (hasTouchScreen) {
40 this.isTouchDevice = true
41 } else {
42 this.isTouchDevice = false
43 }
pineafandf39fd42021-09-04 16:05:27 +010044 this.setState({
45 cookie: Cookies.get('theme')
46 })
Samuel Shuert604e31d2021-09-02 16:06:20 -050047 }
48
Samuel Shuert604e31d2021-09-02 16:06:20 -050049 onClick() {
50 if ( this.isTouchDevice ) {
51 return this.toggleVertical(this)
52 }
53 }
pineafana5ce9102021-09-02 17:21:31 +010054
55 toggleVertical(prevState, force=null) {
56 this.setState(prevState => ({
57 isOpen: (force === null) ? !prevState.isOpen : force
58 }));
59 }
60
61 render() {
62 return (
63 <>
pineafand494b852021-09-03 19:49:49 +010064 <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 +010065 <div className={Styles.group}>
pineafanaed30242021-09-04 09:33:40 +010066 <img alt="CMP" className={Styles.headerIcon} src="/Icons/CMP.svg" onClick={() => {this.onClick()}}/>
67 <a href="/#"><img alt="Home" className={Styles.icon} src="/Icons/Homepage.svg"/></a>
68 <a href="/gps#"><img alt="GPS" className={Styles.icon} src="/Icons/GS.svg"/></a>
69 <a href="/rsm#"><img alt="RSM" className={Styles.icon} src="/Icons/RM.svg"/></a>
70 <a href="/clicksforms#"><img alt="ClicksForms" className={Styles.icon} src="/Icons/CF.svg"/></a>
Samuel Shuert604e31d2021-09-02 16:06:20 -050071 {/* <a href="/castaway#"><img className={Styles.icon} src="/Icons/CA.svg"/></a> */}
Samuel Shuert52f37772021-09-02 12:29:40 -050072 {/* <a href="https://clcks.dev"><img className={Styles.icon} src="/Icons/CL.svg"/></a> */}
pineafana5ce9102021-09-02 17:21:31 +010073 </div>
74 <div className={Styles.group}>
Skyler Turner16c08d32021-11-04 20:06:50 +000075 <ThemeChangeButton/>
pineafana5ce9102021-09-02 17:21:31 +010076 </div>
77 </div>
78 </>
79 )
80 }
81}
82
pineafandf39fd42021-09-04 16:05:27 +010083
84// const mapStateToProps = state => {
85// return { theme: state.main.theme }
86// }
87
88// const mapDispatchToProps = {
89// setInfo
90// }
91
92// const nav = connect(mapStateToProps, mapDispatchToProps)(NavBar);
93// export default nav;
94
pineafana5ce9102021-09-02 17:21:31 +010095export default NavBar;