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

Support colors in Avatar component #409

Closed
tiagossa1 opened this issue Oct 24, 2022 · 5 comments · Fixed by #439
Closed

Support colors in Avatar component #409

tiagossa1 opened this issue Oct 24, 2022 · 5 comments · Fixed by #439
Labels
good first issue Good for newcomers help wanted Extra attention is needed 🚀 enhancement New feature or request

Comments

@tiagossa1
Copy link
Contributor

Avatar component has color property, but it doesn't work. Any color that is passed doesn't change anything.
IMO, it should have the following colours:

  • dark
  • failure
  • gray/info/light
  • purple
  • success
  • warning
  • pink

Gray, info and light, if all added, should have different tones, to distinguish them.

I've tried to implemented and almost got it to work, so I think whoever picks this should:

  • Change default.ts and add color styling on 'avatar' key value (see snippets below)
  • Avatar.tsx must extends from Omit instead of PropsWithChildren and have 'color' argument passed. It should have another prop called color with a custom interface that explicit tells the colour options. Add theme.color[color] at least on the placeholder HTML element.
  • Add the custom interface from previous step into FlowbiteTheme.ts on avatar key.
@tiagossa1
Copy link
Contributor Author

Avatar.tsx

Line 8:
export interface AvatarProps extends Omit<ComponentProps<'div'>, 'color'>

Line 17, before closing the object:
color?: keyof AvatarColors;

Line 19, after closing the object and before AvatarSizes:

export interface AvatarColors
  extends Pick<FlowbiteColors, 'failure' | 'gray' | 'info' | 'pink' | 'purple' | 'success' | 'warning'> {
  [key: string]: string;
}

Line 35 or somewhere before ...props:
color = 'gray', - this sets the default colour of the avatar.

Line 62:
theme.color[color],

@tiagossa1
Copy link
Contributor Author

FlowbiteTheme.ts

Line 89, before closing the object on line 90:
color: AvatarColors; - imported from Avatar.tsx.

@tiagossa1
Copy link
Contributor Author

default.ts

Line 100, after closing the object on line 99:

    color: {
      dark: 'bg-gray-800 dark:bg-gray-800',
      failure: 'bg-red-500 dark:bg-red-700',
      gray: 'border-gray-500 dark:text-gray-400',
      info: 'bg-blue-400 dark:bg-blue-800',
      light: 'border-gray-500 dark:bg-gray-600',
      purple: 'bg-purple-500 dark:bg-purple-600',
      success: 'bg-green-500 dark:bg-green-500',
      warning: 'bg-yellow-300 dark:bg-yellow-500',
      pink: 'bg-pink-500 dark:bg-pink-500',
    },

I've personally chose these colours, but this can be changed.

@rluders rluders added 🚀 enhancement New feature or request help wanted Extra attention is needed good first issue Good for newcomers labels Nov 3, 2022
yurisldk added a commit to yurisldk/flowbite-react that referenced this issue Nov 25, 2022
Adds color property to Avatar component to change image ring color. Works only if border property is
true. Adds 'color' test case to the Avatar`s Theme test case

themesberg#409
@yurisldk
Copy link
Collaborator

@rluders @tiagossa1 just did PR. @tiagossa1 thank you for the detailed description and steps, it was a really helpful. I've used pallet that was suggested by @tiagossa1 Also I'm going to update docs for Avatar component as well soon.

yurisldk added a commit to yurisldk/flowbite-react that referenced this issue Nov 26, 2022
Adds 5 examples of rounded and bordered avatars and 5 examples of bordered avatars for Avatar
component

themesberg#409
rluders pushed a commit that referenced this issue Nov 27, 2022
* feat(avatar): adds color prop and test case for it

Adds color property to Avatar component to change image ring color. Works only if border property is
true. Adds 'color' test case to the Avatar`s Theme test case

#409

* docs(avatar): adds doc example for avatar color prop

Adds 5 examples of rounded and bordered avatars and 5 examples of bordered avatars for Avatar
component

#409
@tiagossa1
Copy link
Contributor Author

@sldk-yuri you're welcome! I was checking the original code and almost made it work, so I thought that this was the way to go! Great job!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers help wanted Extra attention is needed 🚀 enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants