From 6ec259a0e71174651bae95d4628138bf6fd68742 Mon Sep 17 00:00:00 2001
From: kj_sh604
Date: Sun, 15 Mar 2026 16:19:35 -0400
Subject: refactor: packages/

---
 packages/excalidraw/components/Avatar.tsx | 41 +++++++++++++++++++++++++++++++
 1 file changed, 41 insertions(+)
 create mode 100644 packages/excalidraw/components/Avatar.tsx

(limited to 'packages/excalidraw/components/Avatar.tsx')

diff --git a/packages/excalidraw/components/Avatar.tsx b/packages/excalidraw/components/Avatar.tsx
new file mode 100644
index 0000000..9ddc319
--- /dev/null
+++ b/packages/excalidraw/components/Avatar.tsx
@@ -0,0 +1,41 @@
+import "./Avatar.scss";
+
+import React, { useState } from "react";
+import { getNameInitial } from "../clients";
+import clsx from "clsx";
+
+type AvatarProps = {
+  onClick: (e: React.MouseEvent<HTMLDivElement, MouseEvent>) => void;
+  color: string;
+  name: string;
+  src?: string;
+  className?: string;
+};
+
+export const Avatar = ({
+  color,
+  onClick,
+  name,
+  src,
+  className,
+}: AvatarProps) => {
+  const shortName = getNameInitial(name);
+  const [error, setError] = useState(false);
+  const loadImg = !error && src;
+  const style = loadImg ? undefined : { background: color };
+  return (
+    <div className={clsx("Avatar", className)} style={style} onClick={onClick}>
+      {loadImg ? (
+        <img
+          className="Avatar-img"
+          src={src}
+          alt={shortName}
+          referrerPolicy="no-referrer"
+          onError={() => setError(true)}
+        />
+      ) : (
+        shortName
+      )}
+    </div>
+  );
+};
-- 
cgit v1.2.3

