cryp spawn button

This commit is contained in:
ntr 2019-04-03 13:21:28 +11:00
parent 43c0af4ded
commit 42124c8c48
6 changed files with 37 additions and 8 deletions

View File

@ -96,7 +96,15 @@ button.hidden {
flex-flow: column; flex-flow: column;
} }
.cryps input {
border-color: #444;
background-color: #333;
border-radius: 0;
}
.cryps input:focus {
border-color: whitesmoke;
}
/* /*
MENU MENU
@ -177,7 +185,6 @@ header {
.spawn-btn input { .spawn-btn input {
flex: 1 1 100%; flex: 1 1 100%;
margin: 1em; margin: 1em;
background-color: #333;
} }
.spawn-btn button { .spawn-btn button {

View File

@ -1,5 +1,6 @@
const preact = require('preact'); const preact = require('preact');
const { Component } = require('preact'); const { Component } = require('preact');
const range = require('lodash/range');
const { stringSort } = require('./../utils'); const { stringSort } = require('./../utils');
const molecule = require('./molecule'); const molecule = require('./molecule');
@ -17,7 +18,8 @@ class SpawnButton extends Component {
this.setState({ enabled: e }); this.setState({ enabled: e });
} }
render({ }, { enabled }) { render({ spawn }, { enabled }) {
let spawnName = null;
return ( return (
<div <div
className="menu-cryp-ctr spawn-btn"> className="menu-cryp-ctr spawn-btn">
@ -30,11 +32,12 @@ class SpawnButton extends Component {
type="text" type="text"
disabled={!enabled} disabled={!enabled}
placeholder="name" placeholder="name"
// onChange={e => spawnName = e.target.value} onChange={e => spawnName = e.target.value}
/> />
<button <button
className="login-btn" className="login-btn"
disabled={!enabled} disabled={!enabled}
onClick={() => spawn(spawnName)}
type="submit"> type="submit">
spawn spawn
</button> </button>
@ -44,7 +47,15 @@ class SpawnButton extends Component {
} }
} }
function CrypList({ cryps, selectedCryps, setSelectedCryps, sendInstanceJoin }) { function CrypList(args) {
const {
cryps,
selectedCryps,
setSelectedCryps,
sendInstanceJoin,
sendCrypSpawn
} = args;
if (!cryps) return <div></div>; if (!cryps) return <div></div>;
// redux limitation + suggested workaround // redux limitation + suggested workaround
@ -97,12 +108,18 @@ function CrypList({ cryps, selectedCryps, setSelectedCryps, sendInstanceJoin })
); );
}); });
const spawnButtonsNum = cryps.length < 3
? (3 - cryps.length)
: 1;
const spawnButtons = range(spawnButtonsNum)
.map(() => <SpawnButton key={Date.now()} spawn={name => sendCrypSpawn(name)} />);
return ( return (
<div className="menu-cryps"> <div className="menu-cryps">
{instanceJoin} {instanceJoin}
{crypPanels} {crypPanels}
<SpawnButton /> {spawnButtons}
</div> </div>
); );
} }

View File

@ -14,7 +14,11 @@ const addState = connect(
return false; return false;
} }
return { cryps, selectedCryps, sendInstanceJoin }; function sendCrypSpawn(name) {
return ws.sendCrypSpawn(name);
}
return { cryps, selectedCryps, sendInstanceJoin, sendCrypSpawn };
}, },
function receiveDispatch(dispatch) { function receiveDispatch(dispatch) {

View File

@ -9,7 +9,7 @@ const addState = connect(
return ws.sendAccountLogin(name, password); return ws.sendAccountLogin(name, password);
} }
function submitRegister(name, password) { function submitRegister(name, password) {
return ws.sendAccountRegister(name, password); return ws.sendAccountCreate(name, password);
} }
function submitDemo() { function submitDemo() {
return ws.sendAccountDemo(); return ws.sendAccountDemo();

View File

@ -259,7 +259,7 @@ function createSocket(events) {
// if (!account) events.loginPrompt(); // if (!account) events.loginPrompt();
if (process.env.NODE_ENV !== 'production') { if (process.env.NODE_ENV !== 'production') {
send({ method: 'account_login', params: { name: 'ntr', password: 'grepgrepgrep' } }); send({ method: 'account_login', params: { name: 'grepking', password: 'grepgrepgrep' } });
} }
return true; return true;

View File

@ -67,6 +67,7 @@ $$$
# Db maintenance # Db maintenance
# Art Styles # Art Styles
* illusions
* Aztec * Aztec
* youkai * youkai
* Pixel * Pixel