From b9175ecc53e7a494cdaa98a98b322c3add41723f Mon Sep 17 00:00:00 2001 From: ntr Date: Sun, 31 Mar 2019 14:01:51 +1100 Subject: [PATCH] game styles --- html-client/cryps.css | 42 ++++++-------- .../src/components/cryp.list.container.js | 2 +- html-client/src/components/cryp.list.jsx | 57 ------------------- html-client/src/components/game.component.jsx | 46 +++++++-------- .../src/components/instance.component.jsx | 2 +- 5 files changed, 38 insertions(+), 111 deletions(-) delete mode 100644 html-client/src/components/cryp.list.jsx diff --git a/html-client/cryps.css b/html-client/cryps.css index 21255df1..9acd135a 100755 --- a/html-client/cryps.css +++ b/html-client/cryps.css @@ -209,35 +209,40 @@ button:hover { this controls the size of the box as it fills the whole container */ - padding: 0 1em 2em 0; + margin: 0 1em 1em 0; + border: 1px solid whitesmoke; } /*cheeky one to push them in line with the buttons */ -.cryp-box:first-child { +.instance .cryp-box:first-child { margin-top: -2.5em; } .cryp-box figure { margin: 0; - flex: 1 1 50%; - border: 1px solid whitesmoke; + flex: 0 1 50%; text-align: center; box-sizing: border-box; display: flex; flex-flow: column; } -.cryp-box figure figcaption { +.cryp-box .stats { + display: flex; + width: 100%; + border-top: 1px solid whitesmoke; } .cryp-box .stats figure { + flex: 1 1 0; border: 0; - align-items: center + align-items: center; + padding: 0.25em 0; } -.cryp-box .stats { - border-top-width: 0; - border: 1px solid whitesmoke; +.cryp-box .stats svg { + height: 1.5em; + stroke-width: 2px; } .cryp-box .skills { @@ -251,26 +256,11 @@ button:hover { height: 25%; padding: 0; margin: 0; - border-left-width: 0px; border-bottom-width: 0px; + border-left-width: 1px; } -.cryp-skill-btn:last-child { - border-bottom-width: 1px; -} - -.cryp-box .stats { - display: flex; - width: 100%; - text-align: center; -} - -.cryp-box .stats figure { +.cryp-skill-btn:first-child { border-top-width: 0; - flex: 1 1 0; } -.cryp-box .stats svg { - height: 1em; - stroke-width: 2px; -} diff --git a/html-client/src/components/cryp.list.container.js b/html-client/src/components/cryp.list.container.js index ff4c64bf..6ae16e7a 100644 --- a/html-client/src/components/cryp.list.container.js +++ b/html-client/src/components/cryp.list.container.js @@ -1,6 +1,6 @@ const { connect } = require('preact-redux'); -const CrypList = require('./cryp.list'); +const CrypList = require('./cryp.list.component'); const actions = require('./../actions'); const addState = connect( diff --git a/html-client/src/components/cryp.list.jsx b/html-client/src/components/cryp.list.jsx deleted file mode 100644 index b42a8789..00000000 --- a/html-client/src/components/cryp.list.jsx +++ /dev/null @@ -1,57 +0,0 @@ -const preact = require('preact'); - -const { stringSort } = require('./../utils'); -const molecule = require('./molecule'); - -const idSort = stringSort('id'); - -const COLOURS = [ - '#a52a2a', - '#1FF01F', - '#3498db', -]; - -function CrypList({ cryps, selectedCryps, setSelectedCryps }) { - if (!cryps) return
not ready
; - - // redux limitation + suggested workaround - // so much for dumb components - function selectCryp(id) { - if (selectedCryps.length < 3) { - selectedCryps.push(id); - return setSelectedCryps(selectedCryps); - } - return false; - } - - const crypPanels = cryps.sort(idSort).map(cryp => { - const colour = selectedCryps.indexOf(cryp.id); - const selected = colour > -1; - - const borderColour = selected ? COLOURS[colour] : '#000000'; - - return ( -
-
selectCryp(cryp.id)} > -
- {molecule} -
-

{cryp.name}

-
-
- ); - }); - - return ( -
- {crypPanels} -
- ); -} - -module.exports = CrypList; diff --git a/html-client/src/components/game.component.jsx b/html-client/src/components/game.component.jsx index fb167f6e..85ebbf57 100644 --- a/html-client/src/components/game.component.jsx +++ b/html-client/src/components/game.component.jsx @@ -48,6 +48,7 @@ function GamePanel(props) {
{molecule} +
{cryp.name}
{skills} @@ -80,39 +81,34 @@ function GamePanel(props) { ); } - function OpponentCrypCard(cryp) { - const effects = cryp.effects.map((effect, i) => ( -
{effect.effect} for {effect.turns}T
+ function OpponentCryp(cryp, i) { + const stats = [ + { stat: 'hp', colour: '#1FF01F' }, + { stat: 'red_shield', colour: '#a52a2a' }, + { stat: 'blue_shield', colour: '#3498db' }, + ].map((s, j) => ( +
+ {saw(s.colour)} +
{cryp[s.stat].value} / {cryp[s.stat].max}
+
)); return ( -
selectSkillTarget(cryp.id)} > -
-
-
-
-

{cryp.name}

-
-
-
- -
-
- -
-
{cryp.hp.value} / {cryp.hp.value} HP
- -
- {effects} +
+
+ {molecule} +
{cryp.name}
+
+
+ {stats}
); } + function OpponentTeam(team) { - const cryps = team.cryps.map(OpponentCrypCard); + const cryps = team.cryps.map(OpponentCryp); return (
{cryps} @@ -138,11 +134,9 @@ function GamePanel(props) {
- {playerTeam.id} {PlayerTeam(playerTeam, setActiveSkill)}
- {otherTeams.id} {otherTeams.map(OpponentTeam)}
diff --git a/html-client/src/components/instance.component.jsx b/html-client/src/components/instance.component.jsx index ff56ede6..6c77f900 100644 --- a/html-client/src/components/instance.component.jsx +++ b/html-client/src/components/instance.component.jsx @@ -59,7 +59,7 @@ function InstanceComponent(args) { const cryps = instance.cryps.map(Cryp); return ( -
+