diff --git a/client/assets/styles/styles.css b/client/assets/styles/styles.css index ff7d5dcb..a4efc732 100644 --- a/client/assets/styles/styles.css +++ b/client/assets/styles/styles.css @@ -370,6 +370,7 @@ header { } .constructs-list { + max-height: 100%; margin-top: 0.5em; grid-area: team; diff --git a/client/assets/styles/styles.mobile.css b/client/assets/styles/styles.mobile.css index bd29c7f6..e5db00b4 100644 --- a/client/assets/styles/styles.mobile.css +++ b/client/assets/styles/styles.mobile.css @@ -18,45 +18,21 @@ } nav { - opacity: 0; - position: fixed; - margin-top: 4em; - pointer-events: none; - -webkit-transition: all 0.5s ease-in-out; - -moz-transition: all 0.5s ease-in-out; - -o-transition: all 0.5s ease-in-out; - transition: all 0.5s ease-in-out; + display: none; + } + + #mnml.nav-visible nav { + display: grid; + } + + #mnml.nav-visible main { + display: none; } main { overflow-x: hidden; } - #toggle-nav { display: none; } - - #toggle-nav-label { - grid-area: tnav; - color: whitesmoke; - line-height: 1.75em; - font-size: 1.5em; - display: block; - cursor: pointer; - margin-right: 0.5em; - } - - #toggle-nav:checked #toggle-nav-label { - color: #ababab; - } - - #toggle-nav:checked ~ nav { - opacity: 1; - pointer-events: auto; - } - #toggle-nav:checked ~ main { - opacity: 0.1; - pointer-events: none; - } - .login { width: 100%; } diff --git a/client/src/actions.jsx b/client/src/actions.jsx index 9e8e1b43..f729d120 100644 --- a/client/src/actions.jsx +++ b/client/src/actions.jsx @@ -5,6 +5,7 @@ export const setSkip = value => ({ type: 'SET_SKIP', value }); export const setVboxHighlight = value => ({ type: 'SET_VBOX_HIGHLIGHT', value }); export const setInstances = value => ({ type: 'SET_INSTANCES', value }); export const setNav = value => ({ type: 'SET_NAV', value }); +export const setShowNav = value => ({ type: 'SET_SHOW_NAV', value }); export const setInstance = value => ({ type: 'SET_INSTANCE', value }); export const setPing = value => ({ type: 'SET_PING', value }); export const setGame = value => ({ type: 'SET_GAME', value }); diff --git a/client/src/app.jsx b/client/src/app.jsx index 12827c59..715103e2 100644 --- a/client/src/app.jsx +++ b/client/src/app.jsx @@ -1,7 +1,7 @@ const preact = require('preact'); // const logger = require('redux-diff-logger'); -const { Provider } = require('react-redux'); +const { Provider, connect } = require('react-redux'); const { createStore, combineReducers } = require('redux'); const reducers = require('./reducers'); @@ -10,9 +10,7 @@ const setupKeys = require('./keyboard'); const createSocket = require('./socket'); const registerEvents = require('./events'); -const Header = require('./components/header.container'); -const Main = require('./components/main'); -const Nav = require('./components/nav'); +const Mnml = require('./components/mnml'); // Redux Store const store = createStore( @@ -28,16 +26,6 @@ document.fonts.load('16pt "Jura"').then(() => { store.dispatch(actions.setWs(ws)); ws.connect(); - const Mnml = () => ( -
- - -
-
- ); - const App = () => ( diff --git a/client/src/components/login.component.jsx b/client/src/components/login.component.jsx index 41465585..2e8ba903 100644 --- a/client/src/components/login.component.jsx +++ b/client/src/components/login.component.jsx @@ -1,41 +1,44 @@ // eslint-disable-next-line const preact = require('preact'); -const { useState } = require('preact/hooks'); function renderLogin({ submitLogin, submitRegister }) { - const [name, setName] = useState(''); - const [password, setPassword] = useState(''); + const details = { + name: '', + password: '', + }; return ( -
- setName(e.target.value)} - /> - setPassword(e.target.value)} - /> - - - -
+
+
+ (details.name = e.target.value)} + /> + (details.password = e.target.value)} + /> + + + +
+
); } diff --git a/client/src/components/login.container.jsx b/client/src/components/login.container.jsx index 0cba679e..32a451c4 100644 --- a/client/src/components/login.container.jsx +++ b/client/src/components/login.container.jsx @@ -4,7 +4,7 @@ const Login = require('./login.component'); const addState = connect( (state) => { - const { ws } = state; + const { ws, account } = state; function submitLogin(name, password) { return ws.sendAccountLogin(name, password); } @@ -12,7 +12,7 @@ const addState = connect( console.log(name, password); return ws.sendAccountCreate(name, password); } - return { account: state.account, submitLogin, submitRegister }; + return { account, submitLogin, submitRegister }; }, ); diff --git a/client/src/components/main.jsx b/client/src/components/main.jsx index 0e4c7b28..ec4b132e 100644 --- a/client/src/components/main.jsx +++ b/client/src/components/main.jsx @@ -24,23 +24,15 @@ function Main(props) { } = props; if (!account) { - return ( -
- -
- ); + return ; } if (game) { - return ( - - ); + return ; } if (instance) { - return ( - - ); + return ; } if (nav === 'team') return ; diff --git a/client/src/components/mnml.jsx b/client/src/components/mnml.jsx new file mode 100644 index 00000000..b69c718c --- /dev/null +++ b/client/src/components/mnml.jsx @@ -0,0 +1,24 @@ +const preact = require('preact'); +const { connect } = require('react-redux'); + +const actions = require('./../actions'); +const Header = require('./header.container'); +const Main = require('./main'); +const Nav = require('./nav'); + +const addState = connect( + state => ({ showNav: state.showNav }), + dispatch => ({ + setShowNav: v => dispatch(actions.setShowNav(v)), + }) +); + +const Mnml = ({ showNav, setShowNav }) => +
+ setShowNav(!showNav)} className="fa fa-bars"> +
+
; + +module.exports = addState(Mnml); diff --git a/client/src/components/nav.jsx b/client/src/components/nav.jsx index d7a352a4..244bce49 100644 --- a/client/src/components/nav.jsx +++ b/client/src/components/nav.jsx @@ -15,6 +15,7 @@ const addState = connect( team, constructs, game, + showNav, } = state; function sendInstanceState(instance) { @@ -31,6 +32,7 @@ const addState = connect( team, constructs, game, + showNav, sendInstanceState, sendAccountInstances, }; @@ -68,6 +70,7 @@ function Nav(args) { constructs, instances, game, + showNav, setTestGame, setTestInstance, diff --git a/client/src/components/spawn.button.jsx b/client/src/components/spawn.button.jsx index 65924d77..fceeb1d0 100644 --- a/client/src/components/spawn.button.jsx +++ b/client/src/components/spawn.button.jsx @@ -1,42 +1,57 @@ const preact = require('preact'); -const { useState } = require('preact/hooks'); +const { Component } = require('preact'); -function SpawnButton({ spawn }) { - const [name, setName] = useState(''); - const [enabled, setEnabled] = useState(false); +class SpawnButton extends Component { + constructor(props) { + super(props); - function nameInput(e) { - e.stopPropagation(); - setName(e.target.value); + this.state = { value: null, enabled: false }; + + this.handleInput = this.handleInput.bind(this); + this.handleSubmit = this.handleSubmit.bind(this); + this.enable = this.enable.bind(this); } - function enabledToggle(e) { - e.stopPropagation(); - setEnabled(true); + handleInput(event) { + console.log(event.target.value); + this.setState({ value: event.target.value }); } - return ( -
enabledToggle(e)} > -

+

- nameInput(e)} - /> - -
- ); + handleSubmit(event) { + event.preventDefault(); + this.props.spawn(this.state.value); + this.setState({ value: null, enabled: false }); + } + + enable() { + this.setState({ enabled: true }); + } + + render() { + return ( +
this.enable()} > +

+

+ + +
+ ); + } } module.exports = SpawnButton; \ No newline at end of file diff --git a/client/src/reducers.jsx b/client/src/reducers.jsx index 88c5d91a..4e5baf16 100644 --- a/client/src/reducers.jsx +++ b/client/src/reducers.jsx @@ -12,11 +12,11 @@ function createReducer(defaultState, actionType) { /* eslint-disable key-spacing */ module.exports = { account: createReducer(null, 'SET_ACCOUNT'), - activeConstruct: createReducer(null, 'SET_ACTIVE_CONSTRUCT'), + activeConstruct: createReducer(null, 'SET_ACTIVE_CONSTRUCT'), activeItem: createReducer(null, 'SET_ACTIVE_VAR'), activeSkill: createReducer(null, 'SET_ACTIVE_SKILL'), combiner: createReducer([null, null, null], 'SET_COMBINER'), - constructs: createReducer([], 'SET_CONSTRUCTS'), + constructs: createReducer([], 'SET_CONSTRUCTS'), game: createReducer(null, 'SET_GAME'), info: createReducer(null, 'SET_INFO'), instance: createReducer(null, 'SET_INSTANCE'), @@ -25,6 +25,7 @@ module.exports = { itemInfo: createReducer({ combos: [], items: [] }, 'SET_ITEM_INFO'), itemUnequip: createReducer(null, 'SET_ITEM_UNEQUIP'), nav: createReducer(null, 'SET_NAV'), + showNav: createReducer(null, 'SET_SHOW_NAV'), ping: createReducer(null, 'SET_PING'), reclaiming: createReducer(false, 'SET_RECLAIMING'), resolution: createReducer(null, 'SET_RESOLUTION'), diff --git a/client/src/utils.jsx b/client/src/utils.jsx index 01d4b34c..6d9d452a 100644 --- a/client/src/utils.jsx +++ b/client/src/utils.jsx @@ -1,5 +1,4 @@ const preact = require('preact'); -const { useEffect } = require('preact/hooks'); const get = require('lodash/get'); const anime = require('animejs').default; @@ -80,10 +79,10 @@ function clearAnimation(id) { } function constructAvatar(name, id) { - useEffect(() => { - animateConstruct(id); - return () => clearAnimation(id); - }); + // useEffect(() => { + // animateConstruct(id); + // return () => clearAnimation(id); + // }); return ( { - animateConstruct(id); - return () => clearAnimation(id); - }); + // useEffect(() => { + // animateConstruct(id); + // return () => clearAnimation(id); + // }); return (
{ - animateConstruct(id); - return () => clearAnimation(id); - }); + // useEffect(() => { + // animateConstruct(id); + // return () => clearAnimation(id); + // }); return (