import { html, Component } from "https://unpkg.com/htm/preact/index.mjs?module"; import { messageBubbleColorForString } from '../utils/user-colors.js'; import { formatMessageText } from '../utils/chat.js'; import { generateAvatar } from '../utils.js'; import SOCKET_MESSAGE_TYPES from '../utils/socket-message-types.js'; export default class Message extends Component { render(props) { const { message, username } = props; const { type } = message; if (type === SOCKET_MESSAGE_TYPES.CHAT) { const { image, author, body } = message; const formattedMessage = formatMessageText(body, username); const avatar = image || generateAvatar(author); const authorColor = messageBubbleColorForString(author); const avatarBgColor = { backgroundColor: authorColor }; const authorTextColor = { color: authorColor }; return ( html`
`); } else if (type === SOCKET_MESSAGE_TYPES.NAME_CHANGE) { const { oldName, newName, image } = message; return ( html` `); } } }