themesberg / themesberg/flowbite-react
Avatar should render dummy svg when provided with render function
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 2.1k
- Forks
- 506
- PR merge metrics
- No merged PRs in 30d
Description
- 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
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at the Avatar component, focusing on the custom img render-function path when the image URL is undefined. Verify the behavior against the existing Avatar test setup; done means a custom renderer can receive the props while the dummy SVG still renders when no image is provided.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- react, tailwindcss, typescript
- Domain
- frontend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100