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

Generate user colour from configured display driver #2690

Closed
ctml91 opened this issue Mar 13, 2021 · 1 comment · Fixed by #2873
Closed

Generate user colour from configured display driver #2690

ctml91 opened this issue Mar 13, 2021 · 1 comment · Fixed by #2873

Comments

@ctml91
Copy link
Contributor

ctml91 commented Mar 13, 2021

Feature Request

Is your feature request related to a problem? Please describe.
User avatar colours are generated using the username string. On forums that use single sign on and do not rely on user input for the display name (e.g. may use numerical username user1, user2, user3) the colours are almost all the same for every user.

Describe the solution you'd like
The function for generating the colour should instead use the nickname so that whichever display driver is set will be used to generate the colours.

I assume we could just substitute display name into the existing color function.

  color: computed('displayName', 'avatarUrl', 'avatarColor', function (displayName, avatarUrl, avatarColor) {
    // If we've already calculated and cached the dominant color of the user's
    // avatar, then we can return that in RGB format. If we haven't, we'll want
    // to calculate it. Unless the user doesn't have an avatar, in which case
    // we generate a color from their display name.
    if (avatarColor) {
      return 'rgb(' + avatarColor.join(', ') + ')';
    } else if (avatarUrl) {
      this.calculateAvatarColor();
      return '';
    }

    return '#' + stringToColor(displayName);
  }),

Justify why this feature belongs in Flarum's core, rather than in a third-party extension
The display driver is a core feature.

Describe alternatives you've considered
Workarounds are to get users to set an avatar so the colour gets generated from it but it cannot be forced.

@askvortsov1
Copy link
Member

That makes sense to me! PRs are welcome

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

Successfully merging a pull request may close this issue.

3 participants