import React, {useContext} from "react"; import {NavLink} from "react-router-dom"; import {Dropdown, Menu, Responsive} from "semantic-ui-react"; import {StatusContext, ThemeContext} from "../contexts/contexts"; import Icon from "semantic-ui-react/dist/commonjs/elements/Icon"; import {DarkModeToggle, HotspotStatusIcon, NAME} from "./Common"; const responsiveWidth = 500; const links = [ {text: 'Videos', to: '/videos', key: 'videos'}, {text: 'Archive', to: '/archive', key: 'archive'}, {text: 'Map', to: '/map', key: 'map'}, {text: 'Files', to: '/files', key: 'files'}, {text: 'Inventory', to: '/inventory', key: 'inventory'}, { key: 'apps', text: 'Apps', links: [ {to: '/apps/otp', text: 'One Time Pad', exact: true}, ] }, ]; const admin = {to: '/admin', text: 'Admin', exact: true, key: 'admin'}; const rightLinks = [admin,]; const collapsedLinks = links.concat([admin,]); function DropdownLinks(props) { return ( {props.link.links.map((l) => { return ( ) })} ) } function MenuLink(props) { // Wrapper around NavLink to handle Navlink/Dropdown change. let classes = 'item'; if (props.link.header) { classes = `${classes} header`; } if (!props.link.links) { const exact = props.link.exact ? {exact: null} : {}; return ( {props.link.text} ) } else { return ( ) } } function NavIcon(props) { return
{props.children}
} export function NavBar() { const {status} = useContext(StatusContext); const wrol_mode = status ? status['wrol_mode'] : null; const name = NAME || 'WROLPi'; const topNavText = wrol_mode ? <>{name}  : name; const {i} = useContext(ThemeContext); return ( {/*Always show WROLPi home button*/} {/*Show the links in a menu when on desktop*/} {links.map((link) => { return ( ) })} {rightLinks.map((link) => )} {/*Show the menu items in a dropdown when on mobile*/} {collapsedLinks.map((link) => )} ) }