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: Improve styling in the addons panel #437

Merged
merged 24 commits into from
Mar 1, 2023

Conversation

jonathanj
Copy link
Contributor

@jonathanj jonathanj commented Mar 1, 2023

Issue:

The addons panel (and addons in general) are missing polished UI styling, as well as being inconsistently styled with aspects like differing paddings/margins between various addons.

What I did

The largest change is restructuring the theme, the goal is to have enough semantic values to meaningfully style the UI well enough for the default Storybook theme, so that users have as much control over their own Storybook's appearance. Once this was done, it was a matter of replacing hardcoded values across the various pieces of UI in the app and addons.

The theme changes are documented in the "Migrating from 5.3x to 6.5.x" section under "Theming" in MIGRATION.md. I think it might be worth writing a separate piece of (non-migration) documentation around theming, what do you think?

Some motivation for the aesthetic changes:

  • Make it clearer what the current tab selection is and give the user a hint what is the pressable part of the tab UI
  • Increase the contrast between the panel and the various addon inputs/controls
  • Balance the whitespace between inputs better, so that the label and input relationship is more intuitive

A goal for the aesthetic changes was to try keep the styling relatively low-key to avoid drawing attention from the story content itself.

There is a fair amount of duplication between addons and the main app, mostly because there's not really a mechanism to reuse components (like inputs and buttons) between addons and the main app. As we discussed, that is probably a task better left for #181 and the duplication can be cleaned up at a later stage.

A summary of the git commit log:

  • Fix safe area in the panels by not applying the story's safe area preferences to the Storybook panel UI
  • Fix KeyboardAvoidingView padding intruding on the app's UI (focus an input and summon the soft-keyboard to see padding creep up from the bottom)
  • Rework the theme greatly and remove ad hoc use of values in addons and the Storybook UI
  • Tab styling changes (navigation UI, addons list, knob groups)

Screenshots

Before After
image image
image image
image image
image image
image image
image image
image image

How to test

The behaviour of Storybook should be identical to how it was before, any significant changes to the behaviour would be a regression. I've added some additional stories to help test aspects such as all of the controls in one place (like the knobs example). There is a commented section in examples/expo-example/.storybook/Storybook.tsx with some partial theme overrides.

I removed all the theme.value || 'some_default' patterns from the code, as this is a fair amount of maintenance overhead and in my testing I couldn't actually trigger a situation where theme.value returned nothing when it ought to have returned something. Because the user's theme is deep-merged with the default theme, there shouldn't be a case of accidentally missing values.

Jonathan Jacobs added 16 commits February 28, 2023 18:58
The panels are part of the Storybook UI, not the story content, they
should always take safe area into account so that their UI isn't
accidentally rendered in the margins of the device's screen.
KeyboardAvoidingView renders too much padding when the keyboard is
open, which ends up pushing the padding of the view up beyond the
keyboard. This is because the bottom inset (safe area inset + nav bar)
is not taken into account.
This deprecates all of the previous theme values and re-organises the
theme in a way that the majority of the Storybook UI can be themed
this way.
This also renames the components something more intentional than `Button`.
This makes it convenient to return the correct type for the theme.
- Allow tapping anywhere on a collapsed section to expand it
- More compact representation for values
This means users can override only the parts of the theme they're
interested in, from `getStorybookUI`.
@jonathanj jonathanj requested a review from dannyhw as a code owner March 1, 2023 12:24
@dannyhw dannyhw added the 6.5 label Mar 1, 2023
@dannyhw dannyhw added this to the 6.5 release milestone Mar 1, 2023
Copy link
Member

@dannyhw dannyhw left a comment

Choose a reason for hiding this comment

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

this is really great, amazing work @jonathanj!

@dannyhw dannyhw merged commit 4ea8989 into storybookjs:next-6.0 Mar 1, 2023
@jonathanj jonathanj deleted the improve-addons-styling branch March 1, 2023 15:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

2 participants