Implemented left menu

This commit is contained in:
Alejandro Celaya 2018-07-18 20:01:56 +02:00
parent 5a7ac69aff
commit 3ea33d0e38
5 changed files with 74 additions and 7 deletions

View file

@ -1,8 +1,31 @@
import React from 'react'; import React from 'react';
import { NavLink } from 'react-router-dom';
import './AsideMenu.scss'; import './AsideMenu.scss';
export default function AsideMenu() { export default function AsideMenu({ selectedServer }) {
const serverId = selectedServer ? selectedServer.id : '';
return ( return (
<aside className="aside-menu col-md-2 col-sm-2">Aside menu</aside> <aside className="aside-menu col-md-2 col-sm-2">
<nav className="nav flex-column aside-menu__nav">
<NavLink
className="aside-menu__item"
activeClassName="aside-menu__item--selected"
to={`/server/${serverId}/list-short-urls/1`}
isActive={match => match && match.params.serverId === serverId}
>
List short URLs
</NavLink>
<NavLink
className="aside-menu__item"
activeClassName="aside-menu__item--selected"
to={`/server/${serverId}/create-short-url`}
>
Create short code
</NavLink>
<span className="aside-menu__item--divider" />
<span className="aside-menu__item aside-menu__item--danger">Delete this server</span>
</nav>
</aside>
); );
} }

View file

@ -13,3 +13,39 @@
background-color: #f7f7f7; background-color: #f7f7f7;
border-right: 1px solid #eee; border-right: 1px solid #eee;
} }
.aside-menu__nav {
margin-top: 10px;
}
.aside-menu__item {
padding: 10px 20px;
margin: 0 -15px;
text-decoration: none !important;
cursor: pointer;
}
.aside-menu__item:hover {
background-color: $lightHoverColor;
}
.aside-menu__item--selected {
color: #fff;
background-color: $mainColor;
}
.aside-menu__item--selected:hover {
color: #fff;
background-color: $mainColor;
}
.aside-menu__item--divider {
border-bottom: 1px solid #eee;
margin: 20px 0;
}
.aside-menu__item--danger {
color: $dangerColor;
}
.aside-menu__item--danger:hover {
color: #fff;
background-color: $dangerColor;
}

View file

@ -1,12 +1,13 @@
import React from 'react'; import React from 'react';
import { Route, Switch } from 'react-router-dom'; import { Route, Switch } from 'react-router-dom';
import { connect } from 'react-redux';
import ShortUrls from '../short-urls/ShortUrls'; import ShortUrls from '../short-urls/ShortUrls';
import AsideMenu from './AsideMenu'; import AsideMenu from './AsideMenu';
export default function MenuLayout() { export function MenuLayout(props) {
return ( return (
<div className="row"> <div className="row">
<AsideMenu /> <AsideMenu {...props} />
<div className="col-md-10 offset-md-2 col-sm-9 offset-sm-3"> <div className="col-md-10 offset-md-2 col-sm-9 offset-sm-3">
<Switch> <Switch>
<Route <Route
@ -19,3 +20,8 @@ export default function MenuLayout() {
</div> </div>
); );
} }
export default connect(state => ({
selectedServer: state.selectedServer,
shortUrlsListParams: state.shortUrlsListParams,
}))(MenuLayout);

View file

@ -15,10 +15,10 @@ import './ShortUrlsList.scss';
export class ShortUrlsList extends React.Component { export class ShortUrlsList extends React.Component {
componentDidMount() { componentDidMount() {
const { match } = this.props; const { match: { params } } = this.props;
this.props.listShortUrls(match.params.serverId, { this.props.listShortUrls(params.serverId, {
...this.props.shortUrlsListParams, ...this.props.shortUrlsListParams,
page: match.params.page page: params.page
}); });
} }

View file

@ -11,6 +11,8 @@ $xlgMin: 1200px;
// Colors // Colors
$mainColor: #4696e5; $mainColor: #4696e5;
$lightHoverColor: #eee;
$dangerColor: #dc3545;
// Misc // Misc
$headerHeight: 57px; $headerHeight: 57px;