From 3e20337b5eaebc3072170b1b5d82ad42c3ec3eaf Mon Sep 17 00:00:00 2001 From: Zac Ioannidis Date: Wed, 28 Oct 2020 16:09:29 +0000 Subject: [PATCH] Using new Card API --- src/components/CardStack.jsx | 84 ++++++++++++++++++++++++++---------- 1 file changed, 61 insertions(+), 23 deletions(-) diff --git a/src/components/CardStack.jsx b/src/components/CardStack.jsx index 701f0ec..18b501a 100644 --- a/src/components/CardStack.jsx +++ b/src/components/CardStack.jsx @@ -1,20 +1,24 @@ import React from 'react' import { connect } from 'react-redux' +import { timeFormat, timeParse } from 'd3' import * as selectors from '../selectors' // import Card from './Card.jsx' import { Card } from '@forensic-architecture/design-system/react' import copy from '../common/data/copy.json' +const formatTime = timeFormat("%d %B %Y"); +const parseTimeUS = timeParse("%-m/%-d/%Y"); + class CardStack extends React.Component { - constructor () { + constructor() { super() this.refs = {} this.refCardStack = React.createRef() this.refCardStackContent = React.createRef() } - componentDidUpdate () { + componentDidUpdate() { const isNarrative = !!this.props.narrative if (isNarrative) { @@ -22,7 +26,7 @@ class CardStack extends React.Component { } } - scrollToCard () { + scrollToCard() { const duration = 500 const element = this.refCardStack.current const cardScroll = this.refs[this.props.narrative.current].current.offsetTop @@ -52,7 +56,7 @@ class CardStack extends React.Component { animateScroll() } - renderCards (events, selections) { + renderCards(events, selections) { // if no selections provided, select all if (!selections) { selections = events.map(e => true) } this.refs = [] @@ -62,27 +66,61 @@ class CardStack extends React.Component { this.refs[idx] = thisRef return ( ({ + text: association, + color: null, + onClick: () => console.log('hello') + })), + }, + ], + [ + { + kind: "text", + title: "Summary", + value: event.description, + }, + ], + [ + { + kind: "list", + title: "Law Enforcement Agencies", + value: event.le_agencys, + }, + ], + [ + { kind: "text", title: "Name of reporter(s)", value: event.journalist_name }, + { kind: "text", title: "Network", value: event.news_organisation }, + ], + // [{ kind: "text", title: "Category", value: "Press attack" }], + ]} language={this.props.language} isLoading={this.props.isLoading} isSelected={selections[idx]} - getCategoryGroup={this.props.getCategoryGroup} - getCategoryColor={this.props.getCategoryColor} - getCategoryLabel={this.props.getCategoryLabel} - onViewSource={this.props.onViewSource} - onHighlight={this.props.onHighlight} - onSelect={this.props.onSelect} - idx={idx} - features={this.props.features} + // getNarrativeLinks={this.props.getNarrativeLinks} + // getCategoryGroup={this.props.getCategoryGroup} + // getCategoryColor={this.props.getCategoryColor} + // getCategoryLabel={this.props.getCategoryLabel} + // onViewSource={this.props.onViewSource} + // onHighlight={this.props.onHighlight} + // onSelect={this.props.onSelect} + // features={this.props.features} />) }) } - renderSelectedCards () { + renderSelectedCards() { const { selected } = this.props if (selected.length > 0) { @@ -91,7 +129,7 @@ class CardStack extends React.Component { return null } - renderNarrativeCards () { + renderNarrativeCards() { const { narrative } = this.props const showing = narrative.steps @@ -101,7 +139,7 @@ class CardStack extends React.Component { return this.renderCards(showing, selections) } - renderCardStackHeader () { + renderCardStackHeader() { const headerLang = copy[this.props.language].cardstack.header return ( @@ -118,7 +156,7 @@ class CardStack extends React.Component { ) } - renderCardStackContent () { + renderCardStackContent() { return (
    @@ -128,7 +166,7 @@ class CardStack extends React.Component { ) } - renderNarrativeContent () { + renderNarrativeContent() { return (