From 2dd83ecee53502254ead0ffb7366e10290fa1cef Mon Sep 17 00:00:00 2001 From: Franc Camps-Febrer Date: Tue, 4 Dec 2018 16:52:36 +0000 Subject: [PATCH] Put bottom actions in its own component --- src/components/TagListPanel.jsx | 1 + src/components/Toolbar.jsx | 209 ++++++------------------ src/components/ToolbarBottomActions.jsx | 69 ++++++++ src/scss/toolbar.scss | 6 +- 4 files changed, 123 insertions(+), 162 deletions(-) create mode 100644 src/components/ToolbarBottomActions.jsx diff --git a/src/components/TagListPanel.jsx b/src/components/TagListPanel.jsx index 252f3a7..fa6667b 100644 --- a/src/components/TagListPanel.jsx +++ b/src/components/TagListPanel.jsx @@ -65,6 +65,7 @@ class TagListPanel extends React.Component { } render() { + return (

Explore data by tag

diff --git a/src/components/Toolbar.jsx b/src/components/Toolbar.jsx index 83708fb..eca3eab 100644 --- a/src/components/Toolbar.jsx +++ b/src/components/Toolbar.jsx @@ -5,88 +5,24 @@ import * as selectors from '../selectors' import { Tab, Tabs, TabList, TabPanel } from 'react-tabs'; import Search from './Search.jsx'; import TagListPanel from './TagListPanel.jsx'; -import SitesIcon from './presentational/Icons/SitesIcon.js'; -import RefreshIcon from './presentational/Icons/RefreshIcon.js'; -import CoeventIcon from './presentational/Icons/CoeventIcon.js'; -import RouteIcon from './presentational/Icons/RouteIcon.js'; +import ToolbarBottomActions from './ToolbarBottomActions.jsx'; import copy from '../js/data/copy.json'; -// NB: i think this entire component can actually be part of a future feature... class Toolbar extends React.Component { - constructor(props) { - super(props); + constructor(props) { + super(props); - this.state = { - tabNum: -1 - }; - } + this.state = { + tabNum: -1 + }; + } - toggleTab(tabNum) { - this.setState({ tabNum: (this.state.tabNum === tabNum) ? -1 : tabNum }); - } + toggleTab(tabNum) { + this.setState({ tabNum: (this.state.tabNum === tabNum) ? -1 : tabNum }); + } - resetAllFilters() { - this.props.actions.resetAllFilters(); - } - - toggleInfoPopup() { - this.props.actions.toggleInfoPopup(); - } - - toggleLanguage() { - this.props.actions.toggleLanguage(); - } - - toggleMapViews(layer) { - this.props.actions.toggleMapView(layer); - } - - toggleGuidedMode() { - this.props.actions.toggleGuidedMode(); - } - - renderMapActions() { - return ( -
- this.toggleMapViews(view)} - isEnabled={this.props.viewFilters.routes} - /> - this.toggleMapViews(view)} - isEnabled={this.props.viewFilters.sites} - /> - this.toggleMapViews(view)} - isEnabled={this.props.viewFilters.coevents} - /> -
- ); - } - - renderBottomActions() { - return ( -
- - {/*}{this.renderMapActions()} -
- - - -
*/} -
- ); - } - - - renderPanelHeader() { + renderClosePanel() { return (
this.toggleTab(-1)}>
@@ -94,46 +30,21 @@ class Toolbar extends React.Component { ); } - renderToolbarTab(tabNum, key) { - const isActive = (tabNum === this.state.tab); - - let classes = (isActive) ? 'toolbar-tab active' : 'toolbar-tab'; - return ( -
{ this.toggleTab(tabNum); }}> -
{key}
-
- ); - } - - renderToolbarTagRoot() { - if (this.props.features.USE_TAGS && - this.props.tags.children) { - const roots = Object.values(this.props.tags.children); - return roots.map((root, idx) => { - return this.renderToolbarTab(idx, root.key); - }) - } - return ''; - } - - renderTagListPanel(tagType) { - const panels_lang = copy[this.props.language].toolbar.panels; - const title = (panels_lang[tagType]) ? panels_lang[tagType].title : tagType; - const overview = (panels_lang[tagType]) ? panels_lang[tagType].overview : ''; - + renderSearch() { + if (this.props.features.USE_SEARCH) { return ( - - ); + + + + ) + } } renderToolbarNarrativePanel() { @@ -155,56 +66,32 @@ class Toolbar extends React.Component { ); } - renderSearch() { - if (this.props.features.USE_SEARCH) { - return ( - - - - ) - } - } - - renderToolbarTagList() { + renderToolbarTagPanel() { if (this.props.features.USE_TAGS && this.props.tags.children) { - const roots = Object.values(this.props.tags.children); - return roots.map((root, idx) => { - return ( - - {this.renderTagListPanel(root.key)} - - ) - }) + return ( + + + + ) } return ''; } - renderToolbarNarratives() { - const isActive = (this.state.tabNum === 0); + renderToolbarTab(tabNum, label) { + const isActive = (this.state.tabNum === tabNum); let classes = (isActive) ? 'toolbar-tab active' : 'toolbar-tab'; return ( -
{ this.toggleTab(0); }}> -
Focus stories
-
- ); - } - - renderToolbarTags() { - const isActive = (this.state.tabNum === 1); - let classes = (isActive) ? 'toolbar-tab active' : 'toolbar-tab'; - - return ( -
{ this.toggleTab(1); }}> -
Explore freely
+
{ this.toggleTab(tabNum); }}> +
{label}
); } @@ -216,10 +103,12 @@ class Toolbar extends React.Component {

{title}

{/*this.renderToolbarTab(0, 'search')*/} - {this.renderToolbarNarratives()} - {this.renderToolbarTags()} + {this.renderToolbarTab(0, 'Focus stories')} + {this.renderToolbarTab(1, 'Explore freely')}
- {this.renderBottomActions()} +
) } @@ -229,10 +118,10 @@ class Toolbar extends React.Component { return (
- {this.renderPanelHeader()} + {this.renderClosePanel()} {this.renderToolbarNarrativePanel()} - {this.renderToolbarTagList()} + {this.renderToolbarTagPanel()}
) diff --git a/src/components/ToolbarBottomActions.jsx b/src/components/ToolbarBottomActions.jsx new file mode 100644 index 0000000..6b58fca --- /dev/null +++ b/src/components/ToolbarBottomActions.jsx @@ -0,0 +1,69 @@ +import React from 'react'; + +import SitesIcon from './presentational/Icons/SitesIcon.js'; +import RefreshIcon from './presentational/Icons/RefreshIcon.js'; +import CoeventIcon from './presentational/Icons/CoeventIcon.js'; +import RouteIcon from './presentational/Icons/RouteIcon.js'; + +class ToolbarBottomActions extends React.Component { + resetAllFilters() { + this.props.actions.resetAllFilters(); + } + + toggleInfoPopup() { + this.props.actions.toggleInfoPopup(); + } + + toggleLanguage() { + this.props.actions.toggleLanguage(); + } + + toggleMapViews(layer) { + this.props.actions.toggleMapView(layer); + } + + toggleGuidedMode() { + this.props.actions.toggleGuidedMode(); + } + + renderMapActions() { + return ( +
+ this.toggleMapViews(view)} + isEnabled={this.props.viewFilters.routes} + /> + this.toggleMapViews(view)} + isEnabled={this.props.viewFilters.sites} + /> + this.toggleMapViews(view)} + isEnabled={this.props.viewFilters.coevents} + /> +
+ ); + } + + render() { + return ( +
+ + {/*}{this.renderMapActions()} +
+ + + +
*/} +
+ ); + } +} + +export default ToolbarBottomActions; diff --git a/src/scss/toolbar.scss b/src/scss/toolbar.scss index f1590b3..9459f1d 100644 --- a/src/scss/toolbar.scss +++ b/src/scss/toolbar.scss @@ -161,10 +161,12 @@ } .toolbar-tab { - display: inline-block; + display: flex; + align-items: center; + justify-content: center; height: 60px; width: 110px; - padding: 10px 0 5px 0; + padding: 5px 0 5px 0; font-weight: 400; text-overflow: ellipsis; overflow: hidden;