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

feat: locale picker in the storybook's decorator #4687

Merged
merged 5 commits into from
Sep 5, 2024

Conversation

mizgaionutalexandru
Copy link
Contributor

@mizgaionutalexandru mizgaionutalexandru commented Aug 23, 2024

Description

This PR adds a new control in the storybook decorator that helps the user change the language/locale.
In order to leverage the interaction of sp-theme and LanguageResolutionController in the storybook it is needed to use a workaround similar to requestAnimationFrame so that the story functions get called after the Theme's constructor.

For more context please check out this PR comment.

Motivation and context

Currently if a component is reactive to locale/language changes, in order for the storybook to reflect that it is needed for multiple stories to be created. This doesn't scale as well and it's also cumbersome for users of the SWC storybook to clearly identify the differences between locales.
Currently the most notable behavior change is in the sp-number-field component.

How has this been tested?

  • Test case 1

    1. Go to sp-number-field storybook
    2. Type in a number that has group separators and decimals
    3. Observe how it is shown with the en-US locale (e.g. 1,000.56)
    4. Change the locale to fr-FR
    5. Observe the new formatted value (e.g. 1 000,56)
  • Test case 1

    1. Go to sp-number-field storybook
    2. Type in a number that has group separators and decimals
    3. Observe how it is shown with the en-US locale (e.g. 1,000.56)
    4. Change the locale to de-DE
    5. Observe the new formatted value (e.g. 1.000,56)
  • Did it pass in Desktop?

  • Did it pass in Mobile?

  • Did it pass in iPad?

Screenshots (if appropriate)

Screenshot 2024-08-23 at 18 03 26

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Chore (minor updates related to the tooling or maintenance of the repository, does not impact compiled assets)

Checklist

  • I have signed the Adobe Open Source CLA.
  • My code follows the code style of this project.
  • If my change required a change to the documentation, I have updated the documentation in this pull request.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my changes.
  • All new and existing tests passed.
  • I have reviewed at the Accessibility Practices for this feature, see: Aria Practices

Best practices

This repository uses conventional commit syntax for each commit message; note that the GitHub UI does not use this by default so be cautious when accepting suggested changes. Avoid the "Update branch" button on the pull request and opt instead for rebasing your branch against main.

Copy link

Branch preview

Copy link

github-actions bot commented Aug 23, 2024

Lighthouse scores

Category Latest (report) Main (report) Branch (report)
Performance 0.99 0.99 0.99
Accessibility 1 1 1
Best Practices 1 1 1
SEO 1 0.92 0.92
PWA 1 1 1
What is this?

Lighthouse scores comparing the documentation site built from the PR ("Branch") to that of the production documentation site ("Latest") and the build currently on main ("Main"). Higher scores are better, but note that the SEO scores on Netlify URLs are artifically constrained to 0.92.

Transfer Size

Category Latest Main Branch
Total 227.799 kB 214.467 kB 214.428 kB 🏆
Scripts 56.789 kB 49.724 kB 49.721 kB 🏆
Stylesheet 34.637 kB 30.315 kB 30.282 kB 🏆
Document 6.206 kB 5.432 kB 🏆 5.444 kB
Font 127.168 kB 126.649 kB 126.631 kB 🏆

Request Count

Category Latest Main Branch
Total 52 52 52
Scripts 41 41 41
Stylesheet 5 5 5
Document 1 1 1
Font 2 2 2

Copy link

Tachometer results

Currently, no packages are changed by this PR...

@mizgaionutalexandru
Copy link
Contributor Author

mizgaionutalexandru commented Aug 23, 2024

It looks like on iPad and mobile the user has a hard time using these controls from the Storybook decorator. Should we place some of them in a Action Menu?

After checking it out, it seems like the submenu feature of the ActionMenu doesn't work on mobile. I've been checking it out here: https://opensource.adobe.com/spectrum-web-components/storybook/index.html?path=/story/action-menu--submenu

@mizgaionutalexandru mizgaionutalexandru marked this pull request as ready for review August 23, 2024 15:19
@mizgaionutalexandru mizgaionutalexandru requested a review from a team as a code owner August 23, 2024 15:19
@mizgaionutalexandru mizgaionutalexandru changed the title Added locale picker in the storybook's decorator Locale picker in the storybook's decorator Aug 23, 2024
@mizgaionutalexandru mizgaionutalexandru changed the title Locale picker in the storybook's decorator feat: locale picker in the storybook's decorator Aug 23, 2024
@rubencarvalho
Copy link
Collaborator

There seems to be an inconsistent behavior: when you toggle "Reduce motion," the picker displays "Locale" instead of the selected value. Could you please check what's causing this? :)

Screen.Recording.2024-08-27.at.12.08.39.mov

@mizgaionutalexandru
Copy link
Contributor Author

There seems to be an inconsistent behavior: when you toggle "Reduce motion," the picker displays "Locale" instead of the selected value. Could you please check what's causing this? :)

Thank you for looking into this. Missed a small break in the switch case. It should be fixed now. 🚀

Copy link
Collaborator

@rubencarvalho rubencarvalho left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great work! 👍 Let's 🚢 it.

@coveralls
Copy link
Collaborator

coveralls commented Aug 28, 2024

Pull Request Test Coverage Report for Build 10697715122

Details

  • 0 of 0 changed or added relevant lines in 0 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage remained the same at 98.2%

Totals Coverage Status
Change from base Build 10696283257: 0.0%
Covered Lines: 32510
Relevant Lines: 32941

💛 - Coveralls

@rubencarvalho rubencarvalho merged commit 9e0cd08 into main Sep 5, 2024
59 of 61 checks passed
@rubencarvalho rubencarvalho deleted the imizga/locale-story-decorator branch September 5, 2024 09:15
nikkimk pushed a commit that referenced this pull request Sep 13, 2024
---------

Co-authored-by: Rúben Carvalho <rubcar@sapo.pt>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants