Skip to content

Commit

Permalink
Merge branch 'dszlachta-240_grid'
Browse files Browse the repository at this point in the history
  • Loading branch information
tjayrush committed Jan 27, 2020
2 parents a8324dc + 1a2a507 commit 5cfee28
Show file tree
Hide file tree
Showing 26 changed files with 469 additions and 248 deletions.
43 changes: 9 additions & 34 deletions frontend/src/App.css
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
:root {
--color-background: #8d9cab;
--logo-width: 50px;
--logo-height: 70px;
--header-font-size: 1.8em;
--header-small-factor: 0.6;
--footer-height: 84px;
--color-background: #8d9cab;
--logo-width: 50px;
--logo-height: 70px;
--header-font-size: 1.8em;
--header-small-factor: 0.6;
--footer-height: 84px;
--color-border-primary: #777;
--color-border-seconary: #ddd;
}

/*------------------------------------------*/
Expand All @@ -20,8 +22,7 @@
}

/*------------------------------------------*/
.header-item,
.body-item {
.header-item {
display: flex;
flex-flow: row nowrap;
align-content: flex-start;
Expand Down Expand Up @@ -80,32 +81,11 @@
font-size: calc(var(--header-font-size) * var(--header-small-factor));
}

/*------------------------------------------*/
.left-body-container {
display: flex;
flex-flow: column nowrap;
min-width: 7%;
padding: 3px 0px;
}

.right-body-container {
display: flex;
flex-flow: row nowrap;
justify-content: space-between;
border: 1px solid #777;
background-color: white;
}

/*------------------------------------------*/
.menu-panel {
border-right: 1px solid #ddd;
}

/*------------------------------------------*/
.status-panel {
border-right: 1px solid #ddd;
}

/*------------------------------------------*/
.inner-panel {
flex-basis: auto;
Expand All @@ -115,11 +95,6 @@
/* background-color: pink; */
}

/*------------------------------------------*/
.help-panel {
border-left: 1px solid #ddd;
}

/*------------------------------------------*/
.logo {
width: var(--logo-width);
Expand Down
56 changes: 8 additions & 48 deletions frontend/src/App.js
Original file line number Diff line number Diff line change
@@ -1,23 +1,17 @@
import React, { Fragment } from 'react';
import { Route, Redirect } from 'react-router-dom';
import { Redirect } from 'react-router-dom';
import { bindActionCreators } from 'redux';
import { connect } from 'react-redux';
import { history } from './store';
import { SET as SET_LAST_LOCATION } from './last-location-actions';
import { MainMenu, PageHeader, PageFooter, TopScrollObserver } from './components';
import Content from './Content';
import {
PageHeader,
PageFooter,
TopScrollObserver
} from './components';
import './App.css';

//------------------------------------------------------------
import Dashboard, { dashboard_menu } from './pages/dashboard';
import Addresses, { addresses_menu } from './pages/addresses';
import Explore, { explore_menu } from './pages/explore';
import Indicies, { indicies_menu } from './pages/indicies';
import Signatures, { signatures_menu } from './pages/signatures';
import Caches, { caches_menu } from './pages/caches';
import Other, { other_menu } from './pages/other';
import Settings, { settings_menu } from './pages/settings';
import Support, { support_menu } from './pages/support';

//------------------------------------------------------------
const setLastLocation = (lastLocation) => ({ type: SET_LAST_LOCATION, lastLocation });

Expand Down Expand Up @@ -63,7 +57,7 @@ class App extends React.Component {
<TopScrollObserver onTopScroll={this.onTopScroll} />
<div className="page-container">
<PageHeader small={this.state.smallHeader} />
<Body />
<Content />
<PageFooter />
</div>
</Fragment>
Expand All @@ -72,40 +66,6 @@ class App extends React.Component {
}

//------------------------------------------------------------
class Body extends React.Component {
render = () => {
return (
<div className="body-item">
<MainMenu mainMenu={mainMenu} />
<div className="right-body-container">
<Route component={Dashboard} exact path="/" />
<Route component={Addresses} path="/addresses/:subpage?/:query?" />
<Route component={Explore} path="/explore/:subpage?/:query?" />
<Route component={Indicies} path="/indicies/:subpage?/:query?" />
<Route component={Signatures} path="/signatures/:subpage?/:query?" />
<Route component={Caches} path="/caches/:subpage?/:query?" />
<Route component={Other} path="/other/:subpage?/:query?" />
<Route component={Settings} path="/settings/:subpage?/:query?" />
<Route component={Support} path="/support/:subpage?/:query?" />
<Route component={Dashboard} path="/dashboard/:subpage/:query?" />
</div>
</div>
);
};
}

//------------------------------------------------------------
var mainMenu = [];
mainMenu.push(dashboard_menu);
mainMenu.push(addresses_menu);
mainMenu.push(explore_menu);
mainMenu.push(indicies_menu);
mainMenu.push(signatures_menu);
mainMenu.push(caches_menu);
mainMenu.push(other_menu);
mainMenu.push(settings_menu);
mainMenu.push(support_menu);

const mapStateToProps = ({ reducer_LastLocation, router }) => ({
lastLocation: reducer_LastLocation.lastLocation,
currentLocation: router.location
Expand Down
90 changes: 90 additions & 0 deletions frontend/src/Content.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
.app-content {
display: grid;
align-content: flex-start;

grid-template-columns: 1fr 1fr 81fr 1fr;
}

.left-body-container {
display: flex;
flex-flow: column nowrap;
padding: 3px 0px;
overflow-x: hidden;
}

.left-body-container.expanded {
min-width: 7%;
}

.left-body-container .toggle-button {
background: transparent;
border: none;
color: white;
text-align: left;
padding: 0;
}

.left-body-container.expanded .toggle-button {
text-align: right;
}

.status-panel {
background: white;
border-width: 1px 0 1px 1px;
border-style: solid;
border-color: var(--color-border-primary) var(--color-border-seconary) var(--color-border-primary) var(--color-border-primary);
overflow-x: hidden;
}

main {
display: flex;
flex-flow: row nowrap;
justify-content: space-between;
border: 1px solid var(--color-border-primary);
background-color: white;
}

.help-panel {
background: white;
border-width: 1px 1px 1px 0;
border-style: solid;
border-color: var(--color-border-primary) var(--color-border-primary) var(--color-border-primary) var(--color-border-seconary);
overflow-x: hidden;
}

/* Grid */

/* 1. Help expanded */
.app-content.help-expanded {
grid-template-columns: 1fr 1fr 70fr 12fr;
}

/* 2. Status expanded */
.app-content.status-expanded {
grid-template-columns: 1fr 12fr 70fr 1fr;
}

/* 3. Status and help expanded */
.app-content.status-expanded.help-expanded {
grid-template-columns: 1fr 12fr 59fr 12fr;
}

/* 4. Only menu expanded */
.app-content.menu-expanded {
grid-template-columns: 6fr 1fr 76fr 1fr;
}

/* 5. Menu and help expanded */
.app-content.menu-expanded.help-expanded {
grid-template-columns: 6fr 1fr 65fr 12fr;
}

/* 6. Menu and status expanded */
.app-content.menu-expanded.status-expanded {
grid-template-columns: 6fr 12fr 65fr 1fr;
}

/* 7. Everything expanded expanded */
.app-content.menu-expanded.status-expanded.help-expanded {
grid-template-columns: 6fr 12fr 54fr 12fr;
}
102 changes: 102 additions & 0 deletions frontend/src/Content.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
import React from 'react';
import { Route } from 'react-router-dom';
import { bindActionCreators } from 'redux';
import { connect } from 'react-redux';

import { dashboard_menu } from './pages/dashboard';
import { addresses_menu } from './pages/addresses';
import { explore_menu } from './pages/explore';
import { indicies_menu } from './pages/indicies';
import { signatures_menu } from './pages/signatures';
import { caches_menu } from './pages/caches';
import { other_menu } from './pages/other';
import { settings_menu } from './pages/settings';
import { support_menu } from './pages/support';

import {
STATUS_TOGGLE,
HELP_TOGGLE
} from './components/panels/side-panel-actions';
import { MAIN_MENU_TOGGLE } from './components/menus/main-menu/reducer';
import {
MainMenu,
StatusPanel,
HelpPanel,
PageHelp
} from './components';
import Routes from './routes';
import './Content.css';

const mainMenu = [
dashboard_menu,
addresses_menu,
explore_menu,
indicies_menu,
signatures_menu,
caches_menu,
other_menu,
settings_menu,
support_menu,
];

const toggleStatus = () => ({ type: STATUS_TOGGLE });
const toggleHelp = () => ({ type: HELP_TOGGLE });
const toggleMainMenu = () => ({ type: MAIN_MENU_TOGGLE });

export function Content(props) {
const {
isStatusExpanded,
isHelpExpanded,
isMainMenuExpanded,
toggleStatus,
toggleHelp,
toggleMainMenu
} = props;

const classNames = [
'app-content',
isMainMenuExpanded ? 'menu-expanded' : '',
isStatusExpanded ? 'status-expanded' : '',
isHelpExpanded ? 'help-expanded': ''
].join(' ');

return (
<div className={classNames}>
<MainMenu mainMenu={mainMenu} isExpanded={isMainMenuExpanded} toggle={toggleMainMenu} />
<StatusPanel isExpanded={isStatusExpanded} toggle={toggleStatus} />
<main>
{Routes.map((route, index) => (
<Route
key={index}
render={route.component}
exact={route.exact}
path={route.path} />
))}
</main>
<HelpPanel isExpanded={isHelpExpanded} toggle={toggleHelp}>
<PageHelp />
</HelpPanel>
</div>
);
}

const mapStateToProps = ({ reducer_SidePanels, reducer_MainMenu }) => ({
isStatusExpanded: reducer_SidePanels.isStatusExpanded,
isHelpExpanded: reducer_SidePanels.isHelpExpanded,
isMainMenuExpanded: reducer_MainMenu.isMainMenuExpanded
});

const mapDispatchToProps = (dispatch) =>
bindActionCreators(
{
toggleStatus,
toggleHelp,
toggleMainMenu
},
dispatch
);

export default connect(
mapStateToProps,
mapDispatchToProps
)(Content);
17 changes: 17 additions & 0 deletions frontend/src/components/ExpandShrinkIcon.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import React from 'react';
import { Icon } from './';

const chevronDirectionByShrinkTo = new Map([
['left', { shrink: 'chevron_left', expand: 'chevron_right' }],
['right', { shrink: 'chevron_right', expand: 'chevron_left' }]
]);

const getIconsNames = (shrinkTo) => chevronDirectionByShrinkTo.get(shrinkTo);

export default function ExpandShrinkIcon({ shrinkTo, isExpanded, toggleIcon, onClick }) {
const iconName = toggleIcon || getIconsNames(shrinkTo)[isExpanded ? 'shrink' : 'expand'];

return (
<Icon icon={iconName} onClick={onClick} />
);
}
Loading

0 comments on commit 5cfee28

Please sign in to comment.