info fixes

This commit is contained in:
ntr 2019-04-08 14:04:06 +10:00
parent 2f8ff69aee
commit 5632713144
3 changed files with 39 additions and 15 deletions

View File

@ -10,6 +10,7 @@ function Info(args) {
info,
sendUnequip,
instance,
setInfo,
} = args;
function infoVar([type, value]) {
@ -87,10 +88,17 @@ function Info(args) {
function infoCrypElement(cryp) {
// onClick={() => setInfo('skill', { skill: s, cryp })}
const skills = range(0, 4).map(i => {
const skill = cryp.skills[i];
function skillClick() {
if (!skill) return false;
return setInfo('skill', { skill: skill.skill, cryp });
}
const s = cryp.skills[i]
? cryp.skills[i].skill
: (<span>&nbsp;</span>);
return <button key={i} className="cryp-skill-btn right" >{s}</button>;
return <button key={i} className="cryp-skill-btn" onClick={skillClick} >{s}</button>;
});
const stats = Object.values(STATS).map((s, j) => (
@ -100,12 +108,18 @@ function Info(args) {
</figure>
));
const specs = cryp.specs.map((s, i) => (
<figure key={i}>
const specs = cryp.specs.map((s, i) => {
function specClick() {
setInfo('spec', { spec: s, cryp });
}
return (
<figure key={i} onClick={specClick} >
{SPECS[s].svg(`stat-icon ${SPECS[s].colour}`)}
<figcaption>{SPECS[s].caption}</figcaption>
</figure>
));
);
});
return (

View File

@ -1,7 +1,6 @@
const { connect } = require('preact-redux');
// const actions = require('../actions');
const actions = require('../actions');
const Info = require('./info.component');
const addState = connect(
@ -23,13 +22,24 @@ const addState = connect(
sendUnequip,
instance,
};
}
/*
function receiveDispatch(dispatch) {
},
return { };
function receiveDispatch(dispatch) {
function setInfo(item, value) {
dispatch(actions.setInfo([item, value]));
}
*/
function setActiveVar(value) {
dispatch(actions.setActiveVar(value));
}
return {
setInfo,
setActiveVar,
};
}
);
module.exports = addState(Info);

View File

@ -25,7 +25,7 @@ function Cryp(props) {
function skillClick() {
if (!skill) return false;
setInfo('skill', { skill, cryp });
setInfo('skill', { skill: skill.skill, cryp });
return setActiveCryp(cryp);
}