apply narratives only if FILTERS_AS_NARRATIVES set

This commit is contained in:
Lachlan Kermode
2020-06-19 16:08:45 +02:00
parent 0c09131a0d
commit a686268839
2 changed files with 43 additions and 28 deletions

View File

@@ -10,7 +10,15 @@ const defaultStyles = {
stroke: 'none'
}
function MapNarratives ({ styles, onSelectNarrative, svg, narrative, narratives, projectPoint, features }) {
function MapNarratives ({
styles,
onSelectNarrative,
svg,
narrative,
narratives,
projectPoint,
features
}) {
function getNarrativeStyle (narrativeId) {
const styleName = (narrativeId && narrativeId in styles)
? narrativeId
@@ -133,29 +141,32 @@ function MapNarratives ({ styles, onSelectNarrative, svg, narrative, narratives,
let lastMarked = null
for (let idx = 0; idx < n.steps.length; idx += 1) {
const step = n.steps[idx]
if (lastMarked) {
arrows.push(renderBetweenSteps(lastMarked, step, {
strokeWidth: '1px',
stroke: step.colour
}))
if (features.FILTERS_AS_NARRATIVES) {
for (let idx = 0; idx < n.steps.length; idx += 1) {
const step = n.steps[idx]
if (lastMarked) {
arrows.push(renderBetweenSteps(
lastMarked,
step,
n.withLines ? { strokeWidth: '1px', stroke: step.colour } : {})
)
}
lastMarked = step
}
lastMarked = step
}
} else {
for (let idx = 0; idx < n.steps.length; idx += 1) {
const step = n.steps[idx]
const _idx = step.narratives.indexOf(n.id)
const stepStyle = step.narrative___stepStyles[_idx]
// for (let idx = 0; idx < n.steps.length; idx += 1) {
// const step = n.steps[idx]
// const _idx = step.narratives.indexOf(n.id)
// const stepStyle = step.narrative___stepStyles[_idx]
//
// if (stepStyle !== 'None') {
// if (lastMarked) {
// arrows.push(renderBetweenSteps(lastMarked, step, styles.stepStyles[stepStyle]))
// }
// lastMarked = step
// }
// }
if (stepStyle !== 'None') {
if (lastMarked) {
arrows.push(renderBetweenSteps(lastMarked, step, styles.stepStyles[stepStyle]))
}
lastMarked = step
}
}
}
return arrows
}
@@ -163,13 +174,15 @@ function MapNarratives ({ styles, onSelectNarrative, svg, narrative, narratives,
function renderNarrative (n) {
const narrativeId = `narrative-${n.id.replace(/ /g, '_')}`
const body = features.FILTERS_AS_NARRATIVES
? renderBetweenMarked(n)
: (features.NARRATIVE_STEP_STYLES
? renderBetweenMarked(n)
: renderFullNarrative(n))
return (
<g id={narrativeId} className='narrative'>
{renderBetweenMarked(n)}
{/* {(features.NARRATIVE_STEP_STYLES */}
{/* ? renderBetweenMarked(n) */}
{/* : renderFullNarrative(n) */}
{/* )} */}
{body}
</g>
)
}