From 36c2a5a672c8d44e516cea50fdc8ddc891227246 Mon Sep 17 00:00:00 2001 From: Franc Camps-Febrer Date: Tue, 4 Dec 2018 16:12:51 +0000 Subject: [PATCH] Separate tabs and narratives on tab panels --- src/actions/index.js | 7 +++ src/components/TagListPanel.jsx | 6 +- src/components/Toolbar.jsx | 103 +++++++++++++++++++++----------- src/reducers/app.js | 9 +++ 4 files changed, 87 insertions(+), 38 deletions(-) diff --git a/src/actions/index.js b/src/actions/index.js index 10b3c79..6c326cd 100644 --- a/src/actions/index.js +++ b/src/actions/index.js @@ -247,3 +247,10 @@ export function toggleMapView(layer) { layer } } + +export const TOGGLE_GUIDEDMODE = 'TOGGLE_GUIDEDMODE'; +export function toggleGuidedMode() { + return { + type: TOGGLE_GUIDEDMODE + } +} diff --git a/src/components/TagListPanel.jsx b/src/components/TagListPanel.jsx index b834545..252f3a7 100644 --- a/src/components/TagListPanel.jsx +++ b/src/components/TagListPanel.jsx @@ -13,11 +13,11 @@ class TagListPanel extends React.Component { } componentDidMount() { - this.computeTree(this.props.tags.children[this.props.tagType]); + this.computeTree(this.props.tags);//.children[this.props.tagType]); } componentWillReceiveProps(nextProps) { - this.computeTree(nextProps.tags.children[nextProps.tagType]); + this.computeTree(nextProps.tags);//.children[nextProps.tagType]); } onClickCheckbox(tag) { @@ -67,6 +67,8 @@ class TagListPanel extends React.Component { render() { return (
+

Explore data by tag

+

Explore freely all the data by selecting tags.

{this.renderTree()}
); diff --git a/src/components/Toolbar.jsx b/src/components/Toolbar.jsx index 0b3fab0..83708fb 100644 --- a/src/components/Toolbar.jsx +++ b/src/components/Toolbar.jsx @@ -18,16 +18,12 @@ class Toolbar extends React.Component { super(props); this.state = { - tab: -1 + tabNum: -1 }; } - toggleTab(tabIndex) { - if ( this.state.tab === tabIndex ) { - this.setState({ tab: -1 }); - } else { - this.setState({ tab: tabIndex }); - } + toggleTab(tabNum) { + this.setState({ tabNum: (this.state.tabNum === tabNum) ? -1 : tabNum }); } resetAllFilters() { @@ -46,6 +42,10 @@ class Toolbar extends React.Component { this.props.actions.toggleMapView(layer); } + toggleGuidedMode() { + this.props.actions.toggleGuidedMode(); + } + renderMapActions() { return (
@@ -68,18 +68,19 @@ class Toolbar extends React.Component { renderBottomActions() { return (
- {this.renderMapActions()} + + {/*}{this.renderMapActions()}
- - -
+
*/}
); } @@ -135,6 +136,25 @@ class Toolbar extends React.Component { ); } + renderToolbarNarrativePanel() { + return ( + +

Focus stories

+

Here are some highlighted stories

+ {this.props.narratives.map((narr) => { + return ( +
+ +
+ ) + })} +
+ ); + } + renderSearch() { if (this.props.features.USE_SEARCH) { return ( @@ -167,21 +187,26 @@ class Toolbar extends React.Component { return ''; } - renderToolbarNavs() { - if (this.props.narratives) { - return this.props.narratives.map((nar, idx) => { - const isActive = (idx === this.state.tab); + renderToolbarNarratives() { + const isActive = (this.state.tabNum === 0); + let classes = (isActive) ? 'toolbar-tab active' : 'toolbar-tab'; - let classes = (isActive) ? 'toolbar-tab active' : 'toolbar-tab'; + return ( +
{ this.toggleTab(0); }}> +
Focus stories
+
+ ); + } - return ( -
{ this.toggleTab(idx); }}> -
{nar.label}
-
- ); - }) - } - return ''; + renderToolbarTags() { + const isActive = (this.state.tabNum === 1); + let classes = (isActive) ? 'toolbar-tab active' : 'toolbar-tab'; + + return ( +
{ this.toggleTab(1); }}> +
Explore freely
+
+ ); } renderToolbarTabs() { @@ -191,27 +216,33 @@ class Toolbar extends React.Component {

{title}

{/*this.renderToolbarTab(0, 'search')*/} - {(this.props.isModeGuided) - ? this.renderToolbarNavs() - : this.renderToolbarTagRoot()} + {this.renderToolbarNarratives()} + {this.renderToolbarTags()}
- {/* {this.renderBottomActions()} */} + {this.renderBottomActions()} + + ) + } + + renderToolbarPanels() { + let classes = (this.state.tabNum !== -1) ? 'toolbar-panels' : 'toolbar-panels folded'; + + return ( +
+ {this.renderPanelHeader()} + + {this.renderToolbarNarrativePanel()} + {this.renderToolbarTagList()} +
) } render() { - let classes = (this.state.tab !== -1) ? 'toolbar-panels' : 'toolbar-panels folded'; - return (
{this.renderToolbarTabs()} -
- {this.renderPanelHeader()} - - {this.renderToolbarTagList()} - -
+ {this.renderToolbarPanels()}
); } diff --git a/src/reducers/app.js b/src/reducers/app.js index 85459f2..66fa291 100644 --- a/src/reducers/app.js +++ b/src/reducers/app.js @@ -8,6 +8,7 @@ import { RESET_ALLFILTERS, TOGGLE_LANGUAGE, TOGGLE_MAPVIEW, + TOGGLE_GUIDEDMODE, FETCH_ERROR, } from '../actions'; @@ -87,6 +88,12 @@ function toggleMapView(appState, action) { }); } +function toggleGuidedMode(appState, action) { + return Object.assign({}, appState, { + isModeGuided: !appState.isModeGuided + }) +} + function fetchError(state, action) { return { ...state, @@ -112,6 +119,8 @@ function app(appState = initial.app, action) { return toggleLanguage(appState, action); case TOGGLE_MAPVIEW: return toggleMapView(appState, action); + case TOGGLE_GUIDEDMODE: + return toggleGuidedMode(appState, action); case FETCH_ERROR: return fetchError(appState, action); default: