Skip to content
This repository has been archived by the owner on Apr 15, 2019. It is now read-only.

Commit

Permalink
Setup React toolbox tabs
Browse files Browse the repository at this point in the history
  • Loading branch information
slaweet committed Jul 28, 2017
1 parent 99e7836 commit 44d8aac
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 7 deletions.
10 changes: 3 additions & 7 deletions src/components/app/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from 'react';
import { Route, Link } from 'react-router-dom';
import { Route } from 'react-router-dom';
import PrivateRoutes from '../privateRoute';
import Account from '../account';
import Header from '../header';
Expand All @@ -10,6 +10,7 @@ import Forging from '../forging';
import styles from './app.css';
import Metronome from '../../utils/metronome';
import Dialog from '../dialog';
import Tabs from '../tabs';
// temporary, will be deleted with #347

// start dispatching sync ticks
Expand All @@ -23,12 +24,7 @@ const App = () => (
<PrivateRoutes path='/main' render={ ({ match }) => (
<main>
<Account />
<section className='main-tabs'>
<Link to={`${match.url}/transactions`}>Transactions</Link>
<Link to={`${match.url}/voting`}>Voting</Link>
<Link to={`${match.url}/forging`}>Forging</Link>
</section>

<Tabs />
<Route path={`${match.url}/transactions`} component={Transactions} />
<Route path={`${match.url}/voting`} component={Voting} />
<Route path={`${match.url}/forging`} component={Forging} />
Expand Down
10 changes: 10 additions & 0 deletions src/components/tabs/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { connect } from 'react-redux';
import { withRouter } from 'react-router';
import Tabs from './tabs';

const mapStateToProps = state => ({
isDelegate: state.account.isDelegate,
});

export default withRouter(connect(mapStateToProps)(Tabs));

17 changes: 17 additions & 0 deletions src/components/tabs/tabs.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
.tab {
background: #f4f4f4;
box-shadow: inset 0px -1px 1px -1px rgba(0, 0, 0, 0.12);
padding-right: 24px;
padding-left: 24px;
}

:global .theme__pointer___1xgdB {
height: 4px;
margin-top: -48px;
}

:global .theme__label___1yb8L.theme__active___2LZ7Z {
background: white;
color: #0288D1;
margin-bottom: -1px;
}
26 changes: 26 additions & 0 deletions src/components/tabs/tabs.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import React from 'react';
import { Tab, Tabs as ToolboxTabs } from 'react-toolbox';
import styles from './tabs.css';

const tabs = [
'Transactions',
'Voting',
'Forging',
];

const getTabs = isDelegate => (tabs.filter(t => t !== 'Forging' || isDelegate));

const getIndex = history => (
tabs.map(t => t.toLowerCase())
.indexOf(history.location.pathname.replace('/main/', '')));

const Tabs = props => (
<ToolboxTabs index={getIndex(props.history)}
onChange={index => props.history.push(`${tabs[index].toLowerCase()}`)}
className='main-tabs'>
{getTabs(props.isDelegate).map((tab, index) =>
<Tab key={index} label={tab} className={styles.tab} />)}
</ToolboxTabs>
);

export default Tabs;

0 comments on commit 44d8aac

Please sign in to comment.