mirror of
https://github.com/bellingcat/ukraine-timemap.git
synced 2026-06-12 13:28:36 +03:00
add NarrativeAdjust as arrows above timeline
This commit is contained in:
@@ -126,6 +126,10 @@ class Dashboard extends React.Component {
|
||||
getCategoryColor={category => this.getCategoryColor(category)}
|
||||
/>
|
||||
<NarrativeControls
|
||||
narrative={!!app.narrative ? {
|
||||
...app.narrative,
|
||||
current: app.narrativeState.current
|
||||
} : null}
|
||||
methods={{
|
||||
onNext: () => this.moveInNarrative(1),
|
||||
onPrev: () => this.moveInNarrative(-1),
|
||||
@@ -165,16 +169,6 @@ function mapDispatchToProps(dispatch) {
|
||||
}
|
||||
}
|
||||
|
||||
function injectSource(id) {
|
||||
return state => ({
|
||||
...state,
|
||||
app: {
|
||||
...state.app,
|
||||
source: state.domain.sources[id]
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
export default connect(
|
||||
state => state,
|
||||
mapDispatchToProps,
|
||||
|
||||
16
src/components/presentational/NarrativeAdjust.js
Normal file
16
src/components/presentational/NarrativeAdjust.js
Normal file
@@ -0,0 +1,16 @@
|
||||
import React from 'react'
|
||||
|
||||
export default ({ isDisabled, direction, onClickHandler }) => {
|
||||
return (
|
||||
<div
|
||||
className={`narrative-adjust ${direction}`}
|
||||
onClick={!isDisabled ? onClickHandler : null}
|
||||
>
|
||||
<i
|
||||
className={`material-icons ${isDisabled ? 'disabled' : ''}`}
|
||||
>
|
||||
chevron_{direction}
|
||||
</i>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
@@ -3,37 +3,7 @@ import { connect } from 'react-redux'
|
||||
import { selectActiveNarrative } from '../../selectors'
|
||||
|
||||
function NarrativeCard ({ narrative }) {
|
||||
// function renderClose() {
|
||||
// return (
|
||||
// <button
|
||||
// className='side-menu-burg is-active'
|
||||
// onClick={() => { onSelectNarrative(null) }}
|
||||
// >
|
||||
// <span></span>
|
||||
// </button>
|
||||
// )
|
||||
// }
|
||||
|
||||
// function _renderActions(current, steps) {
|
||||
// const prevExists = current !== 0
|
||||
// const nextExists = current < steps.length - 1
|
||||
// return (
|
||||
// <div className='actions'>
|
||||
// <div
|
||||
// className={`${prevExists ? '' : 'disabled'} action`}
|
||||
// onClick={prevExists ? onPrev : null}>←
|
||||
// </div>
|
||||
// <div
|
||||
// className={`${nextExists ? '' : 'disabled'} action`}
|
||||
// onClick={nextExists ? onNext : null}>→
|
||||
// </div>
|
||||
// </div>
|
||||
// )
|
||||
// }
|
||||
|
||||
// no display if no narrative
|
||||
if (!narrative) return null
|
||||
|
||||
// no display if no narrative
|
||||
const { steps, current } = narrative
|
||||
|
||||
if (steps[current]) {
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import React from 'react'
|
||||
import NarrativeCard from './NarrativeCard'
|
||||
import NarrativeAdjust from './NarrativeAdjust'
|
||||
|
||||
export default ({ narrative, methods }) => {
|
||||
// function renderClose() {
|
||||
@@ -30,11 +31,25 @@ export default ({ narrative, methods }) => {
|
||||
// )
|
||||
// }
|
||||
|
||||
if (!narrative) return null
|
||||
|
||||
const { current, steps } = narrative
|
||||
const prevExists = current !== 0
|
||||
const nextExists = current < steps.length - 1
|
||||
|
||||
return (
|
||||
<React.Fragment>
|
||||
<NarrativeCard narrative={narrative} />
|
||||
<NarrativeAdjust
|
||||
isDisabled={!prevExists}
|
||||
direction='left'
|
||||
onClickHandler={methods.onPrev}
|
||||
/>
|
||||
<NarrativeAdjust
|
||||
isDisabled={!nextExists}
|
||||
direction='right'
|
||||
onClickHandler={methods.onNext}
|
||||
/>
|
||||
</React.Fragment>
|
||||
)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user