diff --git a/src/actions/index.js b/src/actions/index.js index 6c326cd..b406ae8 100644 --- a/src/actions/index.js +++ b/src/actions/index.js @@ -171,6 +171,14 @@ export function updateTimeRange(timerange) { } } +export const UPDATE_NARRATIVE = 'UPDATE_NARRATIVE'; +export function updateNarrative(narrative) { + return { + type: UPDATE_NARRATIVE, + narrative + } +} + export const RESET_ALLFILTERS = 'RESET_ALLFILTERS' export function resetAllFilters() { return { diff --git a/src/components/Dashboard.jsx b/src/components/Dashboard.jsx index 091d969..6fe812f 100644 --- a/src/components/Dashboard.jsx +++ b/src/components/Dashboard.jsx @@ -9,6 +9,7 @@ import LoadingOverlay from './presentational/LoadingOverlay'; import Viewport from './Viewport.jsx'; import Toolbar from './Toolbar.jsx'; import CardStack from './CardStack.jsx'; +import NarrativeCard from './NarrativeCard.js'; import InfoPopUp from './InfoPopup.jsx'; import Timeline from './Timeline.jsx'; import Notification from './Notification.jsx'; @@ -104,6 +105,9 @@ class Dashboard extends React.Component { app={this.props.app} toggle={() => this.props.actions.toggleInfoPopup()} /> + 0) { + this.setState({ step: this.state.step - 1 }); + } + } + + goToNextKeyFrame() { + if (this.state.step < this.props.narrative.steps.length - 1) { + this.setState({ step: this.state.step + 1 }); + } + } + + componentDidUpdate() { + if (this.props.narrative !== null) { + const step = this.props.narrative.steps[this.state.step]; + this.props.onSelect([step.id]); + } + } + + render() { + if (this.props.narrative !== null) { + const steps = this.props.narrative.steps; + const step = steps[this.state.step]; + + return ( +
+
{this.props.narrative.label}
+

{this.props.narrative.description}

+

{this.state.step + 1}/{steps.length}. {step.location}

+
+
this.goToPrevKeyFrame()}>←
+
= this.props.narrative.steps.length - 1) ? 'disabled ' : ''} action`} onClick={() => this.goToNextKeyFrame()}>→
+
+
+ ); + } + return (
); + } +} + +function mapStateToProps(state) { + console.log(state) + return { + narrative: state.app.narrative + } +} +export default connect(mapStateToProps)(NarrativeCard); diff --git a/src/components/Toolbar.jsx b/src/components/Toolbar.jsx index eca3eab..20a888c 100644 --- a/src/components/Toolbar.jsx +++ b/src/components/Toolbar.jsx @@ -34,19 +34,27 @@ class Toolbar extends React.Component { if (this.props.features.USE_SEARCH) { return ( - + ) } } + goToNarrative(narrative) { + this.setState({ + tabNum: -1 + }, () => { + this.props.actions.updateNarrative(narrative); + }); + } + renderToolbarNarrativePanel() { return ( @@ -55,7 +63,7 @@ class Toolbar extends React.Component { {this.props.narratives.map((narr) => { return (
- diff --git a/src/components/ToolbarBottomActions.jsx b/src/components/ToolbarBottomActions.jsx index 6b58fca..082365b 100644 --- a/src/components/ToolbarBottomActions.jsx +++ b/src/components/ToolbarBottomActions.jsx @@ -48,7 +48,6 @@ class ToolbarBottomActions extends React.Component { render() { return (
- {/*}{this.renderMapActions()}