Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tidy/Item component #573

Merged
merged 11 commits into from
Apr 21, 2019
110 changes: 110 additions & 0 deletions app/components/item/Description.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
import React from 'react';
import classNames from 'classnames';
import { Row, Col, UncontrolledTooltip } from 'reactstrap';

import Rating from '../card/Rating';

type Props = {
title: string,
runtime: Object,
genres: Array,
summary: string,
rating: number,
onTrailerClick: Function,
year: number,
torrentHealth: string,
certification: string,
nrSeeders: number,
trailer: string
};

export default function Description({
title,
runtime,
genres,
summary,
rating = 'n/a',
onTrailerClick,
year,
torrentHealth,
certification,
nrSeeders = 0,
trailer
}: Props) {
const torrentHealthClassName = classNames([
'torrent__health',
{ [`torrent__health--${torrentHealth}`]: torrentHealth }
]);

return (
<Col sm="6" className="Movie">
<h1 className="row-margin" id="title">
{title}
</h1>
<Row>
{(runtime.hours || runtime.minutes) && (
<span className="col-sm-3" id="runtime">
<h6>
{runtime.hours ? `${runtime.hours} hrs ` : ''}
{runtime.minutes ? `${runtime.minutes} min` : ''}
</h6>
</span>
)}
<span className="col-sm-9" id="genres">
{genres && <h6>{genres.join(', ')}</h6>}
</span>
</Row>
<h6 data-e2e="summary" className="row-margin item__summary">
{summary}
</h6>
<Row className="row-margin row-center Item--details">
{rating && typeof rating === 'number' && (
<Col sm="5">
<Rating
emptyStarColor="rgba(255, 255, 255, 0.2)"
starColor="white"
rating={rating}
/>
</Col>
)}
<Col sm="2">
<span data-e2e="item-year">{year}</span>
</Col>

{certification && certification !== 'n/a' && (
<Col sm="3">
<div className="certification">{certification}</div>
</Col>
)}

<Col sm="2" className="row-center">
<i className="ion-md-magnet" />
<div
id="magnetPopoverOpen"
data-e2e="item-magnet-torrent-health-popover"
className={torrentHealthClassName}
/>
<UncontrolledTooltip placement="top" target="magnetPopoverOpen">
{nrSeeders}
{' Seeders'}
</UncontrolledTooltip>
</Col>

{process.env.NODE_ENV === 'test' && trailer !== 'n/a' && (
<Col sm="3" className="row-center">
<i
id="trailerPopoverOpen"
data-e2e="item-trailer-button"
className="ion-md-videocam"
onClick={onTrailerClick}
role="presentation"
/>
<UncontrolledTooltip placement="top" target="trailerPopoverOpen">
Trailer
</UncontrolledTooltip>
</Col>
)}
</Row>
</Col>
);
}
Loading