From 9dea8f719d0cf79e12b14d8c757e741ded4cbd4b Mon Sep 17 00:00:00 2001 From: Nikola Bjelo Date: Tue, 6 Nov 2018 23:11:37 +0100 Subject: [PATCH] Putting in place a minimal dropdown system (1lvl) --- client/src/views/header/imports.js | 30 ++++++++++++ client/src/views/header/index.js | 75 ++++++++++++++++++++---------- 2 files changed, 80 insertions(+), 25 deletions(-) create mode 100644 client/src/views/header/imports.js diff --git a/client/src/views/header/imports.js b/client/src/views/header/imports.js new file mode 100644 index 000000000..6a54601bf --- /dev/null +++ b/client/src/views/header/imports.js @@ -0,0 +1,30 @@ +import { + Search, + GamepadRounded, + AccessibilityNew, + LibraryAdd +} from '@material-ui/icons' + +const eventsMenus = { + title: 'Events', + 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: '' } + ] +} + +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: '' } + ] +} + +const allMenus = [ eventsMenus, teamsMenus ] + +export default allMenus diff --git a/client/src/views/header/index.js b/client/src/views/header/index.js index 2f46a9dea..d96f17c85 100644 --- a/client/src/views/header/index.js +++ b/client/src/views/header/index.js @@ -7,7 +7,6 @@ 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' -import classNames from 'classnames' // icons import HomeIcon from '@material-ui/icons/Home' @@ -15,21 +14,13 @@ import ExitIcon from '@material-ui/icons/ExitToApp' import { Link } from 'react-router-dom' -import { getItem } from '../../utils/local-storage' - // components import { LoggedIn } from './LoggedIn' import { LoggedOut } from './LoggedOut' +import allMenus from './imports' import AALogo from '../../assets/advanced-algos/aa-logo-dark.svg' -const ChartsLink = props => -const UsersLink = props => -const TeamsLink = props => -const EventsLink = props => -const KeyVaultLink = props => -const HomeLink = props => - const styles = theme => ({ '@global': { body: { @@ -62,6 +53,25 @@ const styles = theme => ({ }, 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' } }) @@ -70,7 +80,7 @@ class Header extends Component { super(props) this.state = { user: null, - open: false + open: null } } @@ -81,8 +91,32 @@ class Header extends Component { render () { let { classes, auth } = this.props + let { open } = this.state let user = JSON.parse(this.state.user) + + const menus = allMenus.map((menu, index) => { + return ( +
this.setState({ open: index })} + onMouseLeave={() => this.setState({ open: null })} + > + +
+ { + menu.submenus.map((submenu, index) => { + // const Icon = submenu.icon + return ( + + ) + })} +
+
+ ) + }) + return (
- - - - - + + { menus }