ui icon indicating copy to clipboard operation
ui copied to clipboard

[feat]: Request to accept avatar component to support StaticImageData as a type in its source

Open bloodgroup-cplusplus opened this issue 1 year ago • 2 comments

Feature description

Currently the Avatar component supports only string or undefined in its source parameter <Avatar src="url"> Can a feature be added so that it support static images or StaticImageData as a type

Affected component/components

Avatar

Additional Context

Additional details here...

Before submitting

  • [X] I've made research efforts and searched the documentation
  • [X] I've searched for existing issues and PRs

bloodgroup-cplusplus avatar Sep 26 '24 08:09 bloodgroup-cplusplus

the only thing i used cn for and now it doesn't accept StaticImageData, oh well

Pastoray avatar Sep 30 '24 18:09 Pastoray

You can modify AvatarImage in avatar.tsx in your project to support StaticImageData.

For example something like that works:

const AvatarImage = React.forwardRef<
  React.ElementRef<typeof AvatarPrimitive.Image>,
  Omit<React.ComponentPropsWithoutRef<typeof AvatarPrimitive.Image>, "src"> & {
    src: string | StaticImageData;
  }
>(({ className, src, ...props }, ref) => (
  <AvatarPrimitive.Image
    ref={ref}
    className={cn("aspect-square h-full w-full", className)}
    src={typeof src === "string" ? src : src.src}
    {...props}
  />
));

IgorM867 avatar Oct 03 '24 13:10 IgorM867

This issue has been automatically marked as stale due to two years of inactivity. It will be closed in 7 days unless there’s further input. If you believe this issue is still relevant, please leave a comment or provide updated details. Thank you.

shadcn avatar Mar 02 '25 11:03 shadcn

No stale. Something went wrong with the stale bot.

shadcn avatar Mar 02 '25 11:03 shadcn