chat wip
This commit is contained in:
parent
057ea9b528
commit
3104c841df
@ -45,5 +45,9 @@
|
|||||||
grid-area: msg;
|
grid-area: msg;
|
||||||
color: @white;
|
color: @white;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.chat {
|
||||||
|
justify-content: flex-end;
|
||||||
|
}
|
||||||
|
|
||||||
|
|||||||
@ -11,6 +11,7 @@ export const setAnimText = value => ({ type: 'SET_ANIM_TEXT', value });
|
|||||||
|
|
||||||
export const setDemo = value => ({ type: 'SET_DEMO', value });
|
export const setDemo = value => ({ type: 'SET_DEMO', value });
|
||||||
|
|
||||||
|
export const setChatShow = value => ({ type: 'SET_CHAT_SHOW', value });
|
||||||
export const setActiveItem = value => ({ type: 'SET_ACTIVE_VAR', value });
|
export const setActiveItem = value => ({ type: 'SET_ACTIVE_VAR', value });
|
||||||
export const setActiveSkill = (constructId, skill) => ({ type: 'SET_ACTIVE_SKILL', value: constructId ? { constructId, skill } : null });
|
export const setActiveSkill = (constructId, skill) => ({ type: 'SET_ACTIVE_SKILL', value: constructId ? { constructId, skill } : null });
|
||||||
export const setCombiner = value => ({ type: 'SET_COMBINER', value: Array.from(value) });
|
export const setCombiner = value => ({ type: 'SET_COMBINER', value: Array.from(value) });
|
||||||
|
|||||||
70
client/src/components/chat.jsx
Normal file
70
client/src/components/chat.jsx
Normal file
@ -0,0 +1,70 @@
|
|||||||
|
const preact = require('preact');
|
||||||
|
const { connect } = require('preact-redux');
|
||||||
|
|
||||||
|
const actions = require('../actions');
|
||||||
|
|
||||||
|
const addState = connect(
|
||||||
|
function receiveState(state) {
|
||||||
|
const {
|
||||||
|
ws,
|
||||||
|
chatShow,
|
||||||
|
instance,
|
||||||
|
} = state;
|
||||||
|
|
||||||
|
function sendChat(i) {
|
||||||
|
// return ws.sendChat(i);
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
instance,
|
||||||
|
chatShow,
|
||||||
|
|
||||||
|
sendChat,
|
||||||
|
};
|
||||||
|
},
|
||||||
|
|
||||||
|
function receiveDispatch(dispatch) {
|
||||||
|
function setChatShow(v) {
|
||||||
|
dispatch(actions.setChatShow(v));
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
setChatShow,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
function Chat(args) {
|
||||||
|
const {
|
||||||
|
instance,
|
||||||
|
chatShow,
|
||||||
|
|
||||||
|
sendChat,
|
||||||
|
setChatShow,
|
||||||
|
} = args;
|
||||||
|
|
||||||
|
const chat = [
|
||||||
|
'gl',
|
||||||
|
'hf',
|
||||||
|
'gg',
|
||||||
|
'thx',
|
||||||
|
'nice',
|
||||||
|
'hmm',
|
||||||
|
'ok',
|
||||||
|
'...',
|
||||||
|
];
|
||||||
|
|
||||||
|
function onClick(i) {
|
||||||
|
sendChat(i);
|
||||||
|
setChatShow(false);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div class={`instance-ctrl-btns chat`}>
|
||||||
|
{chat.map((c, i) => <button key={i} onClick={() => onClick(i)} >{c}</button>)}
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = addState(Chat);
|
||||||
@ -7,6 +7,7 @@ const addState = connect(
|
|||||||
function receiveState(state) {
|
function receiveState(state) {
|
||||||
const {
|
const {
|
||||||
ws,
|
ws,
|
||||||
|
chatShow,
|
||||||
instance,
|
instance,
|
||||||
} = state;
|
} = state;
|
||||||
|
|
||||||
@ -21,19 +22,32 @@ const addState = connect(
|
|||||||
|
|
||||||
return {
|
return {
|
||||||
instance,
|
instance,
|
||||||
|
chatShow,
|
||||||
|
|
||||||
sendAbandon,
|
sendAbandon,
|
||||||
sendReady,
|
sendReady,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
|
||||||
|
function receiveDispatch(dispatch) {
|
||||||
|
function setChatShow(v) {
|
||||||
|
dispatch(actions.setChatShow(v));
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
setChatShow,
|
||||||
|
};
|
||||||
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
function InstanceCtrlBtns(args) {
|
function InstanceCtrlBtns(args) {
|
||||||
const {
|
const {
|
||||||
instance,
|
instance,
|
||||||
|
chatShow,
|
||||||
|
|
||||||
sendAbandon,
|
sendAbandon,
|
||||||
sendReady,
|
sendReady,
|
||||||
|
setChatShow,
|
||||||
} = args;
|
} = args;
|
||||||
|
|
||||||
const finished = instance && instance.phase === 'Finished';
|
const finished = instance && instance.phase === 'Finished';
|
||||||
@ -49,7 +63,7 @@ function InstanceCtrlBtns(args) {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<div class="instance-ctrl-btns">
|
<div class="instance-ctrl-btns">
|
||||||
<button disabled={true} >Chat</button>
|
<button onClick={() => setChatShow(!chatShow)}>Chat</button>
|
||||||
<button disabled={finished} class="ready" onClick={() => sendReady()}>Ready</button>
|
<button disabled={finished} class="ready" onClick={() => sendReady()}>Ready</button>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|||||||
@ -1,20 +1,24 @@
|
|||||||
const preact = require('preact');
|
const preact = require('preact');
|
||||||
const { connect } = require('preact-redux');
|
const { connect } = require('preact-redux');
|
||||||
|
|
||||||
const actions = require('../actions');
|
|
||||||
const PlayerBox = require('./player.box');
|
const PlayerBox = require('./player.box');
|
||||||
|
const Chat = require('./chat');
|
||||||
const InstanceCtrlBtns = require('./instance.ctrl.btns');
|
const InstanceCtrlBtns = require('./instance.ctrl.btns');
|
||||||
const InstanceCtrlTopBtns = require('./instance.ctrl.top.btns');
|
const InstanceCtrlTopBtns = require('./instance.ctrl.top.btns');
|
||||||
|
|
||||||
|
const actions = require('../actions');
|
||||||
|
|
||||||
const addState = connect(
|
const addState = connect(
|
||||||
function receiveState(state) {
|
function receiveState(state) {
|
||||||
const {
|
const {
|
||||||
ws,
|
ws,
|
||||||
instance,
|
instance,
|
||||||
account,
|
account,
|
||||||
|
chatShow,
|
||||||
} = state;
|
} = state;
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
chatShow,
|
||||||
instance,
|
instance,
|
||||||
account,
|
account,
|
||||||
};
|
};
|
||||||
@ -25,6 +29,7 @@ function Controls(args) {
|
|||||||
const {
|
const {
|
||||||
account,
|
account,
|
||||||
instance,
|
instance,
|
||||||
|
chatShow,
|
||||||
} = args;
|
} = args;
|
||||||
|
|
||||||
if (!instance) return false;
|
if (!instance) return false;
|
||||||
@ -58,13 +63,17 @@ function Controls(args) {
|
|||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|
||||||
|
const bottom = chatShow
|
||||||
|
? <Chat />
|
||||||
|
: <PlayerBox player={player} isPlayer={true} />;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<aside>
|
<aside>
|
||||||
{timer}
|
{timer}
|
||||||
<div class="controls instance-ctrl">
|
<div class="controls instance-ctrl">
|
||||||
<InstanceCtrlTopBtns />
|
<InstanceCtrlTopBtns />
|
||||||
<PlayerBox player={opponent} />
|
<PlayerBox player={opponent} />
|
||||||
<PlayerBox player={player} isPlayer={true} />
|
{bottom}
|
||||||
<InstanceCtrlBtns />
|
<InstanceCtrlBtns />
|
||||||
</div>
|
</div>
|
||||||
</aside>
|
</aside>
|
||||||
|
|||||||
@ -24,6 +24,7 @@ module.exports = {
|
|||||||
|
|
||||||
demo: createReducer(null, 'SET_DEMO'),
|
demo: createReducer(null, 'SET_DEMO'),
|
||||||
|
|
||||||
|
chatShow: createReducer(null, 'SET_CHAT_SHOW'),
|
||||||
combiner: createReducer([], 'SET_COMBINER'),
|
combiner: createReducer([], 'SET_COMBINER'),
|
||||||
constructs: createReducer([], 'SET_CONSTRUCTS'),
|
constructs: createReducer([], 'SET_CONSTRUCTS'),
|
||||||
constructEditId: createReducer(null, 'SET_CONSTRUCT_EDIT_ID'),
|
constructEditId: createReducer(null, 'SET_CONSTRUCT_EDIT_ID'),
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user