2022-11-21 05:06:53 +00:00
|
|
|
import { Show } from 'solid-js'
|
|
|
|
import MarkdownIt from 'markdown-it'
|
2022-11-16 12:25:37 +00:00
|
|
|
import { clsx } from 'clsx'
|
|
|
|
import styles from './Message.module.scss'
|
2022-11-21 05:06:53 +00:00
|
|
|
import DialogAvatar from './DialogAvatar'
|
2022-11-16 12:25:37 +00:00
|
|
|
|
|
|
|
type Props = {
|
|
|
|
body: string
|
|
|
|
isOwn: boolean
|
|
|
|
}
|
|
|
|
|
2022-11-21 05:06:53 +00:00
|
|
|
const md = new MarkdownIt({
|
|
|
|
linkify: true
|
|
|
|
})
|
|
|
|
|
2022-11-16 12:25:37 +00:00
|
|
|
const Message = (props: Props) => {
|
|
|
|
return (
|
|
|
|
<div class={clsx(styles.Message, props.isOwn && styles.own)}>
|
2022-11-21 05:06:53 +00:00
|
|
|
<Show when={!props.isOwn}>
|
|
|
|
<div class={styles.author}>
|
|
|
|
<DialogAvatar size="small" name={'Message Author'} />
|
|
|
|
<div class={styles.name}>Message Author</div>
|
|
|
|
</div>
|
|
|
|
</Show>
|
|
|
|
<div class={styles.body}>
|
|
|
|
<div innerHTML={md.render(props.body)} />
|
|
|
|
</div>
|
|
|
|
<div class={styles.time}>12:24</div>
|
2022-11-16 12:25:37 +00:00
|
|
|
</div>
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
export default Message
|