Skip to content
This repository has been archived by the owner on Mar 4, 2020. It is now read-only.

Avatar initials parsing should take long / special names into account #32

Closed
tomasiser opened this issue Jul 31, 2018 · 2 comments
Closed
Assignees

Comments

@tomasiser
Copy link
Contributor

Feature Request

Problem description

In some cases, a name of a user may be too long or it may contain special characters. Consider the following examples:

name Initials in <Avatar /> in 0.2.3 Proposed initials
William Wilson Worlov WWW
image
WW
Barack Obama (Ex-president, USA) BO(U
image
BO

Proposed solution

We should think whether this is a problem of the Avatar component or of the developer using the component. I propose the Avatar component should try to parse these complex names, maybe with configurable flags (e.g., useShortInitials). With this flag enabled, the component would remove everything in brackets ((...), [...], {...}) and then use the initials of the first and last words only, i.e., removing all words between them.

@mnajdova mnajdova self-assigned this Aug 1, 2018
@mnajdova
Copy link
Contributor

mnajdova commented Aug 1, 2018

Thanks for posting this issue. I would say that yes, by default we can ignore the content inside the brackets and we should provide always just the initial from the first and last words of the name. Instead of having the prop useShortInitials, I would make this default behavior, but I would add prop generateInitials(name: string) : stringso that the user can specify custom method about how the initials should be parsed using the name. Would this be sufficient enough?

@levithomason
Copy link
Member

Fixed and released in @stardust-ui/react@0.2.6.

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

No branches or pull requests

3 participants