docbrown/app/javascript/chat/message.jsx
Mac Siri 0f35939906 Update chat app's features (#204)
* Update chat.scss --skip-ci

* Fix height issue

* Add highlighting

* Implement bannged user handling for chat

* Add scroll obsever

* Limit initial messages load count & max messages

* Add new message alert when scrolled

* Add link to usernames in chat

* Implement channel clearing feature

* Update parserOptions

* Implement banning feature for chat app WIP

* Add policy for ChatChannelsController

* Fix arugment error

* Update user_not_authorized to handle JSON request

* Update specs for updated user_not_authorized

* Update font-weight for windows os
2018-04-16 13:20:12 -07:00

41 lines
985 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, hidden,
}) => {
const spanStyle = { color };
const linkStyle = { color: 'inherit' };
const messageStyle = { color: hidden ? 'lightgray' : 'inherit' };
return (
<div className="chatmessage">
<span className="chatmessage__username" style={spanStyle}>
<a style={linkStyle} href={`/${user}`}>
{user}
</a>
</span>
<span className="chatmessage__divider">: </span>
<span className="chatmessage__message" style={messageStyle}>
{hidden ? '<message removed>' : message}
</span>
</div>
);
};
Message.propTypes = {
user: PropTypes.string.isRequired,
color: PropTypes.string.isRequired,
message: PropTypes.string.isRequired,
hidden: PropTypes.bool,
};
Message.defaultProps = {
hidden: false,
};
export default Message;