Compare commits

...

2 commits

Author SHA1 Message Date
9b7de48c02
feat: add IRC colours, without a toggle for now
Some checks failed
ci/woodpecker/push/build-and-publish Pipeline failed
2025-07-13 18:16:02 +02:00
be5d65883b
feat: add xxhash-wasm library 2025-07-13 18:15:48 +02:00
6 changed files with 28 additions and 2 deletions

View file

@ -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) } }
]

View file

@ -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">

View file

@ -22,7 +22,8 @@
"pinia-plugin-persistedstate": "^4.2.0",
"typescript": "^5.8.3",
"vue": "^3.5.13",
"vue-router": "^4.5.1"
"vue-router": "^4.5.1",
"xxhash-wasm": "^1.1.0"
},
"packageManager": "pnpm@10.11.0",
"license": "MIT",

8
pnpm-lock.yaml generated
View file

@ -47,6 +47,9 @@ importers:
vue-router:
specifier: ^4.5.1
version: 4.5.1(vue@3.5.13(typescript@5.8.3))
xxhash-wasm:
specifier: ^1.1.0
version: 1.1.0
devDependencies:
'@iconify-json/lucide':
specifier: ^1.2.44
@ -4744,6 +4747,9 @@ packages:
engines: {node: '>= 0.10.0'}
hasBin: true
xxhash-wasm@1.1.0:
resolution: {integrity: sha512-147y/6YNh+tlp6nd/2pWq38i9h6mz/EuQ6njIrmW8D1BS5nCqs0P6DG+m6zTGnNz5I+uhZ0SHxBs9BsPrwcKDA==}
y18n@5.0.8:
resolution: {integrity: sha512-0pfFzegeDWJHJIAmTLRP2DwHjdF5s7jo9tuztdQxAhINCdvS+3nGINqPd00AphqJR/0LhANUS6/+7SCb98YOfA==}
engines: {node: '>=10'}
@ -10146,6 +10152,8 @@ snapshots:
cssfilter: 0.0.10
optional: true
xxhash-wasm@1.1.0: {}
y18n@5.0.8: {}
yallist@3.1.1: {}

View file

@ -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
View 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}%)`
}