mirror of
https://github.com/lrnselfreliance/wrolpi.git
synced 2026-12-03 05:09:58 -05:00
A new start
Signed-off-by: Roland <roland@learningselfreliance.com>
This commit is contained in:
commit
9b899f6fc0
135 changed files with 15764 additions and 0 deletions
96
app/src/components/Nav.js
Normal file
96
app/src/components/Nav.js
Normal file
|
|
@ -0,0 +1,96 @@
|
|||
import React from "react";
|
||||
import {NavLink} from "react-router-dom";
|
||||
import {Dropdown, Menu, Responsive} from "semantic-ui-react";
|
||||
|
||||
const responsiveWidth = 500;
|
||||
|
||||
const links = [
|
||||
{
|
||||
text: 'Videos', links: [
|
||||
{to: '/videos', text: 'Newest Videos', exact: true},
|
||||
{to: '/videos/favorites', text: 'Favorites', exact: true},
|
||||
{to: '/videos/channel', text: 'Channels', exact: true},
|
||||
{to: '/videos/manage', text: 'Manage', exact: true},
|
||||
]
|
||||
},
|
||||
{text: 'Inventory', to: '/inventory', exact: true},
|
||||
{text: 'Archive', to: '/archive', exact: true},
|
||||
{
|
||||
text: 'Apps', links: [
|
||||
{to: '/apps/otp', text: 'One Time Pad', exact: true},
|
||||
]
|
||||
},
|
||||
];
|
||||
const admin = {to: '/admin', text: 'Admin', exact: true};
|
||||
const rightLinks = [admin,];
|
||||
|
||||
const collapsedLinks = links.concat([admin,]);
|
||||
|
||||
function DropdownLinks(props) {
|
||||
return (
|
||||
<Dropdown item text={props.link.text}>
|
||||
<Dropdown.Menu>
|
||||
{props.link.links.map((l) => {
|
||||
return (
|
||||
<Link key={l.to} link={l}/>
|
||||
)
|
||||
})}
|
||||
</Dropdown.Menu>
|
||||
</Dropdown>
|
||||
)
|
||||
}
|
||||
|
||||
function Link(props) {
|
||||
let classes = 'item';
|
||||
if (props.link.header) {
|
||||
classes = `${classes} header`;
|
||||
}
|
||||
|
||||
if (!props.link.links) {
|
||||
return (
|
||||
<NavLink
|
||||
className={classes}
|
||||
exact={props.link.exact || false}
|
||||
to={props.link.to}
|
||||
>
|
||||
{props.link.text}
|
||||
</NavLink>
|
||||
)
|
||||
} else {
|
||||
return (
|
||||
<DropdownLinks link={props.link}/>
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
export function NavBar() {
|
||||
return (
|
||||
<Menu>
|
||||
{/*Always show WROLPi home button*/}
|
||||
<Link link={{to: '/', text: 'WROLPi', exact: true}}/>
|
||||
|
||||
{/*Show the links in a menu when on desktop*/}
|
||||
{links.map((link) => {
|
||||
return (
|
||||
<Responsive minWidth={responsiveWidth} as={Link} link={link} key={link.to}/>
|
||||
)
|
||||
})}
|
||||
<Responsive minWidth={responsiveWidth} as={Menu.Menu} position="right">
|
||||
{rightLinks.map((link) => {
|
||||
return (<Link link={link} key={link.to}/>)
|
||||
})}
|
||||
</Responsive>
|
||||
|
||||
{/*Show the menu items in a dropdown when on mobile*/}
|
||||
<Responsive as={Menu.Menu} maxWidth={responsiveWidth - 1} position='right'>
|
||||
<Dropdown item icon="bars">
|
||||
<Dropdown.Menu>
|
||||
{collapsedLinks.map((link) => {
|
||||
return (<Link link={link} key={link.to}/>)
|
||||
})}
|
||||
</Dropdown.Menu>
|
||||
</Dropdown>
|
||||
</Responsive>
|
||||
</Menu>
|
||||
)
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue