docbrown/app/javascript/chat/message.jsx
Mac Siri 8003191a4e Create Chat app (#175)
* Setup Pusher gem

* Create ChatChannel and Message model

* Create ChatChannelController

* Add back fix-db-schema-conflicts gem

* Add pusher-js package

* Add validations on Message & ChatChannel models

* Update Route

* Create MessageController

* Update ChatChannelController

* Create Chat app WIP

* Extract messenger render to Message Component

* Implement live chat WIP

* Implement live chat WIP (2)

* Add style and scrollToBottom feature for chat

* Create getUserDataAndCsrfToken function

* Add feature toggle to the new live chat

* Clean up ChatChannelsController & create spec

* Update ChatChannel spec

* Update Message spec

* Create MessagesController spec & refactor

* Clean up Chat app

* Fix lint

* Add character limit to Message
2018-04-04 14:19:57 -07:00

27 lines
652 B
JavaScript

import { h } from 'preact';
import PropTypes from 'prop-types';
/*
* The prop also contain timeStamp, which is currently not in used
*/
const Message = ({
user, message, color,
}) => {
const spanStyle = { color };
return (
<div className="chatmessage">
<span className="chatmessage__username" style={spanStyle}>{ user }</span>
<span className="chatmessage__divider">: </span>
<span className="chatmessage__message">{ message } </span>
</div>
);
};
Message.propTypes = {
user: PropTypes.string.isRequired,
color: PropTypes.string.isRequired,
message: PropTypes.string.isRequired,
};
export default Message;