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

storybook: global language selector #6904

Merged
merged 4 commits into from
Jul 1, 2024

Conversation

VIKTORVAV99
Copy link
Member

Issue

Many of our components are directly using translations but we have no way to control the language in storybook right now.

Closes: AVO-347

Description

Adds a decorator and global controls to the main storybook preview file as instructed here: https://storybook.js.org/recipes/react-i18next

Note

There is an add-on that does this as well but we'll actually end up with more code if we go down that route? So I opted to just do the simple solution.

Double check

  • I have run pnpx prettier@2 --write . and poetry run format in the top level directory to format my changes.

@madsnedergaard
Copy link
Member

I like the simple approach!
Doesn't seem to work for me though 🤔
https://github.com/electricitymaps/electricitymaps-contrib/assets/3296643/7ea6974f-dec7-4e16-add2-5d0bc967dc6b

@VIKTORVAV99
Copy link
Member Author

I like the simple approach!

Doesn't seem to work for me though 🤔

Kapture.2024-07-01.at.12.32.46.mp4

Did you make sure it's not a component that has its own i18next wrapper?

I'm going to remove those in a follow up PR.

I think you can test it best on the FAQ panel.

@VIKTORVAV99
Copy link
Member Author

VIKTORVAV99 commented Jul 1, 2024

I like the simple approach! Doesn't seem to work for me though 🤔 https://github.com/electricitymaps/electricitymaps-contrib/assets/3296643/7ea6974f-dec7-4e16-add2-5d0bc967dc6b

Hehe, turns out these are hardcoded in storybook...

export const Default: Story = {
  argTypes: {
    ratio: {
      control: { type: 'number', min: 0, max: 1, step: 0.1 },
    },
  },
  args: {
    ratio: 0.5,
    name: 'Renewable', // <- This one...
  },
};

I'll add a task to clean them up later.

@madsnedergaard
Copy link
Member

Oh, that explains it! 😄

@VIKTORVAV99 VIKTORVAV99 merged commit 8dccf0f into master Jul 1, 2024
21 checks passed
@VIKTORVAV99 VIKTORVAV99 deleted the vik/storybook_global_language_selector branch July 1, 2024 13:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
frontend 🎨 javascript Pull requests that update Javascript code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants