Merge branch 'feature-chat-badge' into develop
commit
cd6db5e08d
|
|
@ -7,6 +7,13 @@ import MessageList from './Chat/MessageList';
|
||||||
|
|
||||||
class ChatWidget extends Component
|
class ChatWidget extends Component
|
||||||
{
|
{
|
||||||
|
componentWillReceiveProps(nextProps)
|
||||||
|
{
|
||||||
|
if (nextProps.chatmessages.length !== this.props.chatmessages.length)
|
||||||
|
if (!this.props.showChat)
|
||||||
|
this.props.increaseBadge();
|
||||||
|
}
|
||||||
|
|
||||||
render()
|
render()
|
||||||
{
|
{
|
||||||
const {
|
const {
|
||||||
|
|
@ -68,15 +75,15 @@ ChatWidget.propTypes =
|
||||||
disabledInput : PropTypes.bool,
|
disabledInput : PropTypes.bool,
|
||||||
badge : PropTypes.number,
|
badge : PropTypes.number,
|
||||||
autofocus : PropTypes.bool,
|
autofocus : PropTypes.bool,
|
||||||
displayName : PropTypes.string
|
displayName : PropTypes.string,
|
||||||
|
chatmessages : PropTypes.arrayOf(PropTypes.object),
|
||||||
|
increaseBadge : PropTypes.func
|
||||||
};
|
};
|
||||||
|
|
||||||
ChatWidget.defaultProps =
|
ChatWidget.defaultProps =
|
||||||
{
|
{
|
||||||
senderPlaceHolder : 'Type a message...',
|
senderPlaceHolder : 'Type a message...',
|
||||||
badge : 0,
|
autofocus : true
|
||||||
autofocus : true,
|
|
||||||
displayName : null
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const mapStateToProps = (state) =>
|
const mapStateToProps = (state) =>
|
||||||
|
|
@ -84,7 +91,9 @@ const mapStateToProps = (state) =>
|
||||||
return {
|
return {
|
||||||
showChat : state.chatbehavior.showChat,
|
showChat : state.chatbehavior.showChat,
|
||||||
disabledInput : state.chatbehavior.disabledInput,
|
disabledInput : state.chatbehavior.disabledInput,
|
||||||
displayName : state.me.displayName
|
displayName : state.me.displayName,
|
||||||
|
badge : state.chatbehavior.badge,
|
||||||
|
chatmessages : state.chatmessages
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -106,6 +115,10 @@ const mapDispatchToProps = (dispatch) =>
|
||||||
dispatch(requestActions.sendChatMessage(userInput, displayName));
|
dispatch(requestActions.sendChatMessage(userInput, displayName));
|
||||||
}
|
}
|
||||||
event.target.message.value = '';
|
event.target.message.value = '';
|
||||||
|
},
|
||||||
|
increaseBadge : () =>
|
||||||
|
{
|
||||||
|
dispatch(stateActions.increaseBadge());
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -12,8 +12,9 @@ const chatbehavior = (state = initialState, action) =>
|
||||||
case 'TOGGLE_CHAT':
|
case 'TOGGLE_CHAT':
|
||||||
{
|
{
|
||||||
const showChat = !state.showChat;
|
const showChat = !state.showChat;
|
||||||
|
const badge = 0;
|
||||||
|
|
||||||
return { ...state, showChat };
|
return { ...state, showChat, badge };
|
||||||
}
|
}
|
||||||
|
|
||||||
case 'TOGGLE_INPUT_DISABLED':
|
case 'TOGGLE_INPUT_DISABLED':
|
||||||
|
|
@ -23,6 +24,10 @@ const chatbehavior = (state = initialState, action) =>
|
||||||
return { ...state, disabledInput };
|
return { ...state, disabledInput };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
case 'INCREASE_BADGE':
|
||||||
|
{
|
||||||
|
return { ...state, badge: state.badge + (state.showChat ? 0 : 1) };
|
||||||
|
}
|
||||||
default:
|
default:
|
||||||
return state;
|
return state;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -338,6 +338,13 @@ export const toggleChat = () =>
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const increaseBadge = () =>
|
||||||
|
{
|
||||||
|
return {
|
||||||
|
type : 'INCREASE_BADGE'
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
export const toggleInputDisabled = () =>
|
export const toggleInputDisabled = () =>
|
||||||
{
|
{
|
||||||
return {
|
return {
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,7 @@
|
||||||
right: 0;
|
right: 0;
|
||||||
width: 90vw;
|
width: 90vw;
|
||||||
z-index: 9999;
|
z-index: 9999;
|
||||||
|
|
||||||
> .launcher {
|
> .launcher {
|
||||||
align-self: flex-end;
|
align-self: flex-end;
|
||||||
margin-top: 10px;
|
margin-top: 10px;
|
||||||
|
|
@ -23,11 +23,12 @@
|
||||||
border-radius: 100%;
|
border-radius: 100%;
|
||||||
height: 45px;
|
height: 45px;
|
||||||
width: 45px;
|
width: 45px;
|
||||||
|
position: relative;
|
||||||
|
|
||||||
&.focus {
|
&.focus {
|
||||||
outline: none;
|
outline: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
&.on {
|
&.on {
|
||||||
background-color: rgba(#fff, 0.7);
|
background-color: rgba(#fff, 0.7);
|
||||||
}
|
}
|
||||||
|
|
@ -36,6 +37,17 @@
|
||||||
pointer-events: none;
|
pointer-events: none;
|
||||||
opacity: 0.5;
|
opacity: 0.5;
|
||||||
}
|
}
|
||||||
|
> .badge{
|
||||||
|
border-radius: 50%;
|
||||||
|
padding: 0.7vmin;
|
||||||
|
top: -1vmin;
|
||||||
|
font-size: 1.5vmin;
|
||||||
|
left: -1vmin;
|
||||||
|
background: rgba(255,0,0,0.9);
|
||||||
|
color: #fff;
|
||||||
|
font-weight: bold;
|
||||||
|
position: absolute;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -105,7 +117,7 @@
|
||||||
height: 35px;
|
height: 35px;
|
||||||
padding: 5px;
|
padding: 5px;
|
||||||
border-radius: 0 0 5px 5px;
|
border-radius: 0 0 5px 5px;
|
||||||
|
|
||||||
> .new-message {
|
> .new-message {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
border: 0;
|
border: 0;
|
||||||
|
|
@ -121,4 +133,3 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue