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

docs: add storybook #5162

Merged
merged 3 commits into from
Sep 20, 2023
Merged

Conversation

petermakowski
Copy link
Contributor

@petermakowski petermakowski commented Sep 18, 2023

Done

  • add storybook with example stories for AppSideNavigation, Meter, TooltipButon, MachineActionFormWrapper
  • include @storybook/addon-a11y for easy accessibility testing
  • refactor AppSideNavigation
  • extend HACKING.md docs
  • export context providers from AppRoot as RootProviders (so that they can be used in storybook)

Rationale

This PR adds storybook to maas-ui to encourage component-driven development and good component design.

It allows to quickly preview various states of components acting as an interactive documentation and speeding up the development.

It's not using extensive customisation options or specifying separate variants for each type of component to keep things simple and minimize the maintenance burden.

For example, MachineActionFormWrapper is not added as separate Stories for each action (deploy, abort, etc.). This would have the benefit of them being displayed in the navigation on the left, but would require specifying each story manually. We can achieve the same thing by simply switching the "action" prop using storybook controls. These are added automatically and don't require any extra code.

What's not included

  • Mocking of the API.
  • Customisation of redux store/dispatching actions (will be added in the future). For that reason some of the machine actions may render unexpected results like an infinitely loading spinner.

QA

QA steps

  • run yarn storybook
  • verify you can view components and control their props via storybook controls

Screenshots

After

Google Chrome screenshot 000820@2x
Google Chrome screenshot 000834@2x

Google Chrome screenshot 000828@2x

@webteam-app
Copy link

Demo starting at https://maas-ui-5162.demos.haus

@petermakowski petermakowski force-pushed the add-storybook branch 2 times, most recently from 065656a to b4e2680 Compare September 18, 2023 15:27
@petermakowski petermakowski force-pushed the add-storybook branch 3 times, most recently from eec091e to 52463ac Compare September 19, 2023 12:48
@petermakowski petermakowski marked this pull request as ready for review September 19, 2023 12:58
@petermakowski petermakowski changed the title feat: add storybook WIP feat: add storybook Sep 19, 2023
@petermakowski petermakowski changed the title feat: add storybook docs: add storybook Sep 19, 2023
@petermakowski petermakowski force-pushed the add-storybook branch 3 times, most recently from 52463ac to 2450159 Compare September 19, 2023 13:29
Copy link
Contributor

@ndv99 ndv99 left a comment

Choose a reason for hiding this comment

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

I really like this. I think the re-structure of the app side navigation is a really solid example for extracting component state from presentation, and a good basis for future improvements. LGTM!

@petermakowski
Copy link
Contributor Author

I really like this. I think the re-structure of the app side navigation is a really solid example for extracting component state from presentation, and a good basis for future improvements. LGTM!

Thanks. Keep in mind that it's just the beginning. The shared MAAS UI Component Library is where the real work will happen in terms of refactoring and aligning with component design best practices.

@petermakowski petermakowski merged commit 7227828 into canonical:main Sep 20, 2023
4 checks passed
@petermakowski petermakowski deleted the add-storybook branch May 9, 2024 10:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants