colorize user names under messages
This commit is contained in:
@@ -39,7 +39,7 @@ export function bytesToHumanSize(bytes) {
|
||||
|
||||
// Get 32 bit integer hash value for a string. Ideally it should produce the same value
|
||||
// as Java's String#hash().
|
||||
export function stringHash(value) {
|
||||
function stringToColorHash(value) {
|
||||
let hash = 0;
|
||||
value = '' + value;
|
||||
for (let i = 0; i < value.length; i++) {
|
||||
@@ -48,3 +48,8 @@ export function stringHash(value) {
|
||||
}
|
||||
return hash;
|
||||
}
|
||||
|
||||
// Converts user or topic ID to a CSS color class. Ideally it should produce the same color value as Java version.
|
||||
export function idToColorClass(string, light) {
|
||||
return (light ? 'light-color' : 'dark-color') + (Math.abs(stringToColorHash(string)) % 16);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user