Working unresponsive version
This commit is contained in:
1 parent
fc6331a434
commit
51c539f31e
7 files changed
+251
-287
No files matched your search
@@ -1,8 +1,5 @@
|
||||
import React from 'react'
|
||||
import PropTypes from 'prop-types'
|
||||
// import { graphql } from 'react-apollo'
|
||||
|
||||
import LoggedInMenu from './LoggedInMenu'
|
||||
import { Link } from 'react-router-dom'
|
||||
|
||||
import { isDefined } from '../../../utils/js-helpers'
|
||||
|
||||
@@ -27,15 +24,15 @@ export const LoggedIn = props => {
|
||||
}
|
||||
|
||||
return (
|
||||
<div>
|
||||
<LoggedInMenu menuLabel={displayName} auth={auth} />
|
||||
</div>
|
||||
|
||||
<li className='primaryLink hasChildren'>
|
||||
<Link to='/users/user'> {displayName} </Link>
|
||||
<ul className='subMenu'>
|
||||
<li><Link to='/users/user' > Profile </Link></li>
|
||||
<li><a href='#' onClick={() => auth.logout()}> Logout </a></li>
|
||||
</ul>
|
||||
</li>
|
||||
)
|
||||
}
|
||||
|
||||
LoggedIn.propTypes = {
|
||||
user: PropTypes.object.isRequired,
|
||||
auth: PropTypes.object.isRequired
|
||||
}
|
||||
|
||||
export default LoggedIn
|
||||
@@ -1,77 +0,0 @@
|
||||
import React, { Component } from 'react'
|
||||
import PropTypes from 'prop-types'
|
||||
import Button from '@material-ui/core/Button'
|
||||
import Menu from '@material-ui/core/Menu'
|
||||
import MenuItem from '@material-ui/core/MenuItem'
|
||||
import { Link } from 'react-router-dom'
|
||||
|
||||
import ProfileIcon from '@material-ui/icons/Person'
|
||||
import LogoutIcon from '@material-ui/icons/DirectionsWalk'
|
||||
|
||||
const UserLink = props => <Link to='/users/user' {...props} />
|
||||
const LogoutLink = props => <Link to='/' {...props} />
|
||||
|
||||
class LoggedInUserMenu extends Component {
|
||||
constructor (props) {
|
||||
super(props)
|
||||
|
||||
this.handleMenu = this.handleMenu.bind(this)
|
||||
this.handleClose = this.handleClose.bind(this)
|
||||
this.handleLogout = this.handleLogout.bind(this)
|
||||
|
||||
this.state = {
|
||||
menu: null
|
||||
}
|
||||
}
|
||||
|
||||
render () {
|
||||
const { menuLabel } = this.props
|
||||
return (
|
||||
<React.Fragment>
|
||||
<Button
|
||||
aria-owns={this.state.open ? 'render-props-menu' : null}
|
||||
aria-haspopup='true'
|
||||
onClick={e => this.handleMenu(e)}
|
||||
color='inherit'
|
||||
>
|
||||
{menuLabel}
|
||||
</Button>
|
||||
<Menu
|
||||
id='render-props-menu'
|
||||
anchorEl={this.state.menu}
|
||||
open={Boolean(this.state.menu)}
|
||||
onClose={this.handleClose}
|
||||
>
|
||||
<MenuItem onClick={this.handleClose} component={UserLink}>
|
||||
<ProfileIcon />
|
||||
<div>Profile</div>
|
||||
</MenuItem>
|
||||
<MenuItem onClick={this.handleLogout} component={LogoutLink}>
|
||||
<LogoutIcon />
|
||||
<div>Logout</div>
|
||||
</MenuItem>
|
||||
</Menu>
|
||||
</React.Fragment>
|
||||
)
|
||||
}
|
||||
|
||||
handleMenu (e) {
|
||||
this.setState({ menu: e.currentTarget })
|
||||
}
|
||||
|
||||
handleClose () {
|
||||
this.setState({ menu: null })
|
||||
}
|
||||
|
||||
handleLogout () {
|
||||
this.props.auth.logout()
|
||||
this.setState({ menu: null })
|
||||
}
|
||||
}
|
||||
|
||||
LoggedInUserMenu.propTypes = {
|
||||
menuLabel: PropTypes.string.isRequired,
|
||||
auth: PropTypes.object.isRequired
|
||||
}
|
||||
|
||||
export default LoggedInUserMenu
|
||||
@@ -1,15 +0,0 @@
|
||||
import React from 'react'
|
||||
import PropTypes from 'prop-types'
|
||||
import Button from '@material-ui/core/Button'
|
||||
|
||||
export const LoggedOut = ({ auth }) => (
|
||||
<div onClick={() => auth.login()}>
|
||||
<Button color='inherit'>Login / Sign up</Button>
|
||||
</div>
|
||||
)
|
||||
|
||||
LoggedOut.propTypes = {
|
||||
auth: PropTypes.object.isRequired
|
||||
}
|
||||
|
||||
export default LoggedOut
|
||||
@@ -5,14 +5,14 @@ import {
|
||||
LibraryAdd
|
||||
} from '@material-ui/icons'
|
||||
|
||||
const eventsMenus = {
|
||||
title: 'Events',
|
||||
const usersMenus = {
|
||||
title: 'Users',
|
||||
to: '/events',
|
||||
submenus: [
|
||||
{ title: 'Look for an event', to: '/events', icon: Search, text: '' },
|
||||
{ title: 'Events you are enrolled in', to: '/events/my', icon: GamepadRounded, text: '' },
|
||||
{ title: 'Your hosted competition', to: '/events/host', icon: AccessibilityNew, text: '' },
|
||||
{ title: 'Host a new competition', to: '/events/create', icon: LibraryAdd, text: '' }
|
||||
{ title: 'Your profile', to: '/users/user', icon: Search },
|
||||
{ title: 'Directory', to: '/users/browse', icon: GamepadRounded },
|
||||
{ title: 'Search', to: '/users/search', icon: AccessibilityNew },
|
||||
{ title: 'Report', to: '/report/users', icon: LibraryAdd }
|
||||
]
|
||||
}
|
||||
|
||||
@@ -20,11 +20,36 @@ const teamsMenus = {
|
||||
title: 'Teams',
|
||||
to: '/teams',
|
||||
submenus: [
|
||||
{ title: 'All teams', to: '/teams', icon: Search, text: '' },
|
||||
{ title: 'Your teams', to: '/teams/manage-teams', icon: GamepadRounded, text: '' }
|
||||
{ title: 'All teams', to: '/teams', icon: Search },
|
||||
{ title: 'Your teams', to: '/teams/manage-teams', icon: GamepadRounded },
|
||||
{ title: 'Team members', to: '/teams/team-members', icon: GamepadRounded },
|
||||
{ title: 'Financial beings', to: '/teams/financial-beings', icon: GamepadRounded },
|
||||
{ title: 'Report', to: '/report/teams', icon: LibraryAdd }
|
||||
]
|
||||
}
|
||||
|
||||
const allMenus = [ eventsMenus, teamsMenus ]
|
||||
const eventsMenus = {
|
||||
title: 'Events',
|
||||
to: '/events',
|
||||
submenus: [
|
||||
{ title: 'Look for an event', to: '/events', icon: Search },
|
||||
{ title: 'Events you are enrolled in', to: '/events/my', icon: GamepadRounded },
|
||||
{ title: 'Your hosted competition', to: '/events/host', icon: AccessibilityNew },
|
||||
{ title: 'Host a new competition', to: '/events/create', icon: LibraryAdd },
|
||||
{ title: 'Report', to: '/report/events', icon: LibraryAdd }
|
||||
]
|
||||
}
|
||||
|
||||
const keyvaultMenus = {
|
||||
title: 'Key Vault',
|
||||
to: '/events',
|
||||
submenus: [
|
||||
{ title: 'Manage keys', to: '/key-vault/browse', icon: Search },
|
||||
{ title: 'Add key', to: '/key-vault/addKey', icon: GamepadRounded },
|
||||
{ title: 'Report', to: '/report/key-vault', icon: LibraryAdd }
|
||||
]
|
||||
}
|
||||
|
||||
const allMenus = [ usersMenus, teamsMenus, eventsMenus, keyvaultMenus ]
|
||||
|
||||
export default allMenus
|
||||
@@ -3,25 +3,14 @@ import PropTypes from 'prop-types'
|
||||
import { Link } from 'react-router-dom'
|
||||
import jwtDecode from 'jwt-decode'
|
||||
|
||||
import { withStyles } from '@material-ui/core/styles'
|
||||
import withWidth from '@material-ui/core/withWidth'
|
||||
import AppBar from '@material-ui/core/AppBar'
|
||||
import Toolbar from '@material-ui/core/Toolbar'
|
||||
import Typography from '@material-ui/core/Typography'
|
||||
import IconButton from '@material-ui/core/IconButton'
|
||||
import Button from '@material-ui/core/Button'
|
||||
|
||||
// icons
|
||||
import HomeIcon from '@material-ui/icons/Home'
|
||||
import ExitIcon from '@material-ui/icons/ExitToApp'
|
||||
import MenuIcon from '@material-ui/icons/Menu'
|
||||
|
||||
// styles
|
||||
import styles from './styles'
|
||||
import './styles.scss'
|
||||
|
||||
// components
|
||||
import { LoggedIn } from './LoggedIn'
|
||||
import { LoggedOut } from './LoggedOut'
|
||||
|
||||
import allMenus from './imports'
|
||||
import AALogo from '../../../assets/advanced-algos/aa-logo-dark.svg'
|
||||
@@ -29,22 +18,33 @@ import AALogo from '../../../assets/advanced-algos/aa-logo-dark.svg'
|
||||
class Header extends Component {
|
||||
constructor (props) {
|
||||
super(props)
|
||||
this.toggleMenu = this.toggleMenu.bind(this)
|
||||
this.state = {
|
||||
user: null,
|
||||
open: null,
|
||||
mobileOpen: false
|
||||
onTop: true,
|
||||
user: null
|
||||
}
|
||||
}
|
||||
|
||||
async componentDidMount () {
|
||||
handleScroll () {
|
||||
if (window.pageYOffset > 0) {
|
||||
this.setState({ onTop: false })
|
||||
} else {
|
||||
this.setState({ onTop: true })
|
||||
}
|
||||
}
|
||||
|
||||
componentDidMount () {
|
||||
window.addEventListener('scroll', () => this.handleScroll())
|
||||
const user = window.localStorage.getItem('user')
|
||||
this.setState({ user })
|
||||
}
|
||||
|
||||
componentWillUnmount () {
|
||||
window.removeEventListener('scroll', () => this.handleScroll())
|
||||
}
|
||||
|
||||
render () {
|
||||
let { classes, auth, width } = this.props
|
||||
let { open } = this.state
|
||||
let { auth } = this.props
|
||||
let { onTop } = this.state
|
||||
|
||||
if (window.localStorage.getItem('access_token')) {
|
||||
if (jwtDecode(window.localStorage.getItem('access_token')).exp < new Date().getTime() / 1000) {
|
||||
@@ -54,114 +54,56 @@ class Header extends Component {
|
||||
}
|
||||
let user = JSON.parse(this.state.user)
|
||||
|
||||
const menus = allMenus.map((menu, index) => {
|
||||
const menus = allMenus.map(({ to, title, submenus }, index) => {
|
||||
return (
|
||||
<div
|
||||
key={index}
|
||||
className='dropdown'
|
||||
onMouseEnter={() => this.setState({ open: index })}
|
||||
onMouseLeave={() => this.setState({ open: null })}
|
||||
>
|
||||
<Button component={Link} to={menu.to} color='inherit'>
|
||||
{menu.title}
|
||||
</Button>
|
||||
<div className={open === index ? classes.dropdownContentShown : classes.dropdownContent} >
|
||||
<li key={index} className='primaryLink hasChildren'>
|
||||
<Link to={to}> {title} </Link>
|
||||
<ul className='subMenu'>
|
||||
{
|
||||
menu.submenus.map((submenu, subindex) => {
|
||||
// const Icon = submenu.icon
|
||||
submenus.map(({ icon: Icon, to: subTo, title: subTitle }, subindex) => {
|
||||
return (
|
||||
<Button key={subindex} component={Link} to={submenu.to} className={classes.dropdownButtons}>{submenu.title}</Button>
|
||||
<li key={subindex}><Link to={subTo}> <Icon /> {subTitle} </Link></li>
|
||||
)
|
||||
})}
|
||||
</div>
|
||||
</div>
|
||||
</ul>
|
||||
</li>
|
||||
)
|
||||
})
|
||||
|
||||
const mobileMenusButton = (
|
||||
<Button onClick={() => this.toggleMenu} className={classes.mobileMenu} variant='extendedFab' >
|
||||
<MenuIcon /> MENU
|
||||
</Button>
|
||||
)
|
||||
|
||||
return (
|
||||
<div className={classes.root}>
|
||||
<AppBar
|
||||
position='static'
|
||||
classes={{ root: classes.appBar, colorDefault: classes.colorDefault }}
|
||||
>
|
||||
<Toolbar>
|
||||
<img className={classes.img} src={AALogo} alt='Advanced Algos' />
|
||||
<Typography
|
||||
variant='h6'
|
||||
color='inherit'
|
||||
className={classes.toolbarTitle}
|
||||
>
|
||||
|
||||
</Typography>
|
||||
{(width !== 'xs' && width !== 'sm') &&
|
||||
<React.Fragment>
|
||||
<IconButton
|
||||
className={classes.menuButton}
|
||||
color='inherit'
|
||||
title='Home'
|
||||
component={Link}
|
||||
to='/'
|
||||
>
|
||||
<HomeIcon />
|
||||
</IconButton>
|
||||
<header className={onTop ? 'menu' : 'menu notOnTop'}>
|
||||
<div className='container'>
|
||||
<Link to='/'> <img className='logo' src={AALogo} alt='Advanced Algos' /> </Link>
|
||||
<nav className='links'>
|
||||
<ul className='primaryMenu'>
|
||||
<li className='primaryLink'>
|
||||
<Link to='/'> Charts </Link>
|
||||
</li>
|
||||
{menus}
|
||||
<li className='primaryLink'>
|
||||
<a href='https://www.advancedalgos.net/documentation-quick-start.shtml'> Docs </a>
|
||||
</li>
|
||||
{this.state.user !== undefined && this.state.user !== null ? (
|
||||
<LoggedIn user={user} auth={auth} />
|
||||
) : (
|
||||
|
||||
<Button component={Link} to='/charts' color='inherit'>
|
||||
Charts
|
||||
</Button>
|
||||
|
||||
{ menus }
|
||||
|
||||
<Button
|
||||
href='https://www.advancedalgos.net/documentation-quick-start.shtml'
|
||||
color='inherit'
|
||||
target='_blank'
|
||||
>
|
||||
Docs
|
||||
</Button>
|
||||
|
||||
{this.state.user !== undefined && this.state.user !== null ? (
|
||||
<React.Fragment>
|
||||
<LoggedIn user={user} auth={auth} styles={styles} />
|
||||
</React.Fragment>
|
||||
) : (
|
||||
<LoggedOut auth={auth} styles={styles} />
|
||||
)}
|
||||
|
||||
<IconButton
|
||||
className={classes.menuButton}
|
||||
color='inherit'
|
||||
title='Exit'
|
||||
href='http://www.advancedalgos.net/'
|
||||
>
|
||||
<ExitIcon />
|
||||
</IconButton>
|
||||
</React.Fragment>
|
||||
}
|
||||
{ (width === 'xs' || width === 'sm') ? mobileMenusButton : '' }
|
||||
{ (width === 'xs' || width === 'sm') && this.state.mobileOpen ? menus : '' }
|
||||
</Toolbar>
|
||||
</AppBar>
|
||||
</div>
|
||||
<li className='primaryLink'>
|
||||
<a href='#' onClick={() => auth.login()}> Login / Sign Up </a>
|
||||
</li>
|
||||
)}
|
||||
<li className='primaryLink'>
|
||||
<a href='https://www.advancedalgos.net'> <ExitIcon /> </a>
|
||||
</li>
|
||||
</ul>
|
||||
</nav>
|
||||
</div>
|
||||
</header>
|
||||
)
|
||||
}
|
||||
|
||||
toggleMenu () {
|
||||
this.setState({ mobileOpen: !this.state.mobileOpen })
|
||||
}
|
||||
}
|
||||
|
||||
Header.propTypes = {
|
||||
classes: PropTypes.object.isRequired,
|
||||
auth: PropTypes.object.isRequired,
|
||||
width: PropTypes.string
|
||||
auth: PropTypes.object.isRequired
|
||||
}
|
||||
|
||||
const HeaderWithStyles = withStyles(styles)(Header)
|
||||
|
||||
export default withWidth()(HeaderWithStyles)
|
||||
export default Header
|
||||
@@ -1,61 +0,0 @@
|
||||
const styles = theme => ({
|
||||
'@global': {
|
||||
body: {
|
||||
backgroundColor: theme.palette.common.white
|
||||
}
|
||||
},
|
||||
root: {
|
||||
flexGrow: 1
|
||||
},
|
||||
colorDefault: {
|
||||
color: '#000'
|
||||
},
|
||||
flex: {
|
||||
flexGrow: 1
|
||||
},
|
||||
toolbarTitle: {
|
||||
flex: 1
|
||||
},
|
||||
menuButton: {
|
||||
marginLeft: -12,
|
||||
marginRight: 20
|
||||
},
|
||||
appBar: {
|
||||
position: 'relative'
|
||||
},
|
||||
img: {
|
||||
display: 'block',
|
||||
maxWidth: 240,
|
||||
maxHeight: 48
|
||||
},
|
||||
externalLink: {
|
||||
textDecoration: 'none'
|
||||
},
|
||||
dropdownContent: {
|
||||
display: 'none',
|
||||
position: 'absolute',
|
||||
backgroundColor: '#f1f1f1',
|
||||
minWidth: '160px',
|
||||
boxShadow: '0px 8px 16px 0px rgba(0,0,0,0.2)',
|
||||
zIndex: 1
|
||||
},
|
||||
dropdownContentShown: {
|
||||
display: 'block',
|
||||
position: 'absolute',
|
||||
backgroundColor: '#f1f1f1',
|
||||
minWidth: '160px',
|
||||
boxShadow: '0px 8px 16px 0px rgba(0,0,0,0.2)',
|
||||
zIndex: 1
|
||||
},
|
||||
dropdownButtons: {
|
||||
display: 'block'
|
||||
},
|
||||
mobileMenu: {
|
||||
color: theme.palette.common.white,
|
||||
boxShadow: 'none',
|
||||
border: `1px solid ${theme.palette.common.white}`,
|
||||
background: 'none'
|
||||
}
|
||||
})
|
||||
|
||||
export default styles
|
||||
@@ -0,0 +1,153 @@
|
||||
body{
|
||||
overflow-y:scroll;
|
||||
|
||||
&::-webkit-scrollbar-track {
|
||||
border: 1px solid #000;
|
||||
padding: 2px 0;
|
||||
background-color: #404040;
|
||||
}
|
||||
|
||||
&::-webkit-scrollbar {
|
||||
width: 10px;
|
||||
}
|
||||
|
||||
&::-webkit-scrollbar-thumb {
|
||||
border-radius: 10px;
|
||||
box-shadow: inset 0 0 6px rgba(0,0,0,.3);
|
||||
background-color: #737272;
|
||||
border: 1px solid #000;
|
||||
}
|
||||
}
|
||||
|
||||
$break-big: 1300px;
|
||||
$break-middle: 992px;
|
||||
$break-small: 768px;
|
||||
|
||||
$height-large-device: 131px;
|
||||
$height-small-device: 181px;
|
||||
|
||||
$height-not-top: 87px;
|
||||
|
||||
$image-height-big: 75px;
|
||||
$image-height-small: 45px;
|
||||
|
||||
$text-height: 25px;
|
||||
|
||||
$transition-time: 0.3s;
|
||||
|
||||
$advanced-algos-red: rgb(245,88,88);
|
||||
|
||||
header.menu{
|
||||
transition: $transition-time;
|
||||
&.notOnTop{
|
||||
background-color: rgba(0, 0, 0, 0.6);
|
||||
border-bottom: 1px solid rgba(210, 217, 224, 0.5);
|
||||
height: $height-not-top;
|
||||
.container{
|
||||
border-bottom: 0px;
|
||||
img.logo{
|
||||
margin-top: ( $height-not-top - $image-height-small ) / 2;
|
||||
height: $image-height-small;
|
||||
}
|
||||
nav.links{
|
||||
ul.primaryMenu{
|
||||
li.primaryLink{
|
||||
padding-top: ( $height-not-top - $text-height ) / 2;
|
||||
padding-bottom: ( $height-not-top - $text-height ) / 2;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
position: fixed;
|
||||
height: $height-large-device;
|
||||
width: 100vw;
|
||||
z-index: 125;
|
||||
|
||||
@media screen and (max-width: $break-small) {
|
||||
height: $height-small-device;
|
||||
}
|
||||
.container{
|
||||
height: 100%;
|
||||
border-bottom: 1px solid rgba(142, 144, 146, 0.3);
|
||||
|
||||
width: 100%;
|
||||
@media screen and (min-width: $break-small) {
|
||||
width: 750px;
|
||||
}
|
||||
@media screen and (min-width: $break-middle) {
|
||||
width: 970px;
|
||||
}
|
||||
@media screen and (min-width: $break-big) {
|
||||
width: 1270px;
|
||||
}
|
||||
|
||||
padding-left: 15px;
|
||||
padding-right: 15px;
|
||||
margin-left: auto;
|
||||
margin-right: auto;
|
||||
|
||||
img.logo{
|
||||
transition: $transition-time;
|
||||
margin-top: ( $height-large-device - $image-height-big ) / 2 ;
|
||||
height: $image-height-big;
|
||||
}
|
||||
nav.links{
|
||||
float: right;
|
||||
ul.primaryMenu{
|
||||
margin: 0 4px 0 0;
|
||||
list-style: none;
|
||||
|
||||
font-family: 'Saira';
|
||||
font-size: 12px;
|
||||
font-weight: 700;
|
||||
line-height: $text-height;
|
||||
text-transform: uppercase;
|
||||
li.primaryLink{
|
||||
transition: $transition-time;
|
||||
display: block;
|
||||
float: left;
|
||||
position: relative;
|
||||
padding-top: ( $height-large-device - $text-height ) / 2;
|
||||
padding-bottom: ( $height-large-device - $text-height ) / 2;
|
||||
padding-right: 21px;
|
||||
padding-left: 21px;
|
||||
a{
|
||||
color: white;
|
||||
text-decoration: none;
|
||||
&:hover{
|
||||
color: $advanced-algos-red;
|
||||
}
|
||||
}
|
||||
ul.subMenu{
|
||||
display: none;
|
||||
position: absolute;
|
||||
top: 100%;
|
||||
left: 0;
|
||||
|
||||
padding: 18px 30px;
|
||||
list-style: none;
|
||||
font-family: 'Saira';
|
||||
font-size: 12px;
|
||||
font-weight: 300;
|
||||
line-height: $text-height;
|
||||
|
||||
min-width: 240px;
|
||||
background-color: rgba(0, 0, 0, 0.6);
|
||||
li{
|
||||
height: 30px;
|
||||
}
|
||||
}
|
||||
&:hover{
|
||||
&>a{
|
||||
color: $advanced-algos-red;
|
||||
}
|
||||
ul.subMenu{
|
||||
display: block;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user