website refactor
This commit is contained in:
27
apps/website/ui/Avatar.tsx
Normal file
27
apps/website/ui/Avatar.tsx
Normal file
@@ -0,0 +1,27 @@
|
||||
/**
|
||||
* Avatar
|
||||
*
|
||||
* Pure UI component for displaying driver avatars.
|
||||
* Renders an image with fallback on error.
|
||||
*/
|
||||
|
||||
export interface AvatarProps {
|
||||
driverId: string;
|
||||
alt: string;
|
||||
className?: string;
|
||||
}
|
||||
|
||||
export function Avatar({ driverId, alt, className = '' }: AvatarProps) {
|
||||
return (
|
||||
// eslint-disable-next-line @next/next/no-img-element
|
||||
<img
|
||||
src={`/media/avatar/${driverId}`}
|
||||
alt={alt}
|
||||
className={`w-10 h-10 rounded-full object-cover ${className}`}
|
||||
onError={(e) => {
|
||||
// Fallback to default avatar
|
||||
(e.target as HTMLImageElement).src = '/default-avatar.png';
|
||||
}}
|
||||
/>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user