From 51c539f31e649561636d5b3c4a317f149379f10b Mon Sep 17 00:00:00 2001 From: Unknown Date: Thu, 8 Nov 2018 09:06:47 +0100 Subject: [PATCH] Working unresponsive version --- client/src/views/layout/header/LoggedIn.js | 21 +-- .../src/views/layout/header/LoggedInMenu.js | 77 -------- client/src/views/layout/header/LoggedOut.js | 15 -- client/src/views/layout/header/imports.js | 43 ++++- client/src/views/layout/header/index.js | 168 ++++++------------ client/src/views/layout/header/styles.js | 61 ------- client/src/views/layout/header/styles.scss | 153 ++++++++++++++++ 7 files changed, 251 insertions(+), 287 deletions(-) delete mode 100644 client/src/views/layout/header/LoggedInMenu.js delete mode 100644 client/src/views/layout/header/LoggedOut.js delete mode 100644 client/src/views/layout/header/styles.js create mode 100644 client/src/views/layout/header/styles.scss diff --git a/client/src/views/layout/header/LoggedIn.js b/client/src/views/layout/header/LoggedIn.js index 6d3f8a6a5..2bda15736 100644 --- a/client/src/views/layout/header/LoggedIn.js +++ b/client/src/views/layout/header/LoggedIn.js @@ -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 ( -
- -
+ +
  • + {displayName} + +
  • ) } -LoggedIn.propTypes = { - user: PropTypes.object.isRequired, - auth: PropTypes.object.isRequired -} - export default LoggedIn diff --git a/client/src/views/layout/header/LoggedInMenu.js b/client/src/views/layout/header/LoggedInMenu.js deleted file mode 100644 index 21304e64b..000000000 --- a/client/src/views/layout/header/LoggedInMenu.js +++ /dev/null @@ -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 => -const LogoutLink = 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 ( - - - - - -
    Profile
    -
    - - -
    Logout
    -
    -
    -
    - ) - } - - 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 diff --git a/client/src/views/layout/header/LoggedOut.js b/client/src/views/layout/header/LoggedOut.js deleted file mode 100644 index 7ce0da698..000000000 --- a/client/src/views/layout/header/LoggedOut.js +++ /dev/null @@ -1,15 +0,0 @@ -import React from 'react' -import PropTypes from 'prop-types' -import Button from '@material-ui/core/Button' - -export const LoggedOut = ({ auth }) => ( -
    auth.login()}> - -
    -) - -LoggedOut.propTypes = { - auth: PropTypes.object.isRequired -} - -export default LoggedOut diff --git a/client/src/views/layout/header/imports.js b/client/src/views/layout/header/imports.js index 6a54601bf..1f1cd948c 100644 --- a/client/src/views/layout/header/imports.js +++ b/client/src/views/layout/header/imports.js @@ -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 diff --git a/client/src/views/layout/header/index.js b/client/src/views/layout/header/index.js index 8d88111d6..60c89835e 100644 --- a/client/src/views/layout/header/index.js +++ b/client/src/views/layout/header/index.js @@ -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 ( -
    this.setState({ open: index })} - onMouseLeave={() => this.setState({ open: null })} - > - -
    +
  • + {title} +
      { - menu.submenus.map((submenu, subindex) => { - // const Icon = submenu.icon + submenus.map(({ icon: Icon, to: subTo, title: subTitle }, subindex) => { return ( - +
    • {subTitle}
    • ) })} -
  • -
    + + ) }) - const mobileMenusButton = ( - - ) - return ( -
    - - - Advanced Algos - -   - - {(width !== 'xs' && width !== 'sm') && - - - - +
    +
    + Advanced Algos +
    +
  • + auth.login()}> Login / Sign Up +
  • + )} +
  • + +
  • + + +
    + ) } - - 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 diff --git a/client/src/views/layout/header/styles.js b/client/src/views/layout/header/styles.js deleted file mode 100644 index 9bf2e9855..000000000 --- a/client/src/views/layout/header/styles.js +++ /dev/null @@ -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 diff --git a/client/src/views/layout/header/styles.scss b/client/src/views/layout/header/styles.scss new file mode 100644 index 000000000..7697add81 --- /dev/null +++ b/client/src/views/layout/header/styles.scss @@ -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; + } + } + } + } + } + } +}