4
4
5
5
import * as React from 'react'
6
6
import * as prettierBytes from 'prettier-bytes'
7
- import { Column , Grid } from 'brave-ui/components'
8
- import { Heading } from 'brave-ui/old'
7
+ import { Column , Grid , Heading } from 'brave-ui/components'
9
8
10
9
// Constants
11
10
import { TorrentObj } from '../constants/webtorrentState'
@@ -20,9 +19,7 @@ export default class TorrentStatus extends React.PureComponent<Props, {}> {
20
19
const { torrent, errorMsg } = this . props
21
20
22
21
if ( errorMsg ) {
23
- return (
24
- < div > { errorMsg } </ div >
25
- )
22
+ return < div > { errorMsg } </ div >
26
23
}
27
24
28
25
if ( ! torrent ) {
@@ -31,41 +28,57 @@ export default class TorrentStatus extends React.PureComponent<Props, {}> {
31
28
32
29
const renderStatus = ( ) => {
33
30
const status = torrent . progress < 1 ? 'Downloading' : 'Seeding'
34
- return ( < Column size = { 2 } > { status } </ Column > )
31
+ return < Column size = { 2 } > { status } </ Column >
35
32
}
36
33
37
34
const renderPercentage = ( ) => {
38
- const percentage = ( torrent . progress < 1 ) ?
39
- ( torrent . progress * 100 ) . toFixed ( 1 ) : '100'
40
- return ( < Column size = { 2 } > { percentage } </ Column > )
35
+ const percentage =
36
+ torrent . progress < 1 ? ( torrent . progress * 100 ) . toFixed ( 1 ) : '100'
37
+ return < Column size = { 2 } > { percentage } </ Column >
41
38
}
42
39
43
40
const renderSpeeds = ( ) => {
44
41
let str = ''
45
- if ( torrent . downloadSpeed > 0 ) str += ' ↓ ' + prettierBytes ( torrent . downloadSpeed ) + '/s'
46
- if ( torrent . uploadSpeed > 0 ) str += ' ↑ ' + prettierBytes ( torrent . uploadSpeed ) + '/s'
42
+ if ( torrent . downloadSpeed > 0 ) {
43
+ str += ' ↓ ' + prettierBytes ( torrent . downloadSpeed ) + '/s'
44
+ }
45
+ if ( torrent . uploadSpeed > 0 ) {
46
+ str += ' ↑ ' + prettierBytes ( torrent . uploadSpeed ) + '/s'
47
+ }
47
48
if ( str === '' ) return
48
- return ( < Column size = { 2 } > { str } </ Column > )
49
+ return < Column size = { 2 } > { str } </ Column >
49
50
}
50
51
51
52
const renderTotalProgress = ( ) => {
52
53
const downloaded = prettierBytes ( torrent . downloaded )
53
54
const total = prettierBytes ( torrent . length || 0 )
54
55
if ( downloaded === total ) {
55
- return ( < Column size = { 2 } > { downloaded } </ Column > )
56
+ return < Column size = { 2 } > { downloaded } </ Column >
56
57
} else {
57
- return ( < Column size = { 2 } > { downloaded } / { total } </ Column > )
58
+ return (
59
+ < Column size = { 2 } >
60
+ { ' ' }
61
+ { downloaded } / { total } { ' ' }
62
+ </ Column >
63
+ )
58
64
}
59
65
}
60
66
61
67
const renderPeers = ( ) => {
62
68
if ( torrent . numPeers === 0 ) return
63
69
const count = torrent . numPeers === 1 ? 'peer' : 'peers'
64
- return ( < Column size = { 2 } > { torrent . numPeers } { count } </ Column > )
70
+ return (
71
+ < Column size = { 2 } >
72
+ { ' ' }
73
+ { torrent . numPeers } { count } { ' ' }
74
+ </ Column >
75
+ )
65
76
}
66
77
67
78
const renderEta = ( ) => {
68
- if ( torrent . timeRemaining === 0 || torrent . timeRemaining === Infinity ) return // Zero download speed
79
+ if ( torrent . timeRemaining === 0 || torrent . timeRemaining === Infinity ) {
80
+ return
81
+ } // Zero download speed
69
82
if ( torrent . downloaded === torrent . length ) return // Already done
70
83
71
84
const rawEta = torrent . timeRemaining / 1000
@@ -76,19 +89,20 @@ export default class TorrentStatus extends React.PureComponent<Props, {}> {
76
89
// Only display hours and minutes if they are greater than 0 but always
77
90
// display minutes if hours is being displayed
78
91
const hoursStr = hours ? hours + 'h' : ''
79
- const minutesStr = ( hours || minutes ) ? minutes + 'm' : ''
92
+ const minutesStr = hours || minutes ? minutes + 'm' : ''
80
93
const secondsStr = seconds + 's'
81
94
82
- return ( < Column size = { 2 } > { hoursStr } { minutesStr } { secondsStr } remaining </ Column > )
95
+ return (
96
+ < div className = '__column' >
97
+ { hoursStr } { minutesStr } { secondsStr } remaining
98
+ </ div >
99
+ )
83
100
}
84
101
85
102
return (
86
- < div >
87
- < Heading
88
- text = 'Torrent Status'
89
- level = { 3 }
90
- />
91
- < Grid >
103
+ < div className = 'torrentSubhead' >
104
+ < Heading children = 'Torrent Status' level = { 3 } />
105
+ < Grid className = 'gridFix' >
92
106
{ renderStatus ( ) }
93
107
{ renderPercentage ( ) }
94
108
{ renderSpeeds ( ) }
0 commit comments