lint jsx files

This commit is contained in:
Lachlan Kermode
2019-01-23 11:35:34 +00:00
parent 939a4833b8
commit fb4d0c2d86
28 changed files with 572 additions and 627 deletions

View File

@@ -1,59 +1,40 @@
import copy from '../js/data/copy.json'
import {
isNotNullNorUndefined,
parseDate,
formatterWithYear
} from '../js/utilities'
import React from 'react'
import Spinner from './presentational/Spinner'
import CardTimestamp from './presentational/Card/Timestamp'
import CardLocation from './presentational/Card/Location'
import CardCaret from './presentational/Card/Caret'
import CardTags from './presentational/Card/Tags'
import CardSummary from './presentational/Card/Summary'
import CardSource from './presentational/Card/Source'
import CardCategory from './presentational/Card/Category'
import CardNarrative from './presentational/Card/Narrative'
class Card extends React.Component {
constructor(props) {
constructor (props) {
super(props)
this.state = {
isOpen: false
}
}
toggle() {
toggle () {
this.setState({
isOpen: !this.state.isOpen
})
}
makeTimelabel(timestamp) {
makeTimelabel (timestamp) {
if (timestamp === null) return null
const parsedTimestamp = parseDate(timestamp)
const timelabel = formatterWithYear(parsedTimestamp)
return timelabel
}
renderCategory() {
const categoryTitle = copy[this.props.language].cardstack.category
const categoryLabel = this.props.event.category
const color = this.props.getCategoryColor(this.props.event.category)
return null
// return (
// <CardCategory
// categoryTitle={categoryTitle}
// categoryLabel={categoryLabel}
// color={color}
// />
// )
}
renderSummary() {
renderSummary () {
return (
<CardSummary
language={this.props.language}
@@ -63,7 +44,7 @@ class Card extends React.Component {
)
}
renderTags() {
renderTags () {
if (!this.props.tags || (this.props.tags && this.props.tags.length === 0)) {
return null
}
@@ -75,7 +56,7 @@ class Card extends React.Component {
)
}
renderLocation() {
renderLocation () {
return (
<CardLocation
language={this.props.language}
@@ -84,15 +65,15 @@ class Card extends React.Component {
)
}
renderSources() {
renderSources () {
if (this.props.sourceError) {
return <div>ERROR: something went wrong loading sources, TODO:</div>
}
const source_lang = copy[this.props.language].cardstack.sources
const sourceLang = copy[this.props.language].cardstack.sources
return (
<div className='card-col'>
<h4>{source_lang}: </h4>
<h4>{sourceLang}: </h4>
{this.props.event.sources.map(source => (
<CardSource
isLoading={this.props.isLoading}
@@ -105,7 +86,7 @@ class Card extends React.Component {
}
// NB: should be internaionalized.
renderTimestamp() {
renderTimestamp () {
return (
<CardTimestamp
makeTimelabel={(timestamp) => this.makeTimelabel(timestamp)}
@@ -115,11 +96,10 @@ class Card extends React.Component {
)
}
renderNarrative() {
renderNarrative () {
const links = this.props.getNarrativeLinks(this.props.event)
if (links !== null) {
return (
<CardNarrative
select={(event) => this.props.onSelect([event])}
@@ -131,7 +111,7 @@ class Card extends React.Component {
}
}
renderMain() {
renderMain () {
return (
<div className='card-container'>
<div className='card-row details'>
@@ -144,7 +124,7 @@ class Card extends React.Component {
)
}
renderExtra() {
renderExtra () {
return (
<div className='card-bottomhalf'>
{this.renderTags()}
@@ -154,7 +134,7 @@ class Card extends React.Component {
)
}
renderCaret() {
renderCaret () {
return (
<CardCaret
toggle={() => this.toggle()}
@@ -163,10 +143,10 @@ class Card extends React.Component {
)
}
render() {
render () {
const { isSelected } = this.props
return (
<li className={`event-card ${isSelected ? 'selected' : ''}`}>
<li className={`event-card ${isSelected ? 'selected' : ''}`}>
{this.renderMain()}
{this.state.isOpen ? this.renderExtra() : null}
{isSelected ? this.renderCaret() : null}