security-checklist/components/ChecklistItem/App.js

53 lines
1.4 KiB
JavaScript
Raw Normal View History

2019-01-13 07:00:23 +00:00
// @flow
import React from 'react';
import type { App } from '../../types';
import {
AppMeta,
AppRowContainer,
AppIcon,
AppName,
AppSourcesList,
AppSourcesListItem,
AppSourcesLabel,
} from './style';
2019-01-14 18:12:41 +00:00
import Offer from './Offer';
2019-01-13 07:00:23 +00:00
import Icon from '../Icon';
type Props = {
app: App,
};
export const AppRow = ({ app }: Props) => {
2019-01-13 20:12:45 +00:00
const sourcesKeys = app.sources && Object.keys(app.sources);
2019-01-13 07:00:23 +00:00
const renderSourceIcon = (key: string) => {
const sourceUrl = app.sources[key];
2019-01-15 17:09:13 +00:00
const renderMatch = key.toLowerCase();
const hideOnMobile =
renderMatch === 'linux' ||
renderMatch === 'macos' ||
renderMatch === 'windows';
return (
<AppSourcesListItem hideOnMobile={hideOnMobile} key={key}>
<a href={sourceUrl} target="_blank" rel="noopener noreferrer">
<Icon size={32} glyph={renderMatch} />
<AppSourcesLabel>{renderMatch}</AppSourcesLabel>
</a>
</AppSourcesListItem>
);
2019-01-13 07:00:23 +00:00
};
return (
<AppRowContainer href={app.url} target="_blank" rel="noopener noreferrer">
<AppMeta>
2019-01-14 17:54:56 +00:00
{app.image && <AppIcon alt={app.name} src={app.image} />}
2019-01-13 07:00:23 +00:00
<AppName>{app.name}</AppName>
</AppMeta>
2019-01-13 20:12:45 +00:00
{sourcesKeys && (
<AppSourcesList>{sourcesKeys.map(renderSourceIcon)}</AppSourcesList>
)}
2019-01-14 18:12:41 +00:00
{app.offer && <Offer offer={app.offer} />}
2019-01-13 07:00:23 +00:00
</AppRowContainer>
);
};