Skip to content

Show generated avatar based on username initials 🎨 #380

Description

@anoopcodehack

Show generated avatar based on username initials 🎨

File: client/src/pages/Dashboard.jsx

Navbar shows plain initials in a circle 💀
Make it generate a proper colorful avatar fr!!

Fix: generate consistent color from name:
const getAvatarColor = (name) => {
const colors = [
'#7F77DD', '#E85D75', '#27AE60',
'#F39C12', '#2980B9', '#8E44AD'
]
const index = name?.charCodeAt(0) % colors.length
return colors[index || 0]
}

{user?.name?.[0]?.toUpperCase()}

~8 lines! No backend needed 🎯
Looks way more polished!! ✨

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions