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
28 changes: 7 additions & 21 deletions app/components/item/Item.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,6 @@ export default class Item extends Component<Props, State> {

checkCastingDevicesInterval: number;

SUMMARY_CHAR_LIMIT = 300;

defaultTorrent: torrentSelectionType = {
default: {
quality: undefined,
Expand Down Expand Up @@ -494,7 +492,7 @@ export default class Item extends Component<Props, State> {
return [];
}

stopPlayback() {
stopPlayback = () => {
const { torrentInProgress, playbackInProgress, currentPlayer } = this.state;
if (!torrentInProgress && !playbackInProgress) {
return;
Expand All @@ -511,7 +509,7 @@ export default class Item extends Component<Props, State> {
this.player.destroy();
this.torrent.destroy();
this.setState({ torrentInProgress: false });
}
};

selectShow = (
type: string,
Expand Down Expand Up @@ -623,7 +621,7 @@ export default class Item extends Component<Props, State> {
return captions;
}

closeVideo() {
closeVideo = () => {
const { playbackInProgress } = this.state;
if (!playbackInProgress) {
return;
Expand All @@ -633,7 +631,7 @@ export default class Item extends Component<Props, State> {
this.setState({
currentPlayer: 'default'
});
}
};

toggleActive() {
this.setState(prevState => ({
Expand Down Expand Up @@ -809,19 +807,14 @@ export default class Item extends Component<Props, State> {
role="presentation"
className="pct-btn pct-btn-tran pct-btn-outline pct-btn-round"
data-e2e="item-button-back"
onClick={() => this.stopPlayback()}
onClick={this.stopPlayback}
>
<i className="ion-md-arrow-back" /> Back
</span>
</Link>
<Row>
<Plyr
captions={captions}
// captions={[{
// kind: "captions",
// label: "English captions",
// src: 'http://localhost:4000/Deadpool.2.Super.Duper.Cut.2018.HDRip.XviD.AC3-EVO.vtt'
// }]}
type="video"
url={playbackInProgress ? servingUrl || item.trailer : undefined}
poster={(item && item.images && item.images.fanart.full) || ''}
Expand All @@ -843,7 +836,7 @@ export default class Item extends Component<Props, State> {
data-e2e="close-player"
role="presentation"
id="close-button"
onClick={() => this.closeVideo()}
onClick={this.closeVideo}
>
<i className="ion-md-close" />
</span>
Expand Down Expand Up @@ -919,14 +912,7 @@ export default class Item extends Component<Props, State> {
{item.genres && <h6>{item.genres.join(', ')}</h6>}
</span>
</Row>
{/* HACK: Prefer a CSS solution to this, using text-overflow: ellipse */}
<h6 className="row-margin" id="summary">
amilajack marked this conversation as resolved.
Show resolved Hide resolved
{item.summary
? item.summary.length > this.SUMMARY_CHAR_LIMIT
? `${item.summary.slice(0, this.SUMMARY_CHAR_LIMIT)}...`
: item.summary
: ''}
</h6>
<h6 className="row-margin item__summary">{item.summary}</h6>
<Row className="row-margin row-center Item--details">
{item.rating && typeof item.rating === 'number' && (
<Col sm="5">
Expand Down
12 changes: 12 additions & 0 deletions app/styles/components/Item.scss
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,18 @@
}
}

//cf. https://codepen.io/martinwolf/pen/qlFdp
.item__summary {
display: block; /* Fallback for non-webkit */
display: -webkit-box;
margin: 0 auto;
line-height: 2rem;
-webkit-line-clamp: 3;
-webkit-box-orient: vertical;
overflow: hidden;
text-overflow: ellipsis;
}

> .row > .plyr {
position: absolute;
left: 0;
Expand Down
4 changes: 0 additions & 4 deletions app/styles/variables.scss
Original file line number Diff line number Diff line change
Expand Up @@ -83,10 +83,6 @@ $headings-font-weight: 400;
margin: 20px 0;
}

#summary {
line-height: 2rem;
}

::selection {
background: black;
color: white;
Expand Down