should comp update for info / combos

This commit is contained in:
Mashy 2019-11-26 10:42:06 +10:00
parent 86a84cbcea
commit c10b68949c
5 changed files with 111 additions and 92 deletions

View File

@ -259,15 +259,15 @@
padding: 0.25em; padding: 0.25em;
} }
.info {
display: none;
}
.combos { .combos {
display: none; display: none;
} }
.info-combiner { .info-combiner {
.info {
display: none;
}
.combiner { .combiner {
margin: 0; margin: 0;
width: 100%; width: 100%;

View File

@ -71,7 +71,7 @@
button { button {
line-height: 1.6; line-height: 1.6;
letter-spacing: 0.15em; letter-spacing: 0.15em;
border-width: 1px; border-width: 0.1em;
} }
} }
@ -108,7 +108,7 @@
&[disabled] { &[disabled] {
background: black; background: black;
border-width: 1px; border-width: 0.1em;
}; };
} }
@ -145,8 +145,6 @@
&.highlight { &.highlight {
color: black; color: black;
background: @silver; background: @silver;
// border: 1px solid @white; (this bangs around the vbox)
// overwrite the classes on white svg elements // overwrite the classes on white svg elements
svg { svg {
stroke-width: 0.75em; stroke-width: 0.75em;

View File

@ -6,7 +6,16 @@ const { convertItem } = require('../utils');
const addState = connect(({ info, itemInfo, instance, tutorial, vboxInfo }) => const addState = connect(({ info, itemInfo, instance, tutorial, vboxInfo }) =>
({ info, itemInfo, instance, tutorial, vboxInfo })); ({ info, itemInfo, instance, tutorial, vboxInfo }));
function Combos(args) {
class Combos extends preact.Component {
shouldComponentUpdate(newProps) {
if (newProps.info !== this.props.info) return true;
if (newProps.tutorial !== this.props.tutorial) return true;
if (newProps.vboxInfo !== this.props.vboxInfo) return true;
return false;
}
render(props) {
const { const {
// Variables that will change // Variables that will change
info, info,
@ -15,7 +24,7 @@ function Combos(args) {
// Static // Static
itemInfo, itemInfo,
instance, // Only used for tutorial check instance, // Only used for tutorial check
} = args; } = props;
if (tutorial && instance.time_control === 'Practice' && instance.rounds.length === 1) return false; if (tutorial && instance.time_control === 'Practice' && instance.rounds.length === 1) return false;
@ -51,6 +60,7 @@ function Combos(args) {
</div> </div>
</div> </div>
); );
}
} }
module.exports = addState(Combos); module.exports = addState(Combos);

View File

@ -6,7 +6,17 @@ const { genItemInfo } = require('./vbox.utils');
const addState = connect(({ info, player, tutorial, vboxInfo, ws, itemInfo, instance }) => const addState = connect(({ info, player, tutorial, vboxInfo, ws, itemInfo, instance }) =>
({ info, player, tutorial, vboxInfo, ws, itemInfo, instance })); ({ info, player, tutorial, vboxInfo, ws, itemInfo, instance }));
function Info(args) { class Info extends preact.Component {
shouldComponentUpdate(newProps) {
// Single variable props
if (newProps.info !== this.props.info) return true;
if (newProps.player !== this.props.player) return true;
if (newProps.tutorial !== this.props.tutorial) return true;
if (newProps.vboxInfo !== this.props.vboxInfo) return true;
return false;
}
render(props) {
const { const {
// Variables that will change // Variables that will change
info, info,
@ -17,7 +27,7 @@ function Info(args) {
ws, ws,
itemInfo, itemInfo,
instance, instance,
} = args; } = props;
if (tutorial) { if (tutorial) {
const tutorialStageInfo = tutorialStage(tutorial, ws, instance); const tutorialStageInfo = tutorialStage(tutorial, ws, instance);
@ -54,6 +64,7 @@ function Info(args) {
} }
return genItemInfo(info, itemInfo, player, info); return genItemInfo(info, itemInfo, player, info);
}
} }
module.exports = addState(Info); module.exports = addState(Info);

View File

@ -66,7 +66,7 @@ function setVboxState(dispatch, vboxSelected, state) {
dispatch(actions.setVboxInfo(vboxInfo())); dispatch(actions.setVboxInfo(vboxInfo()));
dispatch(actions.setVboxCombiner(vboxCombiner)); dispatch(actions.setVboxCombiner(vboxCombiner));
return dispatch(actions.setVboxHighlight(vboxHighlight)); dispatch(actions.setVboxHighlight(vboxHighlight));
} }
function genItemInfo(item, itemInfo, player, info) { function genItemInfo(item, itemInfo, player, info) {