render sources collectively in card

This commit is contained in:
Lachlan Kermode
2018-12-14 12:01:09 +00:00
parent e350a0c60f
commit f53c8e0225
3 changed files with 34 additions and 27 deletions

View File

@@ -3,28 +3,28 @@ import Spinner from './Spinner'
import copy from '../../js/data/copy.json'
function renderSource(source) {
return source.error ? (
<div><small>{source.error}</small></div>
) : (
<div>
<p>{source.id}</p>
</div>
)
}
const CardSource = ({ source, language, isLoading, error }) => {
const source_lang = copy[language].cardstack.source
function renderContent() {
return isLoading
? <Spinner/>
: renderSource(source)
if (isLoading) {
return <Spinner/>
} else if (source.error) {
return (
<div><small>{source.error}</small></div>
)
} else {
/* source with no errors */
return (
<div>
<p>{source.id}</p>
<i className="material-icons md-36">photo</i>
</div>
)
}
}
return (
<div className="card-row card-cell source">
<h4>{source_lang}: </h4>
{renderContent()}
</div>
)