diff --git a/src/actions/index.js b/src/actions/index.js index 1ddd64a..7c9dcd7 100644 --- a/src/actions/index.js +++ b/src/actions/index.js @@ -260,6 +260,14 @@ export function decrementNarrativeCurrent () { } } +export const SELECT_NARRATIVE_EVENT = 'SELECT_NARRATIVE_EVENT' +export function selectNarrativeEvent (idx) { + return { + type: SELECT_NARRATIVE_EVENT, + idx + } +} + export const UPDATE_SOURCE = 'UPDATE_SOURCE' export function updateSource (source) { return { diff --git a/src/components/Card.jsx b/src/components/Card.jsx index fe24c72..2edf026 100644 --- a/src/components/Card.jsx +++ b/src/components/Card.jsx @@ -163,8 +163,8 @@ class Card extends React.Component { /> ) : null } - - render () { + + render () { const { isSelected, idx } = this.props return ( @@ -172,6 +172,7 @@ class Card extends React.Component { className={`event-card ${isSelected ? 'selected' : ''}`} id={`event-card-${idx}`} ref={this.props.innerRef} + onClick={(e) => {this.props.onClick(idx);} } > {this.renderMain()} {this.state.isOpen ? this.renderExtra() : null} diff --git a/src/components/CardStack.jsx b/src/components/CardStack.jsx index f3bac98..6f7018d 100644 --- a/src/components/CardStack.jsx +++ b/src/components/CardStack.jsx @@ -1,6 +1,8 @@ import React from 'react' +import { bindActionCreators } from 'redux' import { connect } from 'react-redux' import * as selectors from '../selectors' +import * as actions from '../actions' import Card from './Card.jsx' import copy from '../common/data/copy.json' @@ -8,6 +10,7 @@ import copy from '../common/data/copy.json' class CardStack extends React.Component { constructor () { super() + this.onCardClick = this.onCardClick.bind(this) this.refs = {} this.refCardStack = React.createRef() this.refCardStackContent = React.createRef() @@ -61,6 +64,7 @@ class CardStack extends React.Component { this.refs[idx] = thisRef return () }) } + onCardClick (idx) { + this.props.actions.selectNarrativeEvent(idx) + } + renderSelectedCards () { const { selected } = this.props if (selected.length > 0) { @@ -126,7 +135,7 @@ class CardStack extends React.Component { renderNarrativeContent () { return (