-
-
Notifications
You must be signed in to change notification settings - Fork 9.4k
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: Add IS_STORYBOOK global variable #16676
Conversation
☁️ Nx Cloud ReportCI ran the following commands for commit 12f44d7. Click to see the status, the terminal output, and the build insights. 📂 See all runs for this branch ✅ Successfully ran 1 targetSent with 💌 from NxCloud. |
lib/core-client/src/preview/start.ts
Outdated
@@ -76,6 +76,9 @@ export function start<TFramework extends AnyFramework>( | |||
// eslint-disable-next-line no-underscore-dangle | |||
globalWindow.__STORYBOOK_PREVIEW__ = preview; | |||
globalWindow.__STORYBOOK_STORY_STORE__ = preview.storyStore; | |||
|
|||
// To enable user code to detect if it is running in Storybook | |||
globalWindow.IS_STORYBOOK = true; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This only gets executed in legacy 6.x mode, and not if you're using features.storyStoreV7
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@shilman I see that now, thank you. Is it okay to just move my line of code above the if (FEATURES?.storyStoreV7)
?
Yann directed me to this file but I am a bit confused because start.ts
does basically nothing if StoryStoreV7 is enabled.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sorry missed this question first time around. I think moving this to the top of the file will work. you should also check if (globalWindow) ...
(i'm not sure when it isn't set, but i'm sure the code is there for a reason)
Hi everyone! Seems like there hasn't been much going on in this issue lately. If there are still questions, comments, or bugs, please feel free to continue the discussion. Unfortunately, we don't have time to get to every issue. We are always open to contributions so please send us a pull request if you would like to help. Inactive issues will be closed after 30 days. Thanks! |
@shilman I believe this is ready to merge. I saw some E2E tests failed but it seems unrelated to my change. Thanks. |
Hey @srmagura thanks for this work! I'll make sure to properly test this out and merge on Monday the latest! In the meantime, could you rebase with latest next? Seems like your PR is introducing more changes than it was intended |
This is to let user code detect if it is running in Storybook.
e92afb4
to
97bc4ee
Compare
My bad, those changes were not intentional. It should be good now! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! Merging, thanks for your patience @srmagura and your contribution!!!
Issue: #16485.
What I did
Added a global variable to the preview window to enable user code to detect if it is running in Storybook. This was suggested in the discussion on #16379.
How to test
If your answer is yes to any of these, please make sure to include it in your PR.