Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avatar should render dummy svg when provided with render function #1381

Open
2 tasks done
mkbctrl opened this issue Apr 28, 2024 · 0 comments
Open
2 tasks done

Avatar should render dummy svg when provided with render function #1381

mkbctrl opened this issue Apr 28, 2024 · 0 comments

Comments

@mkbctrl
Copy link

mkbctrl commented Apr 28, 2024

  • I have searched the Issues to see if this bug has already been reported
  • I have tested the latest version

Summary

When overwriting the component with custom image component, the dummy svg should still render if we are facing a scenario where the image url may be undefined. Right now I have to workaround it like this:

<Avatar
        img={(avatarProps) => {
          if (imagePreviewUrl) {
            return (
              <Image
                alt={t('alt')}
                referrerPolicy='no-referrer'
                src={imagePreviewUrl}
                width={144}
                height={144}
                {...avatarProps}
              />
            )
          }

          // Flowbite avatar is unable to render dummy when props are passed
          return <Avatar {...avatarProps} size='xl' bordered={false} />
        }}
        size='xl'
        alt={t('alt')}
        className='flex-shrink-0'
        rounded
      />

Context

I want the ability to render custom component, and to maintain the ability to render the dummy, if component is null

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant