mirror of
https://github.com/bellingcat/ukraine-timemap.git
synced 2026-06-12 21:38:35 +03:00
Using prettier for linting
This commit is contained in:
@@ -1,79 +1,79 @@
|
||||
import React from 'react'
|
||||
import Img from 'react-image'
|
||||
import Spinner from '../Spinner'
|
||||
import { typeForPath } from '../../../common/utilities'
|
||||
import React from "react";
|
||||
import Img from "react-image";
|
||||
import Spinner from "../Spinner";
|
||||
import { typeForPath } from "../../../common/utilities";
|
||||
|
||||
const CardSource = ({ source, isLoading, onClickHandler }) => {
|
||||
function renderIconText (type) {
|
||||
function renderIconText(type) {
|
||||
switch (type) {
|
||||
case 'Eyewitness Testimony':
|
||||
return 'visibility'
|
||||
case 'Government Data':
|
||||
return 'public'
|
||||
case 'Satellite Imagery':
|
||||
return 'satellite'
|
||||
case 'Second-Hand Testimony':
|
||||
return 'visibility_off'
|
||||
case 'Video':
|
||||
return 'videocam'
|
||||
case 'Photo':
|
||||
return 'photo'
|
||||
case 'Photobook':
|
||||
return 'photo_album'
|
||||
case 'Document':
|
||||
return 'picture_as_pdf'
|
||||
case "Eyewitness Testimony":
|
||||
return "visibility";
|
||||
case "Government Data":
|
||||
return "public";
|
||||
case "Satellite Imagery":
|
||||
return "satellite";
|
||||
case "Second-Hand Testimony":
|
||||
return "visibility_off";
|
||||
case "Video":
|
||||
return "videocam";
|
||||
case "Photo":
|
||||
return "photo";
|
||||
case "Photobook":
|
||||
return "photo_album";
|
||||
case "Document":
|
||||
return "picture_as_pdf";
|
||||
default:
|
||||
return 'help'
|
||||
return "help";
|
||||
}
|
||||
}
|
||||
|
||||
if (!source) {
|
||||
return (
|
||||
<div className='card-source'>
|
||||
<div className="card-source">
|
||||
<div>Error: this source was not found</div>
|
||||
</div>
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
const isImgUrl = /\.(jpg|png)$/
|
||||
let thumbnail = source.thumbnail
|
||||
const isImgUrl = /\.(jpg|png)$/;
|
||||
let thumbnail = source.thumbnail;
|
||||
|
||||
if (!thumbnail || thumbnail === '' || !thumbnail.match(isImgUrl)) {
|
||||
if (!thumbnail || thumbnail === "" || !thumbnail.match(isImgUrl)) {
|
||||
// default to first image in paths, null if no images
|
||||
const imgs = source.paths.filter(p => p.match(isImgUrl))
|
||||
thumbnail = imgs.length > 0 ? imgs[0] : null
|
||||
const imgs = source.paths.filter((p) => p.match(isImgUrl));
|
||||
thumbnail = imgs.length > 0 ? imgs[0] : null;
|
||||
}
|
||||
|
||||
if (source.type === '' && source.paths.length >= 1) {
|
||||
source.type = typeForPath(source.paths[0])
|
||||
if (source.type === "" && source.paths.length >= 1) {
|
||||
source.type = typeForPath(source.paths[0]);
|
||||
}
|
||||
const fallbackIcon = (
|
||||
<i className='material-icons source-icon'>
|
||||
{renderIconText(source.type)}
|
||||
</i>
|
||||
)
|
||||
<i className="material-icons source-icon">{renderIconText(source.type)}</i>
|
||||
);
|
||||
|
||||
return (
|
||||
<div className='card-source'>
|
||||
{isLoading
|
||||
? <Spinner />
|
||||
: (
|
||||
<div className='source-row' onClick={() => onClickHandler(source)}>
|
||||
{thumbnail ? (
|
||||
<Img
|
||||
className='source-icon'
|
||||
src={thumbnail}
|
||||
loader={<Spinner small />}
|
||||
unloader={fallbackIcon}
|
||||
width={30}
|
||||
height={30}
|
||||
/>
|
||||
) : fallbackIcon}
|
||||
<p>{source.title ? source.title : source.id}</p>
|
||||
</div>
|
||||
)}
|
||||
<div className="card-source">
|
||||
{isLoading ? (
|
||||
<Spinner />
|
||||
) : (
|
||||
<div className="source-row" onClick={() => onClickHandler(source)}>
|
||||
{thumbnail ? (
|
||||
<Img
|
||||
className="source-icon"
|
||||
src={thumbnail}
|
||||
loader={<Spinner small />}
|
||||
unloader={fallbackIcon}
|
||||
width={30}
|
||||
height={30}
|
||||
/>
|
||||
) : (
|
||||
fallbackIcon
|
||||
)}
|
||||
<p>{source.title ? source.title : source.id}</p>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
);
|
||||
};
|
||||
|
||||
export default CardSource
|
||||
export default CardSource;
|
||||
|
||||
Reference in New Issue
Block a user