Merge pull request #536 from monopoint/develop

448: compare highlights in shipyard
This commit is contained in:
Felix Linker
2019-08-25 13:32:08 +02:00
committed by GitHub
4 changed files with 34 additions and 19 deletions

View File

@@ -50,19 +50,6 @@ export default class Page extends React.Component {
} }
} }
/**
* Pages are 'pure' components that only render when props, state, or context changes.
* This method performs a shallow comparison to determine change.
*
* @param {Object} np Next/Incoming properties
* @param {Object} ns Next/Incoming state
* @param {Object} nc Next/Incoming context
* @return {Boolean} True if props, state, or context has changed
*/
shouldComponentUpdate(np, ns, nc) {
return !shallowEqual(this.props, np) || !shallowEqual(this.state, ns) || !shallowEqual(this.context, nc);
}
/** /**
* Update the window title upon mount * Update the window title upon mount
*/ */

View File

@@ -126,12 +126,13 @@ export default class ShipyardPage extends Page {
title: 'Coriolis EDCD Edition - Shipyard', title: 'Coriolis EDCD Edition - Shipyard',
shipPredicate: 'name', shipPredicate: 'name',
shipDesc: true, shipDesc: true,
shipSummaries: ShipyardPage.cachedShipSummaries shipSummaries: ShipyardPage.cachedShipSummaries,
compare: {},
}; };
} }
/** /**
* Higlight the current ship in the table * Higlight the current ship in the table on mouse over
* @param {String} shipId Ship Id * @param {String} shipId Ship Id
* @param {SyntheticEvent} event Event * @param {SyntheticEvent} event Event
*/ */
@@ -140,6 +141,16 @@ export default class ShipyardPage extends Page {
this.setState({ shipId }); this.setState({ shipId });
} }
/**
* Toggle compare highlighting for ships in the table
* @param {String} shipId Ship Id
*/
_toggleCompare(shipId) {
let compare = this.state.compare;
compare[shipId] = !compare[shipId];
this.setState({ compare });
}
/** /**
* Update state with the specified sort predicates * Update state with the specified sort predicates
* @param {String} shipPredicate Sort predicate - property name * @param {String} shipPredicate Sort predicate - property name
@@ -180,8 +191,10 @@ 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,
comparehighlight: this.state.compare[s.id],
})} })}
onMouseEnter={noTouch && this._highlightShip.bind(this, s.id)} onMouseEnter={noTouch && this._highlightShip.bind(this, s.id)}
onClick={() => this._toggleCompare(s.id)}
> >
<td className="ri">{s.manufacturer}</td> <td className="ri">{s.manufacturer}</td>
<td className="ri">{fInt(s.retailCost)}</td> <td className="ri">{fInt(s.retailCost)}</td>
@@ -298,8 +311,10 @@ 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,
comparehighlight: this.state.compare[s.id],
})} })}
onMouseEnter={noTouch && this._highlightShip.bind(this, s.id)} onMouseEnter={noTouch && this._highlightShip.bind(this, s.id)}
onClick={() => this._toggleCompare(s.id)}
> >
<td className="le"> <td className="le">
<Link href={'/outfit/' + s.id}>{s.name} {s.beta === true ? '(Beta)' : null}</Link> <Link href={'/outfit/' + s.id}>{s.name} {s.beta === true ? '(Beta)' : null}</Link>
@@ -321,7 +336,7 @@ export default class ShipyardPage extends Page {
maxWidth: '100%' maxWidth: '100%'
}} }}
> >
<table style={{ width: '12em', position: 'absolute', zIndex: 1 }}> <table style={{ width: '12em', position: 'absolute', zIndex: 1 }} className="shipyard-table">
<thead> <thead>
<tr> <tr>
<th className="le rgt">&nbsp;</th> <th className="le rgt">&nbsp;</th>
@@ -340,7 +355,7 @@ export default class ShipyardPage extends Page {
</tbody> </tbody>
</table> </table>
<div style={{ overflowX: 'scroll', maxWidth: '100%' }}> <div style={{ overflowX: 'scroll', maxWidth: '100%' }}>
<table style={{ marginLeft: 'calc(12em - 1px)', zIndex: 0 }}> <table style={{ marginLeft: 'calc(12em - 1px)', zIndex: 0 }} className="shipyard-table">
<thead> <thead>
<tr className="main"> <tr className="main">
<th <th

View File

@@ -2,6 +2,8 @@
@bgDarken: 40%; @bgDarken: 40%;
@disabledDarken: 15%; @disabledDarken: 15%;
@bgTransparency: 10%; @bgTransparency: 10%;
@bgHighlight: 5%;
@fgHighlight: 10%;
// Foreground colors // Foreground colors
@fg: #CCC; @fg: #CCC;
@@ -21,9 +23,13 @@
@bgBlack: #000; @bgBlack: #000;
@primary-bg: fadeout(darken(@primary, 47%), 15%); @primary-bg: fadeout(darken(@primary, 47%), 15%);
@alt-primary-bg: fadeout(darken(@primary, 42%), 15%); // Lighter brown background @alt-primary-bg: fadeout(darken(@primary, 42%), 15%); // Lighter brown background
@secondary-bg: fadeout(darken(@secondary, @bgDarken), @bgTransparency); // Brown background @secondary-bg: fadeout(darken(@secondary, @bgDarken), @bgTransparency); // Blue background
@warning-bg: fadeout(darken(@warning, @bgDarken), @bgTransparency); // Dark Red @warning-bg: fadeout(darken(@warning, @bgDarken), @bgTransparency); // Dark Red
@alt-primary-bg-highlighted: lighten(@alt-primary-bg, @bgHighlight);
@fg-highlighted: lighten(@fg, @fgHighlight);
.fg { .fg {
color: @fg; color: @fg;

View File

@@ -52,7 +52,7 @@ tbody tr {
} }
.no-touch &.highlight:hover, .no-touch &.highlighted { .no-touch &.highlight:hover, .no-touch &.highlighted {
background-color: @warning-bg; background-color: @alt-primary-bg-highlighted; //@warning-bg;
} }
&:nth-child(odd){ &:nth-child(odd){
@@ -84,3 +84,10 @@ td {
text-align: center; text-align: center;
} }
} }
table.shipyard-table{
tbody tr.comparehighlight{
background-color: @secondary-bg;
color: @fg-highlighted;
}
}