preview combo when you've selected 3 items

This commit is contained in:
Mashy 2019-11-12 13:58:48 +10:00
parent 4e627fa34b
commit 6c0457f8fd
2 changed files with 5 additions and 3 deletions

View File

@ -22,7 +22,7 @@ class InfoComponent extends preact.Component {
componentDidUpdate(prevProps) { componentDidUpdate(prevProps) {
// Catch case where mouse events don't properly clear state and info changed // Catch case where mouse events don't properly clear state and info changed
if (prevProps.info !== this.props.info) this.setState({ comboItem: null }); if (prevProps.info !== this.props.info && this.state.comboItem) this.setState({ comboItem: null });
} }
render(args) { render(args) {

View File

@ -287,7 +287,7 @@ class Vbox extends preact.Component {
const combinerItems = combiner.map(j => vbox.bound[j]); const combinerItems = combiner.map(j => vbox.bound[j]);
const combinerCount = countBy(combinerItems, co => co); const combinerCount = countBy(combinerItems, co => co);
const comboHighlight = combinerItems.length > 0 && itemInfo.combos.some(combo => { const comboItem = itemInfo.combos.find(combo => {
if (combo.components.includes(v)) { if (combo.components.includes(v)) {
return combinerItems.every(c => { return combinerItems.every(c => {
if (!combo.components.includes(c)) return false; if (!combo.components.includes(c)) return false;
@ -297,7 +297,8 @@ class Vbox extends preact.Component {
return true; return true;
}); });
} return false; } return false;
}) ? 'combo-border' : ''; });
const comboHighlight = combinerItems.length > 0 && comboItem ? 'combo-border' : '';
function onClick(type) { function onClick(type) {
if (vboxSelecting) clearVboxSelected(); if (vboxSelecting) clearVboxSelected();
@ -323,6 +324,7 @@ class Vbox extends preact.Component {
} }
combiner.push(i); combiner.push(i);
if (combiner.length === 3) setInfo(comboItem.item);
return combinerChange(combiner); return combinerChange(combiner);
} }