From 795a445b52e83e4f9941b300f83966066aadc1f1 Mon Sep 17 00:00:00 2001 From: Qstick Date: Wed, 27 Feb 2019 22:15:24 -0500 Subject: [PATCH] Fixed: Rendering Tweaks to UI --- .../src/Artist/Index/ArtistIndexFooter.js | 271 +++++++++--------- frontend/src/Components/Icon.js | 78 ++--- frontend/src/Components/Page/PageJumpBar.js | 7 + 3 files changed, 188 insertions(+), 168 deletions(-) diff --git a/frontend/src/Artist/Index/ArtistIndexFooter.js b/frontend/src/Artist/Index/ArtistIndexFooter.js index f16e36661..245312ae6 100644 --- a/frontend/src/Artist/Index/ArtistIndexFooter.js +++ b/frontend/src/Artist/Index/ArtistIndexFooter.js @@ -1,5 +1,5 @@ import PropTypes from 'prop-types'; -import React from 'react'; +import React, { PureComponent } from 'react'; import classNames from 'classnames'; import formatBytes from 'Utilities/Number/formatBytes'; import { ColorImpairedConsumer } from 'App/ColorImpairedContext'; @@ -7,141 +7,148 @@ import DescriptionList from 'Components/DescriptionList/DescriptionList'; import DescriptionListItem from 'Components/DescriptionList/DescriptionListItem'; import styles from './ArtistIndexFooter.css'; -function ArtistIndexFooter({ artist }) { - const count = artist.length; - let tracks = 0; - let trackFiles = 0; - let ended = 0; - let continuing = 0; - let monitored = 0; - let totalFileSize = 0; - - artist.forEach((s) => { - const { statistics = {} } = s; - - const { - trackCount = 0, - trackFileCount = 0, - sizeOnDisk = 0 - } = statistics; - - tracks += trackCount; - trackFiles += trackFileCount; - - if (s.status === 'ended') { - ended++; - } else { - continuing++; - } - - if (s.monitored) { - monitored++; - } - - totalFileSize += sizeOnDisk; - }); - - return ( - - {(enableColorImpairedMode) => { - return ( -
-
-
-
-
Continuing (All tracks downloaded)
+class ArtistIndexFooter extends PureComponent { + + // + // Render + + render() { + const { artist } = this.props; + const count = artist.length; + let tracks = 0; + let trackFiles = 0; + let ended = 0; + let continuing = 0; + let monitored = 0; + let totalFileSize = 0; + + artist.forEach((s) => { + const { statistics = {} } = s; + + const { + trackCount = 0, + trackFileCount = 0, + sizeOnDisk = 0 + } = statistics; + + tracks += trackCount; + trackFiles += trackFileCount; + + if (s.status === 'ended') { + ended++; + } else { + continuing++; + } + + if (s.monitored) { + monitored++; + } + + totalFileSize += sizeOnDisk; + }); + + return ( + + {(enableColorImpairedMode) => { + return ( +
+
+
+
+
Continuing (All tracks downloaded)
+
+ +
+
+
Ended (All tracks downloaded)
+
+ +
+
+
Missing Tracks (Artist monitored)
+
+ +
+
+
Missing Tracks (Artist not monitored)
+
-
-
-
Ended (All tracks downloaded)
+
+ + + + + + + + + + + + + + + + + + + + + + +
- -
-
-
Missing Tracks (Artist monitored)
-
- -
-
-
Missing Tracks (Artist not monitored)
-
-
- -
- - - - - - - - - - - - - - - - - - - - - - -
-
- ); - }} - - ); + ); + }} + + ); + } } ArtistIndexFooter.propTypes = { diff --git a/frontend/src/Components/Icon.js b/frontend/src/Components/Icon.js index ae3f01c10..d7748d2e7 100644 --- a/frontend/src/Components/Icon.js +++ b/frontend/src/Components/Icon.js @@ -1,49 +1,55 @@ import PropTypes from 'prop-types'; -import React from 'react'; +import React, { PureComponent } from 'react'; import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'; import { kinds } from 'Helpers/Props'; import classNames from 'classnames'; import styles from './Icon.css'; -function Icon(props) { - const { - containerClassName, - className, - name, - kind, - size, - title, - isSpinning, - ...otherProps - } = props; +class Icon extends PureComponent { - const icon = ( - - ); + // + // Render - if (title) { - return ( - - {icon} - + render() { + const { + containerClassName, + className, + name, + kind, + size, + title, + isSpinning, + ...otherProps + } = this.props; + + const icon = ( + ); - } - return icon; + if (title) { + return ( + + {icon} + + ); + } + + return icon; + } } Icon.propTypes = { diff --git a/frontend/src/Components/Page/PageJumpBar.js b/frontend/src/Components/Page/PageJumpBar.js index f7d44ae9a..f555d5426 100644 --- a/frontend/src/Components/Page/PageJumpBar.js +++ b/frontend/src/Components/Page/PageJumpBar.js @@ -26,6 +26,13 @@ class PageJumpBar extends Component { this.computeVisibleItems(); } + shouldComponentUpdate(nextProps, nextState) { + return ( + nextProps.items !== this.props.items || + nextState.height !== this.state.height + ); + } + componentDidUpdate(prevProps, prevState) { if ( prevProps.items !== this.props.items ||