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>
|
||||||
<div class="message-data">
|
<div class="message-data">
|
||||||
<div class="message-metadata">
|
<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 }}
|
{{ author?.display_name || author?.username }}
|
||||||
</span>
|
</span>
|
||||||
<span class="message-date" :title="date.toString()">
|
<span class="message-date" :title="date.toString()">
|
||||||
|
@ -71,6 +71,7 @@
|
||||||
import DOMPurify from 'dompurify';
|
import DOMPurify from 'dompurify';
|
||||||
import { parse } from 'marked';
|
import { parse } from 'marked';
|
||||||
import type { MessageProps } from '~/types/props';
|
import type { MessageProps } from '~/types/props';
|
||||||
|
import generateIrcColor from '~/utils/generateIrcColor';
|
||||||
|
|
||||||
const props = defineProps<MessageProps>();
|
const props = defineProps<MessageProps>();
|
||||||
|
|
||||||
|
@ -117,6 +118,8 @@ onMounted(async () => {
|
||||||
// showHover.value = !showHover.value;
|
// showHover.value = !showHover.value;
|
||||||
//}
|
//}
|
||||||
|
|
||||||
|
console.log(props.authorColor)
|
||||||
|
|
||||||
const menuItems = [
|
const menuItems = [
|
||||||
{ name: "Reply", callback: () => { if (messageElement.value) replyToMessage(messageElement.value, props) } }
|
{ 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"
|
: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"
|
:last="i == messages.length - 1" :message-id="message.uuid" :author="message.user" :me="me"
|
||||||
:message="message" :is-reply="message.reply_to"
|
:message="message" :is-reply="message.reply_to"
|
||||||
|
:author-color="`${generateIrcColor(message.user.uuid)}`"
|
||||||
:reply-message="message.reply_to ? getReplyMessage(message.reply_to) : undefined" />
|
:reply-message="message.reply_to ? getReplyMessage(message.reply_to) : undefined" />
|
||||||
</div>
|
</div>
|
||||||
<div id="message-box" class="rounded-corners">
|
<div id="message-box" class="rounded-corners">
|
||||||
|
|
|
@ -9,6 +9,7 @@ export interface MessageProps {
|
||||||
format: "12" | "24",
|
format: "12" | "24",
|
||||||
type: "normal" | "grouped",
|
type: "normal" | "grouped",
|
||||||
marginBottom: boolean,
|
marginBottom: boolean,
|
||||||
|
authorColor: string,
|
||||||
last: boolean,
|
last: boolean,
|
||||||
messageId: string,
|
messageId: string,
|
||||||
replyingTo?: boolean,
|
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