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

Core: Single story option in iframe view #14875

Merged
merged 11 commits into from
May 19, 2021

Conversation

robhil
Copy link
Contributor

@robhil robhil commented May 10, 2021

We are trying to integrate the Storybook in our app - UXPin and allow our users to use components from Storybook in their design.
Generally, it's work fine but we noticed that the iframe view loads slower when there are more stories added to the storybook
e.g. please take into consideration this button: https://5ccbc373887ca40020446347-synmdrrwjj.chromatic.com/iframe.html?id=design-system-button--basic&viewMode=story

ConfigApi.configure takes about 900ms.
Screenshot 2021-05-10 at 15 48 24

What I did

We figured out that we can load only one story when we want to show only one component.
We added a new param __singleStory and when it's true only one story is loaded.
As I know you have some plans to improve the loading time but this solution could be a quick win for us :)
Here you can see how it looks tested on official-storybook example
https://recordit.co/dkie0lFbJk

How to test

  • Is this testable with Jest or Chromatic screenshots?
    no
  • Does this need a new example in the kitchen sink apps?
    no
  • Does this need an update to the documentation?
    no

@nx-cloud
Copy link

nx-cloud bot commented May 10, 2021

Nx Cloud Report

CI ran the following commands for commit 69880ed. Click to see the status, the terminal output, and the build insights.

📂 See all runs for this branch

Status Command
#000000 nx run-many --target=prepare --all --parallel --max-parallel=15

Sent with 💌 from NxCloud.

@robhil robhil marked this pull request as ready for review May 10, 2021 15:04
@shilman
Copy link
Member

shilman commented May 10, 2021

Great stuff @robhil!! 😻

We're also thinking about some other use cases here #14843. I'll try to get some variant of this (this PR or a slightly more general one) into 6.3 to help your perf.

@shilman shilman added the core label May 13, 2021
@shilman shilman changed the title Single story mode option in iframe view Core: Single story mode option in iframe view May 13, 2021
@shilman shilman changed the title Core: Single story mode option in iframe view Core: Single story option in iframe view May 13, 2021
@shilman
Copy link
Member

shilman commented May 13, 2021

@robhil Some news:

  1. we love this feature and i've promoted it back to a normal query param
  2. we're starting another round of optimization work and will be considering this as a distinct use case to be optimized (bundle splitting etc.)

I'll merge this as soon as CI passes and release in the next alpha. Great work! 🎉

@shilman
Copy link
Member

shilman commented May 13, 2021

@tmeasday any ideas for a cleaner way to implement this?

Copy link
Member

@tmeasday tmeasday left a comment

Choose a reason for hiding this comment

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

I think this is a great idea and it is a pretty great implementation, thank you for the tests.

However I think I agree with what @shilman is hinting at here and that we should do this filtering in the store. It knows about the specifier already, so could it not just make addStory()/addKindMetadata() a no-op when the kind/storyId doesn't match? WDYT?

We have to evaluate (i.e require) all the imports anyway in this implementation so I would imagine that iterating through them and performing a no-op for each one wouldn't have a performance cost, but if that's not the case, we could reconsider.

I am planning on totally overhauling the story store sometime soon (probably not for 6.3 though), so I am not precious about how this is implemented, but putting it in store at least means it would also work for non-CSF stories too.

@shilman shilman self-assigned this May 14, 2021
@robhil robhil requested a review from tmeasday May 18, 2021 13:54
Copy link
Member

@tmeasday tmeasday left a comment

Choose a reason for hiding this comment

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

Great! Thank you

@shilman shilman merged commit b88ab7c into storybookjs:next May 19, 2021
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