Crate torrentStatusClasses util

This commit is contained in:
John Furrow
2016-02-06 09:18:54 -08:00
parent 299eb28980
commit e30243f4d4
4 changed files with 41 additions and 31 deletions

View File

@@ -9,6 +9,7 @@ import File from '../icons/File';
import format from '../../util/formatData';
import ProgressBar from '../ui/ProgressBar';
import Ratio from '../../components/icons/Ratio';
import {torrentStatusClasses} from '../../util/torrentStatusClasses';
import Upload from '../icons/Upload';
export default class TorrentHeading extends React.Component {
@@ -22,22 +23,10 @@ export default class TorrentHeading extends React.Component {
let uploadRate = format.data(torrent.uploadRate, '/s');
let uploadTotal = format.data(torrent.uploadTotal);
let classes = classNames('torrent-details__heading', {
'has-error': torrent.status.indexOf('has-error') > -1,
'is-selected': this.props.selected,
'is-stopped': torrent.status.indexOf('is-stopped') > -1,
'is-paused': torrent.status.indexOf('is-paused') > -1,
'is-actively-downloading': downloadRate.value > 0,
'is-downloading': torrent.status.indexOf('is-downloading') > -1,
'is-seeding': torrent.status.indexOf('is-seeding') > -1,
'is-completed': torrent.status.indexOf('is-completed') > -1,
'is-checking': torrent.status.indexOf('is-checking') > -1,
'is-active': torrent.status.indexOf('is-active') > -1,
'is-inactive': torrent.status.indexOf('is-inactive') > -1
});
let torrentClasses = torrentStatusClasses(torrent, 'torrent-details__heading');
return (
<div className={classes}>
<div className={torrentClasses}>
<h1 className="torrent__details--name">{torrent.name}</h1>
<ul className="torrent__details torrent__details--tertiary">
<li className="torrent__details--download transfer-data--download">

View File

@@ -4,6 +4,7 @@ import React from 'react';
import DotsMini from '../icons/DotsMini';
import format from '../../util/formatData';
import ProgressBar from '../ui/ProgressBar';
import {torrentStatusClasses} from '../../util/torrentStatusClasses';
const METHODS_TO_BIND = [
'handleClick',
@@ -43,23 +44,10 @@ export default class Torrent extends React.Component {
let uploadRate = format.data(torrent.uploadRate, '/s');
let uploadTotal = format.data(torrent.uploadTotal);
let classes = classNames({
'torrent': true,
'has-error': torrent.status.indexOf('e') > -1,
'is-selected': this.props.selected,
'is-stopped': torrent.status.indexOf('s') > -1,
'is-paused': torrent.status.indexOf('p') > -1,
'is-actively-downloading': downloadRate.value > 0,
'is-downloading': torrent.status.indexOf('d') > -1,
'is-seeding': torrent.status.indexOf('sd') > -1,
'is-completed': torrent.status.indexOf('c') > -1,
'is-checking': torrent.status.indexOf('ch') > -1,
'is-active': torrent.status.indexOf('a') > -1,
'is-inactive': torrent.status.indexOf('i') > -1
});
let torrentClasses = torrentStatusClasses(torrent, this.props.selected ? 'is-selected' : null, 'torrent');
return (
<li className={classes} onClick={this.handleClick}
<li className={torrentClasses} onClick={this.handleClick}
onContextMenu={this.handleRightClick}>
<ul className="torrent__details">
<li className="torrent__details--primary text-overflow">