From 18bb7296886ec9f3cb70561ab5302e7c37d780c7 Mon Sep 17 00:00:00 2001 From: ntr Date: Thu, 30 May 2019 20:06:32 +1000 Subject: [PATCH] mobile buttons --- client/assets/styles/instance.css | 5 +-- client/assets/styles/instance.mobile.css | 46 +++++++------------- client/src/components/instance.component.jsx | 34 ++++++++++++--- client/src/events.jsx | 8 +++- 4 files changed, 52 insertions(+), 41 deletions(-) diff --git a/client/assets/styles/instance.css b/client/assets/styles/instance.css index 637d96d3..ac6ff176 100644 --- a/client/assets/styles/instance.css +++ b/client/assets/styles/instance.css @@ -3,7 +3,7 @@ */ .instance { - overflow: hidden; + overflow-x: hidden; display: grid; grid-template-columns: 1fr 1fr 1fr; grid-template-rows: min-content min-content min-content 1fr; @@ -441,5 +441,4 @@ button.equipping { } /* Mobile Nav*/ -#toggle-vbox { display: none; } -#toggle-vbox-label { display: none; } +.instance .nav-btn { display: none; } diff --git a/client/assets/styles/instance.mobile.css b/client/assets/styles/instance.mobile.css index 333a7fbe..5847dfd1 100644 --- a/client/assets/styles/instance.mobile.css +++ b/client/assets/styles/instance.mobile.css @@ -9,6 +9,9 @@ "vbox" "constructs" } + + .instance .nav-btn { display: initial; } + /* Default view */ .instance .equip { display: none; } .instance .info { display: none; } @@ -24,37 +27,21 @@ "combiner"; } - .vbox-inventory { - margin-left: 0; + /* constructs toggled on */ + .instance.constructs-visible .vbox { + display: none; } - .vbox-combiner { - margin-left: 0; - } - /* Toggled view (constructs)*/ - #toggle-vbox-label { - text-align: center; - border: 2px solid #555; - } - #toggle-vbox-label:after{ - content: "Constructs"; - } - - #toggle-vbox:checked ~ #toggle-vbox-label:after{ - content: "Vbox"; - } - - #toggle-vbox:checked ~ .vbox { display: none; } - #toggle-vbox:checked ~ .equip { + .instance.constructs-visible .equip { display: initial; grid-area: vbox; } - #toggle-vbox:checked ~ .highlight { + .instance.constructs-visible .highlight { display: initial; } - #toggle-vbox:checked ~ .construct-list { + .instance.constructs-visible .construct-list { grid-area: constructs; display: grid; justify-content: center; @@ -63,16 +50,13 @@ grid-template-rows: 1fr 1fr; } - #toggle-vbox { display: none; } - #toggle-vbox-label { - grid-area: controls; - color: whitesmoke; - line-height: 1.75em; - font-size: 1.5em; - display: block; - cursor: pointer; - margin-right: 0.5em; + .vbox-inventory { + margin-left: 0; + } + + .vbox-combiner { + margin-left: 0; } .construct-list .skills { diff --git a/client/src/components/instance.component.jsx b/client/src/components/instance.component.jsx index 796ac788..36ed0727 100644 --- a/client/src/components/instance.component.jsx +++ b/client/src/components/instance.component.jsx @@ -10,14 +10,14 @@ const actions = require('../actions'); const addState = connect( function receiveState(state) { - const { ws, instance, account } = state; + const { ws, instance, account, nav } = state; const player = instance.players.find(p => p.id === account.id); function sendInstanceReady() { return ws.sendInstanceReady(instance.id); } - return { player, instance, sendInstanceReady }; + return { player, instance, sendInstanceReady, nav }; }, function receiveDispatch(dispatch) { @@ -25,8 +25,13 @@ const addState = connect( return dispatch(actions.setInfo(c)); } + function setNav(v) { + return dispatch(actions.setNav(v)); + } + return { setInfo, + setNav, }; } ); @@ -37,6 +42,9 @@ function Instance(args) { player, sendInstanceReady, setInfo, + + nav, + setNav, } = args; if (!instance) return false; @@ -59,6 +67,20 @@ function Instance(args) { ); + function navClick() { + if (nav === 'vbox') return setNav('constructs'); + return setNav('vbox'); + } + + const navBtn = ( + + ); + + const actionBtn = player ? readyBtn : null; @@ -124,15 +146,15 @@ function Instance(args) { ); + const instanceClasses = `instance ${nav === 'constructs' ? 'constructs-visible' : ''}`; + return ( -
setInfo(null)} > +
setInfo(null)} >
{actionBtn} {timer} + {navBtn}
- - - diff --git a/client/src/events.jsx b/client/src/events.jsx index c033a7ae..74e012de 100644 --- a/client/src/events.jsx +++ b/client/src/events.jsx @@ -120,7 +120,13 @@ function registerEvents(store) { function setInstance(v) { const { account, ws } = store.getState(); - if (v) ws.startInstanceStateTimeout(v.id); + if (v) { + ws.startInstanceStateTimeout(v.id); + store.dispatch(actions.setNav('vbox')); + + const first = v.players.find(p => p.id === account.id).constructs[0]; + store.dispatch(actions.setActiveConstruct(first)); + } return store.dispatch(actions.setInstance(v)); }