feat: add IRC colours, without a toggle for now
Some checks failed
ci/woodpecker/push/build-and-publish Pipeline failed
Some checks failed
ci/woodpecker/push/build-and-publish Pipeline failed
This commit is contained in:
parent
be5d65883b
commit
9b7de48c02
4 changed files with 18 additions and 1 deletions
|
@ -40,7 +40,7 @@
|
|||
</div>
|
||||
<div class="message-data">
|
||||
<div class="message-metadata">
|
||||
<span class="message-author-username" tabindex="0">
|
||||
<span class="message-author-username" tabindex="0" :style="`color: ${props.authorColor}`">
|
||||
{{ author?.display_name || author?.username }}
|
||||
</span>
|
||||
<span class="message-date" :title="date.toString()">
|
||||
|
@ -71,6 +71,7 @@
|
|||
import DOMPurify from 'dompurify';
|
||||
import { parse } from 'marked';
|
||||
import type { MessageProps } from '~/types/props';
|
||||
import generateIrcColor from '~/utils/generateIrcColor';
|
||||
|
||||
const props = defineProps<MessageProps>();
|
||||
|
||||
|
@ -117,6 +118,8 @@ onMounted(async () => {
|
|||
// showHover.value = !showHover.value;
|
||||
//}
|
||||
|
||||
console.log(props.authorColor)
|
||||
|
||||
const menuItems = [
|
||||
{ name: "Reply", callback: () => { if (messageElement.value) replyToMessage(messageElement.value, props) } }
|
||||
]
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
:margin-bottom="(messages[i + 1] && messagesType[messages[i + 1].uuid] == 'normal') ?? false"
|
||||
:last="i == messages.length - 1" :message-id="message.uuid" :author="message.user" :me="me"
|
||||
:message="message" :is-reply="message.reply_to"
|
||||
:author-color="`${generateIrcColor(message.user.uuid)}`"
|
||||
:reply-message="message.reply_to ? getReplyMessage(message.reply_to) : undefined" />
|
||||
</div>
|
||||
<div id="message-box" class="rounded-corners">
|
||||
|
|
|
@ -9,6 +9,7 @@ export interface MessageProps {
|
|||
format: "12" | "24",
|
||||
type: "normal" | "grouped",
|
||||
marginBottom: boolean,
|
||||
authorColor: string,
|
||||
last: boolean,
|
||||
messageId: string,
|
||||
replyingTo?: boolean,
|
||||
|
|
12
utils/generateIrcColor.ts
Normal file
12
utils/generateIrcColor.ts
Normal file
|
@ -0,0 +1,12 @@
|
|||
import xxhash from "xxhash-wasm"
|
||||
|
||||
const { h64 } = await xxhash()
|
||||
|
||||
export default (seed: string): string => {
|
||||
const lightness = 50
|
||||
|
||||
// this should probably be cached eventually
|
||||
const idHash = h64(seed)
|
||||
|
||||
return `hsl(${idHash % 360n}, 100%, ${lightness}%)`
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue