mirror of
https://github.com/luxfhe/example-smart-wallet.git
synced 2026-10-30 18:13:16 +00:00
33 lines
695 B
TypeScript
33 lines
695 B
TypeScript
"use client";
|
|
|
|
import Avatar from "boring-avatars";
|
|
import { useMemo } from "react";
|
|
|
|
type UserAvatarProps = {
|
|
address: string;
|
|
primaryColor?: string;
|
|
};
|
|
|
|
const SUB_COLORS = ["#37BCFA", "#6D37FA"];
|
|
|
|
const UserAvatar = ({ address, primaryColor = "#37BCFA" }: UserAvatarProps) => {
|
|
const avatarColors = useMemo(() => {
|
|
return shuffleColors([primaryColor, ...SUB_COLORS]);
|
|
}, [primaryColor]);
|
|
|
|
return (
|
|
<Avatar
|
|
size={32}
|
|
name={address}
|
|
variant="marble"
|
|
colors={avatarColors.length > 0 ? avatarColors : [primaryColor]}
|
|
/>
|
|
);
|
|
};
|
|
|
|
const shuffleColors = (colors: string[]) => {
|
|
return colors.sort(() => Math.random() - 0.5);
|
|
};
|
|
|
|
export { UserAvatar };
|