infra for multiple sources in Card

This commit is contained in:
Lachlan Kermode
2018-12-13 17:47:35 +00:00
parent c85b0c9001
commit cccbcb9e54
2 changed files with 13 additions and 7 deletions

View File

@@ -91,10 +91,12 @@ class Card extends React.Component {
<CardSource
isLoading={this.props.isLoading}
language={this.props.language}
source={{
...this.props.source,
error: this.props.sourceError
}}
sources={[
...this.props.event.sources.map(s => ({
...s,
error: this.props.sourceError
})),
]}
/>
)
}

View File

@@ -3,10 +3,10 @@ import Spinner from './Spinner'
import copy from '../../js/data/copy.json'
const CardSource = ({ source, language, isLoading, error }) => {
const CardSource = ({ sources, language, isLoading, error }) => {
const source_lang = copy[language].cardstack.source
function renderSource() {
function renderSource(source) {
return source.error ? (
<div><small>{source.error}</small></div>
) : (
@@ -15,7 +15,11 @@ const CardSource = ({ source, language, isLoading, error }) => {
}
function renderContent() {
return isLoading ? <Spinner/> : renderSource()
return isLoading
? <Spinner/>
: sources.map(
source => renderSource(source)
)
}
return (