From 1ee7996485dff8fa9ab4fc41f62294a1c94975ae Mon Sep 17 00:00:00 2001 From: ntr Date: Mon, 15 Oct 2018 23:23:04 +1100 Subject: [PATCH] bulma shit --- client/src/actions.jsx | 3 ++ client/src/components/body.component.jsx | 16 +++++++-- client/src/components/cryp.list.jsx | 12 +++---- client/src/components/cryp.panel.jsx | 2 +- client/src/components/cryp.spawn.button.jsx | 31 ++++++++++++++++ client/src/components/cryp.spawn.container.js | 18 ++++++++++ client/src/components/item.list.container.js | 16 +++++++++ client/src/components/item.list.jsx | 36 +++++++++++++++++++ client/src/components/login.component.jsx | 2 +- client/src/components/sidebar.component.jsx | 19 ---------- client/src/main.jsx | 3 +- client/src/reducers.jsx | 11 ++++++ client/src/socket.jsx | 7 +++- server/WORKLOG.md | 8 ++++- 14 files changed, 151 insertions(+), 33 deletions(-) create mode 100644 client/src/components/cryp.spawn.button.jsx create mode 100644 client/src/components/cryp.spawn.container.js create mode 100644 client/src/components/item.list.container.js create mode 100644 client/src/components/item.list.jsx delete mode 100644 client/src/components/sidebar.component.jsx diff --git a/client/src/actions.jsx b/client/src/actions.jsx index 524561a1..52a062c3 100644 --- a/client/src/actions.jsx +++ b/client/src/actions.jsx @@ -4,6 +4,9 @@ export const setAccount = (value) => ({ type: SET_ACCOUNT, value }); export const SET_CRYPS = 'SET_CRYPS'; export const setCryps = (value) => ({ type: SET_CRYPS, value }); +export const SET_ITEMS = 'SET_ITEMS'; +export const setItems = (value) => ({ type: SET_ITEMS, value }); + export const SET_BATTLE = 'SET_BATTLE'; export const setBattle = (value) => ({ type: SET_BATTLE, value }); diff --git a/client/src/components/body.component.jsx b/client/src/components/body.component.jsx index 159f8c41..f4bbfaea 100644 --- a/client/src/components/body.component.jsx +++ b/client/src/components/body.component.jsx @@ -1,14 +1,26 @@ // eslint-disable-next-line const preact = require('preact'); +const ItemListContainer = require('./item.list.container'); +const CrypSpawnContainer = require('./cryp.spawn.container'); const CrypListContainer = require('./cryp.list.container'); const BattleContainer = require('./battle.container'); function renderBody() { return (
-
- +
+
+ +
+
+
+ +
+
+ +
+
diff --git a/client/src/components/cryp.list.jsx b/client/src/components/cryp.list.jsx index ce7091b2..87cd8c75 100644 --- a/client/src/components/cryp.list.jsx +++ b/client/src/components/cryp.list.jsx @@ -1,10 +1,11 @@ const preact = require('preact'); + function CrypList({ cryps, sendCombatPve }) { if (!cryps) return
not ready
; const crypPanels = cryps.map(cryp => ( -
+
@@ -19,10 +20,10 @@ function CrypList({ cryps, sendCombatPve }) {
{cryp.hp.value} / {cryp.stam.value} HP
- +
)); return ( -
- - Spawn 👾 - +
{crypPanels}
); diff --git a/client/src/components/cryp.panel.jsx b/client/src/components/cryp.panel.jsx index 99694d6e..2c598704 100644 --- a/client/src/components/cryp.panel.jsx +++ b/client/src/components/cryp.panel.jsx @@ -28,7 +28,7 @@ function renderCrypPanel(cryp) {
5 / 5 HP
- +
diff --git a/client/src/components/cryp.spawn.button.jsx b/client/src/components/cryp.spawn.button.jsx new file mode 100644 index 00000000..f55ce1ab --- /dev/null +++ b/client/src/components/cryp.spawn.button.jsx @@ -0,0 +1,31 @@ +// eslint-disable-next-line +const preact = require('preact'); + +function renderSpawnButton({ account, sendCrypSpawn }) { + let name = ''; + + if (!account) return
...
; + + return ( +
+
+ (name = e.target.value)} + /> +
+
+ +
+
+ ); +} + +module.exports = renderSpawnButton; \ No newline at end of file diff --git a/client/src/components/cryp.spawn.container.js b/client/src/components/cryp.spawn.container.js new file mode 100644 index 00000000..23d918fa --- /dev/null +++ b/client/src/components/cryp.spawn.container.js @@ -0,0 +1,18 @@ +const { connect } = require('preact-redux'); + +const CrypSpawnButton = require('./cryp.spawn.button'); + +const addState = connect( + function receiveState(state) { + const { ws } = state; + function sendCrypSpawn(name) { + return ws.sendCrypSpawn(name); + } + + console.log(ws); + + return { account: state.account, sendCrypSpawn }; + } +); + +module.exports = addState(CrypSpawnButton); diff --git a/client/src/components/item.list.container.js b/client/src/components/item.list.container.js new file mode 100644 index 00000000..d035102a --- /dev/null +++ b/client/src/components/item.list.container.js @@ -0,0 +1,16 @@ +const { connect } = require('preact-redux'); + +const ItemList = require('./item.list'); + +const addState = connect( + function receiveState(state) { + const { ws, items } = state; + function sendItemUse(crypId) { + return ws.sendItemUse(crypId); + } + + return { items, sendItemUse }; + } +); + +module.exports = addState(ItemList); diff --git a/client/src/components/item.list.jsx b/client/src/components/item.list.jsx new file mode 100644 index 00000000..95b2f31b --- /dev/null +++ b/client/src/components/item.list.jsx @@ -0,0 +1,36 @@ +const preact = require('preact'); + +function ItemList({ items, sendItemUse }) { + if (!items) return
...
; + const itemPanels = items.map(item => ( + +
+
+
+
+

{item.action}

+

∞

+
+
+
+ +
+
+
+
+ +
+ )); + return ( +
+ {itemPanels} +
+ ); +} + +module.exports = ItemList; diff --git a/client/src/components/login.component.jsx b/client/src/components/login.component.jsx index 140ee015..4a17ecde 100644 --- a/client/src/components/login.component.jsx +++ b/client/src/components/login.component.jsx @@ -43,7 +43,7 @@ function renderLogin({ account, submitLogin }) {