MCPcopy Create free account
hub / github.com/codeaashu/claude-code / getAvatarColor

Function getAvatarColor

web/components/ui/avatar.tsx:39–56  ·  view source on GitHub ↗
(name: string)

Source from the content-addressed store, hash-verified

37
38// Deterministic colour from name
39function getAvatarColor(name: string): string {
40 const colours = [
41 'bg-brand-700 text-brand-200',
42 'bg-violet-800 text-violet-200',
43 'bg-indigo-800 text-indigo-200',
44 'bg-blue-800 text-blue-200',
45 'bg-cyan-800 text-cyan-200',
46 'bg-teal-800 text-teal-200',
47 'bg-emerald-800 text-emerald-200',
48 'bg-amber-800 text-amber-200',
49 'bg-rose-800 text-rose-200',
50 ]
51 let hash = 0
52 for (let i = 0; i < name.length; i++) {
53 hash = (hash * 31 + name.charCodeAt(i)) & 0xffffffff
54 }
55 return colours[Math.abs(hash) % colours.length]
56}
57
58function Avatar({ className, size, src, alt, name, ...props }: AvatarProps) {
59 const [imgError, setImgError] = React.useState(false)

Callers 1

AvatarFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected