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

View File

@ -1,7 +1,6 @@
const { connect } = require('preact-redux'); const { connect } = require('preact-redux');
// const actions = require('../actions'); const actions = require('../actions');
const Info = require('./info.component'); const Info = require('./info.component');
const addState = connect( const addState = connect(
@ -23,13 +22,24 @@ const addState = connect(
sendUnequip, sendUnequip,
instance, 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); module.exports = addState(Info);

View File

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