Skip to content

Commit

Permalink
🐛 fix(avatar): Stop using getInitials in hashCode to allow different …
Browse files Browse the repository at this point in the history
…colors for same initials with different names 🎨

By removing `getInitials` from `hashCode`, the function now uses the full name to generate a hash. This ensures that even if two names produce the same initials, their colors will differ if their full names are different.
  • Loading branch information
YukiKoNeko authored Dec 31, 2024
1 parent 41b8186 commit bb687e0
Showing 1 changed file with 1 addition and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ const defaultColors: MantineColor[] = [
];

export function getInitialsColor(name: string, colors: MantineColor[] = defaultColors) {
const hash = hashCode(getInitials(name));
const hash = hashCode(name);
const index = Math.abs(hash) % colors.length;
return colors[index];
}

0 comments on commit bb687e0

Please sign in to comment.