diff --git a/client/cryps.css b/client/cryps.css index 23bb53c9..61a69df2 100644 --- a/client/cryps.css +++ b/client/cryps.css @@ -86,6 +86,18 @@ button.left:hover, button.left:focus { box-shadow: inset 0.5em 0 0 0 whitesmoke; } +/* + LOGIN +*/ + +.login { + flex: 0 1 25%; + display: flex; + flex-flow: column; +} + + + /* MENU */ @@ -117,11 +129,6 @@ header { background-color: black; } -.login { - display: inline; - margin-right: 0; -} - .ping-path { fill: none; stroke-width: 4px; @@ -180,7 +187,7 @@ header { .menu-instance-btn { box-sizing: border-box; - flex: 1 0 20%; + flex: 1 0 100%; font-size: 150%; /*min-width: 20%;*/ border-width: 2px; @@ -188,10 +195,6 @@ header { margin: 0.5em; } -.menu-instance-btn.full { - flex: 1 0 100%; -} - /* INSTANCE */ diff --git a/client/src/components/body.component.jsx b/client/src/components/body.component.jsx index 3dc1c250..b928d184 100644 --- a/client/src/components/body.component.jsx +++ b/client/src/components/body.component.jsx @@ -3,25 +3,34 @@ const preact = require('preact'); const { connect } = require('preact-redux'); const InstanceListContainer = require('./instance.list.container'); +const LoginContainer = require('./login.container'); const CrypListContainer = require('./cryp.list.container'); const GameContainer = require('./game.container'); const InstanceContainer = require('./instance.container'); const addState = connect( - (state) => { - const { game, instance, ws } = state; + state => { + const { game, instance, ws, account } = state; if (!game) { console.log('clear gs interval'); // ws.clearGameStateInterval(); } - return { game, instance }; + return { game, instance, account }; } ); function renderBody(props) { - const { game, instance } = props; + const { game, instance, account } = props; + + if (!account) { + return ( +
+ +
+ ); + } if (game) { return ( diff --git a/client/src/components/header.component.jsx b/client/src/components/header.component.jsx index eb265dc3..c7b50237 100644 --- a/client/src/components/header.component.jsx +++ b/client/src/components/header.component.jsx @@ -1,14 +1,23 @@ // eslint-disable-next-line const preact = require('preact'); -const LoginContainer = require('./login.container'); -function renderHeader() { +const saw = require('./saw.component'); + +function renderHeader(args) { + const { account } = args; + const accountStatus = account ? + (
+

{account.name}

+ {saw('whitesmoke')} +
) + : ''; + return (

cryps.gg

- + {accountStatus}
); } diff --git a/client/src/components/header.container.jsx b/client/src/components/header.container.jsx new file mode 100644 index 00000000..df1da5f9 --- /dev/null +++ b/client/src/components/header.container.jsx @@ -0,0 +1,11 @@ +const { connect } = require('preact-redux'); + +const Header = require('./header.component'); + +const addState = connect( + ({ account }) => { + return { account }; + }, +); + +module.exports = addState(Header); diff --git a/client/src/components/instance.list.component.jsx b/client/src/components/instance.list.component.jsx index 4d1bf265..97678f53 100644 --- a/client/src/components/instance.list.component.jsx +++ b/client/src/components/instance.list.component.jsx @@ -25,7 +25,7 @@ function instanceList({ instances, setActiveInstance, sendInstanceJoin }) { className={`menu-instance-btn right ${globalInstance ? 'full' : ''}`} key={instance.id} onClick={() => setActiveInstance(instance)}> - {name} + {name} | {instance.score.wins} : {instance.score.losses} ); }); diff --git a/client/src/components/login.component.jsx b/client/src/components/login.component.jsx index 475f5fa4..5ac70808 100644 --- a/client/src/components/login.component.jsx +++ b/client/src/components/login.component.jsx @@ -1,74 +1,44 @@ // eslint-disable-next-line const preact = require('preact'); -const saw = require('./saw.component'); - -function renderLogin({ account, submitLogin, submitRegister }) { - if (account) return ( -
-

{account.name}

- {saw('whitesmoke')} -
- ); - +function renderLogin({ submitLogin, submitRegister, submitDemo }) { const details = { name: '', password: '', }; return ( -
-
-

- (details.name = e.target.value)} - /> - - - - - - -

-
-
-

- (details.password = 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 d299732d..d9b60196 100644 --- a/client/src/components/login.container.jsx +++ b/client/src/components/login.container.jsx @@ -11,7 +11,10 @@ const addState = connect( function submitRegister(name, password) { return ws.sendAccountRegister(name, password); } - return { account: state.account, submitLogin, submitRegister }; + function submitDemo() { + return ws.sendAccountDemo(); + } + return { account: state.account, submitLogin, submitRegister, submitDemo }; }, ); diff --git a/client/src/main.jsx b/client/src/main.jsx index ecf02927..73eb97ad 100644 --- a/client/src/main.jsx +++ b/client/src/main.jsx @@ -10,7 +10,7 @@ const setupKeys = require('./keyboard'); const createSocket = require('./socket'); const registerEvents = require('./events'); -const Header = require('./components/header.component'); +const Header = require('./components/header.container'); const Body = require('./components/body.component'); // Redux Store diff --git a/client/src/socket.jsx b/client/src/socket.jsx index cc77a7c9..01e666ef 100644 --- a/client/src/socket.jsx +++ b/client/src/socket.jsx @@ -259,7 +259,7 @@ function createSocket(events) { // if (!account) events.loginPrompt(); if (process.env.NODE_ENV !== 'production') { - send({ method: 'account_login', params: { name: 'ntr', password: 'grepgrepgrep' } }); + // send({ method: 'account_login', params: { name: 'ntr', password: 'grepgrepgrep' } }); } return true;