add NarrativeAdjust as arrows above timeline

This commit is contained in:
Lachlan Kermode
2019-01-08 18:01:08 +00:00
parent 51d7dd8191
commit 46aeaf5217
5 changed files with 70 additions and 42 deletions

View 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>
)
}

View File

@@ -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}>&larr;
// </div>
// <div
// className={`${nextExists ? '' : 'disabled'} action`}
// onClick={nextExists ? onNext : null}>&rarr;
// </div>
// </div>
// )
// }
// no display if no narrative
if (!narrative) return null
// no display if no narrative
const { steps, current } = narrative
if (steps[current]) {

View File

@@ -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>
)
}