feat: configure user color with CSS
This commit is contained in:
parent
d4174ac449
commit
bb4763e509
1 changed files with 3 additions and 1 deletions
|
@ -19,7 +19,9 @@ export function hashCode(str) {
|
|||
|
||||
export function cssColorMXID(userId) {
|
||||
const colorNumber = hashCode(userId) % 8;
|
||||
return `--mx-uc-${colorNumber + 1}`;
|
||||
// @user:a.b.c => -user-a_b_c
|
||||
const escapedUserId = userId.replace(/[@:]/g, '-').replace(/[^\w-]/g, '_');
|
||||
return `--mx-uc-${escapedUserId}, var(--mx-uc-${colorNumber + 1})`;
|
||||
}
|
||||
|
||||
export default function colorMXID(userId) {
|
||||
|
|
Loading…
Reference in a new issue