Fix background highlight on sort in shipyard (#447)

* Fix background highlight on sort in shipyard

* removed docs line
This commit is contained in:
monopoint
2018-12-21 21:14:43 +01:00
committed by William
parent 600df162aa
commit 0cfb0b6878
2 changed files with 2 additions and 19 deletions

View File

@@ -169,10 +169,9 @@ export default class ShipyardPage extends Page {
* @param {Object} u Localized unit map * @param {Object} u Localized unit map
* @param {Function} fInt Localized integer formatter * @param {Function} fInt Localized integer formatter
* @param {Function} fRound Localized round formatter * @param {Function} fRound Localized round formatter
* @param {Boolean} highlight Should this row be highlighted
* @return {React.Component} Table Row * @return {React.Component} Table Row
*/ */
_shipRowElement(s, translate, u, fInt, fRound, highlight) { _shipRowElement(s, translate, u, fInt, fRound) {
let noTouch = this.context.noTouch; let noTouch = this.context.noTouch;
return ( return (
@@ -181,7 +180,6 @@ export default class ShipyardPage extends Page {
style={{ height: '1.5em' }} style={{ height: '1.5em' }}
className={cn({ className={cn({
highlighted: noTouch && this.state.shipId === s.id, highlighted: noTouch && this.state.shipId === s.id,
alt: highlight
})} })}
onMouseEnter={noTouch && this._highlightShip.bind(this, s.id)} onMouseEnter={noTouch && this._highlightShip.bind(this, s.id)}
> >
@@ -286,27 +284,13 @@ export default class ShipyardPage extends Page {
let shipRows = new Array(shipSummaries.length); let shipRows = new Array(shipSummaries.length);
let detailRows = new Array(shipSummaries.length); let detailRows = new Array(shipSummaries.length);
let lastShipSortValue = null;
let backgroundHighlight = false;
for (let s of shipSummaries) { for (let s of shipSummaries) {
let shipSortValue = s[shipPredicate];
if (shipPredicateIndex != undefined) {
shipSortValue = shipSortValue[shipPredicateIndex];
}
if (shipSortValue != lastShipSortValue) {
backgroundHighlight = !backgroundHighlight;
lastShipSortValue = shipSortValue;
}
detailRows[i] = this._shipRowElement( detailRows[i] = this._shipRowElement(
s, s,
translate, translate,
units, units,
fInt, fInt,
formats.f1, formats.f1,
backgroundHighlight
); );
shipRows[i] = ( shipRows[i] = (
<tr <tr
@@ -314,7 +298,6 @@ export default class ShipyardPage extends Page {
style={{ height: '1.5em' }} style={{ height: '1.5em' }}
className={cn({ className={cn({
highlighted: noTouch && this.state.shipId === s.id, highlighted: noTouch && this.state.shipId === s.id,
alt: backgroundHighlight
})} })}
onMouseEnter={noTouch && this._highlightShip.bind(this, s.id)} onMouseEnter={noTouch && this._highlightShip.bind(this, s.id)}
> >

View File

@@ -55,7 +55,7 @@ tbody tr {
background-color: @warning-bg; background-color: @warning-bg;
} }
&.alt { &:nth-child(odd){
background-color: @alt-primary-bg; background-color: @alt-primary-bg;
} }
} }