2016-12-18 22:40:41 -05:00
|
|
|
import React, { PropTypes, Component } from 'react'
|
2016-12-19 00:08:48 -05:00
|
|
|
import Unread from './Unread'
|
|
|
|
import Participant from './Participant'
|
|
|
|
import Message from './Message'
|
2016-12-18 22:40:41 -05:00
|
|
|
|
|
|
|
class MapChat extends Component {
|
2016-12-19 00:41:31 -05:00
|
|
|
constructor(props) {
|
|
|
|
super(props)
|
|
|
|
|
|
|
|
this.state = {
|
|
|
|
messageText: ''
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
handleChange = key => e => {
|
|
|
|
this.setState({
|
|
|
|
[key]: e.target.value
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
handleTextareaKeyUp = e => {
|
|
|
|
if (e.which === 13) {
|
|
|
|
e.preventDefault()
|
|
|
|
const text = this.state.messageText
|
|
|
|
this.props.handleInputMessage(text)
|
|
|
|
this.setState({ messageText: '' })
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-12-19 00:08:48 -05:00
|
|
|
render = () => {
|
|
|
|
const rightOffset = this.props.isOpen ? '-300px' : '0'
|
2016-12-19 00:41:31 -05:00
|
|
|
const { videosShowing, cursorsShowing, alertSound } = this.props
|
2016-12-18 22:40:41 -05:00
|
|
|
return (
|
|
|
|
<div className="chat-box"
|
|
|
|
style={{ right: rightOffset }}
|
|
|
|
>
|
|
|
|
<div className="junto-header">
|
|
|
|
PARTICIPANTS
|
2016-12-19 00:41:31 -05:00
|
|
|
<div className={`video-toggle ${videosShowing ? 'active' : ''}`} />
|
|
|
|
<div className={`cursor-toggle ${cursorsShowing ? 'active' : ''}`} />
|
2016-12-18 22:40:41 -05:00
|
|
|
</div>
|
|
|
|
<div className="participants">
|
2016-12-19 00:08:48 -05:00
|
|
|
<div className="conversation-live">
|
|
|
|
LIVE
|
2016-12-18 22:40:41 -05:00
|
|
|
<span className="call-action leave" onClick={this.props.leaveCall}>
|
|
|
|
LEAVE
|
|
|
|
</span>
|
|
|
|
<span className="call-action join" onClick={this.props.joinCall}>
|
|
|
|
JOIN
|
|
|
|
</span>
|
2016-12-19 00:08:48 -05:00
|
|
|
</div>
|
2016-12-19 00:41:31 -05:00
|
|
|
{this.props.participants.map(participant => {
|
|
|
|
return <Participant key={participant.id} {...participant} />
|
|
|
|
})}
|
2016-12-18 22:40:41 -05:00
|
|
|
</div>
|
|
|
|
<div className="chat-header">
|
|
|
|
CHAT
|
2016-12-19 00:41:31 -05:00
|
|
|
<div className={`sound-toggle ${alertSound ? 'active' : ''}`}></div>
|
2016-12-18 22:40:41 -05:00
|
|
|
</div>
|
|
|
|
<div className="chat-button">
|
|
|
|
<div className="tooltips">Chat</div>
|
2016-12-18 23:24:57 -05:00
|
|
|
<Unread count={this.props.unreadMessages} />
|
2016-12-18 22:40:41 -05:00
|
|
|
</div>
|
2016-12-19 00:41:31 -05:00
|
|
|
<div className="chat-messages">
|
|
|
|
{this.props.messages.map(message => {
|
|
|
|
return <Message key={message.id} {...message} />
|
|
|
|
})}
|
|
|
|
</div>
|
|
|
|
<textarea className="chat-input"
|
|
|
|
placeholder="Send a message..."
|
|
|
|
value={this.state.messageText}
|
|
|
|
onChange={this.handleChange('messageText')}
|
|
|
|
onKeyUp={this.handleTextareaKeyUp}
|
|
|
|
onFocus={this.props.inputFocus}
|
|
|
|
onBlur={this.props.inputBlur}
|
|
|
|
/>
|
2016-12-18 22:40:41 -05:00
|
|
|
</div>
|
|
|
|
)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
MapChat.propTypes = {
|
2016-12-19 00:08:48 -05:00
|
|
|
isOpen: PropTypes.bool,
|
2016-12-18 22:40:41 -05:00
|
|
|
leaveCall: PropTypes.func,
|
|
|
|
joinCall: PropTypes.func,
|
|
|
|
participants: PropTypes.arrayOf(PropTypes.shape({
|
2016-12-18 23:24:57 -05:00
|
|
|
color: PropTypes.string, // css color
|
2016-12-18 22:40:41 -05:00
|
|
|
id: PropTypes.number,
|
|
|
|
image: PropTypes.string, // image url
|
|
|
|
self: PropTypes.bool,
|
2016-12-18 23:24:57 -05:00
|
|
|
username: PropTypes.string
|
2016-12-18 22:40:41 -05:00
|
|
|
}))
|
|
|
|
}
|
|
|
|
|
|
|
|
export default MapChat
|