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

Implement OnyxAvatar with locale sensitive Initials #2454

Open
21 tasks
JoCa96 opened this issue Jan 8, 2025 · 0 comments
Open
21 tasks

Implement OnyxAvatar with locale sensitive Initials #2454

JoCa96 opened this issue Jan 8, 2025 · 0 comments
Labels
0-refinement All issues that can or need to be estimated in our next refinement dev Requires technical expertise

Comments

@JoCa96
Copy link
Collaborator

JoCa96 commented Jan 8, 2025

Why?

The OnyxAvatar should also work with names that use characters that rely on multiple code-points.

Acceptance criteria

General:

  • props.label is deprecated
  • props.username is added and supersedes the props.label
    • It has a new type DisplayName which supports passing a locale, as shown in the implementation details

Algorithm:

  • If an image props.src was provided, it is shown
  • If not provided, while loading and on error, the user's initials are shown. These are determined as follows:
    • If the props.username includes unsupported characters (see fluent-ui) don't show initials, use Fallback.
    • The locale is determined: Either taken from the DisplayName type, otherwise from the injected i18n
    • Using this locale, the first glyph of the first and last word are determined using the Intl.Segmenter API
    • If no locale is defined for the name, the injected locale is used
    • If there is only a single word, the first two characters are used
  • Fallback: If no initials can be determined, the person icon is shown instead.

Aria:

  • The accessible name for the avatar component must be Avatar of ${props.username}

Implementation details

  • We can make use of Intl.Segmenter to determine words and single glyphs. It will consider writing direction, word, and glyph separator for the locale.
type DisplayName = string | {
  name: string;
  // the locale for the given name
  locale: string;
}

Fallback content for the image loading and on error can be shown without JS, using the <object> element:

  <template>
     <object class="onyx-avatar__content" :data="props.src" :aria-label="`Avatar of ${props.username}`">
      <div class="onyx-avatar__initials">
        <slot>{{ initials }}</slot>
      </div>
    </object>
  </template>

Reference implementations

Definition of Done

  • Should be covered by tests:

    • functional tests (Playwright or unit test)
    • visual tests (Playwright screenshots)
  • Make sure, that

    • follow-up tickets were created if necessary
    • updated version + documentation is deployed
    • Storybook can show the feature
    • Storybook code snippet of new/changed examples are checked that they are generated correctly
    • Namings are aligned with Figma

Approval

Storybook

  • Checked and approved by
    • designer
    • dev
@JoCa96 JoCa96 added the dev Requires technical expertise label Jan 8, 2025
@JoCa96 JoCa96 added this to onyx Jan 8, 2025
@github-project-automation github-project-automation bot moved this to New in onyx Jan 8, 2025
@JoCa96 JoCa96 moved this from New to Backlog in onyx Jan 9, 2025
@JoCa96 JoCa96 added the 0-refinement All issues that can or need to be estimated in our next refinement label Jan 9, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
0-refinement All issues that can or need to be estimated in our next refinement dev Requires technical expertise
Projects
Status: Backlog
Development

No branches or pull requests

1 participant