Grouping stats and labels

This commit is contained in:
Mashy 2019-05-11 20:28:45 +10:00
parent cc04738902
commit 3a06774817
3 changed files with 92 additions and 12 deletions

View File

@ -29,7 +29,6 @@
.instance-info { .instance-info {
grid-area: x; grid-area: x;
justify-self: start;
flex: 0 0 50%; flex: 0 0 50%;
} }
@ -40,7 +39,8 @@
display: flex; display: flex;
flex-flow: row; flex-flow: row;
padding: 0 2em 0 2em; padding: 0 2em 0 2em;
justify-content: center; align-content: flex-start;
min-width: 300px; min-width: 300px;
overflow: hidden; overflow: hidden;
@ -187,7 +187,8 @@
"av av av sk sk" "av av av sk sk"
"av av av sk sk" "av av av sk sk"
"st st st st st"; "st st st st st";
max-height: 450px;
max-width: 450px;
margin-left: 1em; margin-left: 1em;
border: 1px solid whitesmoke; border: 1px solid whitesmoke;
transition-property: all; transition-property: all;
@ -204,7 +205,7 @@
.instance-cryp .avatar figure { .instance-cryp .avatar figure {
margin: 0; margin: 0;
height: 100%; height: 80%;
text-align: center; text-align: center;
box-sizing: border-box; box-sizing: border-box;
} }
@ -246,9 +247,12 @@
.instance-cryp .stats { .instance-cryp .stats {
grid-area: st; grid-area: st;
display: flex; display: grid;
flex: 1; grid-template-rows: 1fr 3fr;
justify-content: center; grid-template-columns: repeat(7, 1fr);
grid-template-areas:
"dl dl dl sl ll ll ll"
"di di di si li li li";
border-top: 1px solid whitesmoke; border-top: 1px solid whitesmoke;
} }
@ -263,3 +267,48 @@
.instance-cryp .stats figcaption { .instance-cryp .stats figcaption {
font-size: 75%; font-size: 75%;
} }
.instance-cryp .stats .damage-label {
grid-area: dl;
display: flex;
justify-content: center;
}
.instance-cryp .stats .damage-icons {
grid-area: di;
display: flex;
flex-flow: row;
flex: 1;
justify-content: center;
}
.instance-cryp .stats .speed-label {
grid-area: sl;
display: flex;
justify-content: center;
}
.instance-cryp .stats .speed-icons {
grid-area: si;
display: flex;
flex-flow: row;
flex: 1;
justify-content: center;
}
.instance-cryp .stats .life-label {
grid-area: ll;
display: flex;
justify-content: center;
}
.instance-cryp .stats .life-icons {
grid-area: li;
display: flex;
flex-flow: row;
flex: 1;
justify-content: center;
}

View File

@ -119,12 +119,27 @@ function Cryp(props) {
); );
}); });
const stats = Object.values(STATS).map((s, j) => ( const damage = Object.values(STATS).slice(0, 3).map(s => (
<figure key={j} alt={s.stat} className={s.stat}> <figure key={s.stat} alt={s.stat} className={s.stat}>
{s.svg(`stat-icon ${s.colour}`)} {s.svg(`stat-icon ${s.colour}`)}
<figcaption>{cryp[s.stat].value}</figcaption> <figcaption>{cryp[s.stat].value}</figcaption>
</figure> </figure>
)); ));
const speed = Object.values(STATS).slice(3, 4).map(s => (
<figure key={s.stat} alt={s.stat} className={s.stat}>
{s.svg(`stat-icon ${s.colour}`)}
<figcaption>{cryp[s.stat].value}</figcaption>
</figure>
));
const life = Object.values(STATS).slice(4, 8).map(s => (
<figure key={s.stat} alt={s.stat} className={s.stat}>
{s.svg(`stat-icon ${s.colour}`)}
<figcaption>{cryp[s.stat].value}</figcaption>
</figure>
));
// const cTotal = cryp.colours.red + cryp.colours.blue + cryp.colours.green; // const cTotal = cryp.colours.red + cryp.colours.blue + cryp.colours.green;
// const colours = mapValues(cryp.colours, c => { // const colours = mapValues(cryp.colours, c => {
// if (cTotal === 0) return 245; // if (cTotal === 0) return 245;
@ -138,7 +153,6 @@ function Cryp(props) {
// return 4; // return 4;
// }; // };
// const border = { border: `${thickness(cTotal)}px solid rgba(${colours.red}, ${colours.green}, ${colours.blue}, ${alpha})` }; // const border = { border: `${thickness(cTotal)}px solid rgba(${colours.red}, ${colours.green}, ${colours.blue}, ${alpha})` };
return ( return (
<div key={cryp.id} className="instance-cryp" onClick={onClick} > <div key={cryp.id} className="instance-cryp" onClick={onClick} >
<div className="avatar"> <div className="avatar">
@ -154,7 +168,24 @@ function Cryp(props) {
{specs} {specs}
</div> </div>
<div className="stats"> <div className="stats">
{stats} <div className="damage-label">
Damage
</div>
<div className="damage-icons">
{damage}
</div>
<div className="speed-label">
Speed
</div>
<div className="speed-icons">
{speed}
</div>
<div className="life-label">
Life
</div>
<div className="life-icons">
{life}
</div>
</div> </div>
</div> </div>
); );

View File

@ -68,10 +68,10 @@ const STATS = {
redDamage: { stat: 'red_damage', colour: 'red', svg: shapes.circle }, redDamage: { stat: 'red_damage', colour: 'red', svg: shapes.circle },
greenDamage: { stat: 'green_damage', colour: 'green', svg: shapes.circle }, greenDamage: { stat: 'green_damage', colour: 'green', svg: shapes.circle },
blueDamage: { stat: 'blue_damage', colour: 'blue', svg: shapes.circle }, blueDamage: { stat: 'blue_damage', colour: 'blue', svg: shapes.circle },
speed: { stat: 'speed', colour: 'white', svg: shapes.triangle },
redLife: { stat: 'red_life', colour: 'red', svg: shapes.square }, redLife: { stat: 'red_life', colour: 'red', svg: shapes.square },
greenLife: { stat: 'green_life', colour: 'green', svg: shapes.square }, greenLife: { stat: 'green_life', colour: 'green', svg: shapes.square },
blueLife: { stat: 'blue_life', colour: 'blue', svg: shapes.square }, blueLife: { stat: 'blue_life', colour: 'blue', svg: shapes.square },
speed: { stat: 'speed', colour: 'white', svg: shapes.triangle },
}; };
const SPECS = { const SPECS = {