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 ( - + { this.goToNarrative(narr); }}> {narr.label} {narr.description} 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.toggleGuidedMode(); }}>Toggle mode {/*}{this.renderMapActions()} { this.toggleLanguage()}}> diff --git a/src/reducers/app.js b/src/reducers/app.js index 66fa291..0b17716 100644 --- a/src/reducers/app.js +++ b/src/reducers/app.js @@ -5,6 +5,7 @@ import { UPDATE_SELECTED, UPDATE_TAGFILTERS, UPDATE_TIMERANGE, + UPDATE_NARRATIVE, RESET_ALLFILTERS, TOGGLE_LANGUAGE, TOGGLE_MAPVIEW, @@ -24,6 +25,12 @@ function updateSelected(appState, action) { }); } +function updateNarrative(appState, action) { + return Object.assign({}, appState, { + narrative: action.narrative + }); +} + function updateTagFilters(appState, action) { const tagFilters = appState.filters.tags.slice(0); const nextActiveState = action.tag.active @@ -113,6 +120,8 @@ function app(appState = initial.app, action) { return updateTagFilters(appState, action); case UPDATE_TIMERANGE: return updateTimeRange(appState, action); + case UPDATE_NARRATIVE: + return updateNarrative(appState, action); case RESET_ALLFILTERS: return resetAllFilters(appState, action); case TOGGLE_LANGUAGE: diff --git a/src/scss/main.scss b/src/scss/main.scss index b36fad6..866e93e 100644 --- a/src/scss/main.scss +++ b/src/scss/main.scss @@ -6,6 +6,7 @@ @import 'loading'; @import 'header'; @import 'cardstack'; +@import 'narrativecard'; @import 'map'; @import 'timeline'; @import 'tag-filters'; diff --git a/src/scss/narrativecard.scss b/src/scss/narrativecard.scss new file mode 100644 index 0000000..3f7f7a5 --- /dev/null +++ b/src/scss/narrativecard.scss @@ -0,0 +1,63 @@ +/* +NARRATIVE INFO +*/ +.narrative-info { + position: fixed; + top: 10px; + left: 130px; + height: auto; + width: 270px; + box-sizing: border-box; + padding: 15px; + max-height: calc(100% - 250px); + overflow: auto; + box-shadow: 0 19px 38px rgba($black, 0.3), 0 15px 12px rgba($black, 0.22); + background: $black; + border: 1px solid $midgrey; + color: $offwhite; + font-family: 'Merriweather', 'Georgia', serif; + + h3, h6 { + text-align: center; + } + + h3 { + font-size: $large; + } + + p { + font-family: 'Lato', 'Helvetica', sans-serif; + font-size: $normal; + line-height: 1.4em; + } + + .actions { + width: 100%; + .action { + width: calc(50% - 5px); + height: 40px; + box-sizing: border-box; + line-height: 40px; + font-family: 'Lato', 'Helvetica', sans-serif; + text-align: center; + display: inline-block; + + &:not(.disabled) { + &:hover { + cursor: pointer; + transition: 0.2s ease; + color: $yellow; + } + } + + &.disabled { + color: $midgrey; + cursor: normal; + } + + &:first-child { + margin-right: 10px; + } + } + } +} diff --git a/src/store/initial.js b/src/store/initial.js index 333100f..a40c807 100644 --- a/src/store/initial.js +++ b/src/store/initial.js @@ -28,6 +28,7 @@ const initial = { error: null, highlighted: null, selected: [], + narrative: null, filters: { timerange: [ d3.timeParse("%Y-%m-%dT%H:%M:%S")("2013-02-23T12:00:00"),
{this.props.narrative.description}
{narr.label}
{narr.description}