1 import { clx } from "@medusajs/ui"
2 import { PropsWithChildren } from "react"
3
4 type IconAvatarProps = PropsWithChildren<{
5 className?: string
6 size?: "small" | "large" | "xlarge"
7 variant?: "squared" | "rounded"
8 }>
9
10 /**
11 * Use this component when a design calls for an avatar with an icon.
12 *
13 * The `<Avatar/>` component from `@medusajs/ui` does not support passing an icon as a child.
14 */
15 export const IconAvatar = ({
16 size = "small",
17 variant = "rounded",
18 children,
19 className,
20 }: IconAvatarProps) => {
21 return (
22 <div
23 className={clx(
24 "shadow-borders-base flex size-7 items-center justify-center",
25 variant === "squared" && "rounded-md",
26 variant === "rounded" && "rounded-full",
27 "[&>div]:bg-ui-bg-field [&>div]:text-ui-fg-subtle [&>div]:flex [&>div]:size-6 [&>div]:items-center [&>div]:justify-center",
28 {
29 "size-7 rounded-md [&>div]:size-6 [&>div]:rounded-[4px]":
30 size === "small",
31 "size-10 rounded-lg [&>div]:size-9 [&>div]:rounded-[6px]":
32 size === "large",
33 "size-12 rounded-xl [&>div]:size-11 [&>div]:rounded-[10px]":
34 size === "xlarge",
35 },
36 className
37 )}
38 >
39 <div>{children}</div>
40 </div>
41 )
42 }