-
Notifications
You must be signed in to change notification settings - Fork 5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: storybook theme package not working (#27086)
## **Description** This PR removes the `storybook-dark-mode` package and utilizes the native Storybook Theme API for managing the light and dark modes across both the documentation and component preview pages. The motivation behind this change is to fix the bug introduced after upgrading Storybook to ^7.6.20 and `storybook-dark-mode` to ^4.0.2, which resulted in the following error: ``` Error: Storybook preview hooks can only be called inside decorators and story functions. ``` Additionally, we have updated the `DocsContainer` to ensure it handles the theme correctly without throwing errors. The bug prevented Storybook Docs pages from rendering properly. Key changes: 1. Removed the `storybook-dark-mode` package. 2. Implemented the native Storybook Theme API to manage light/dark modes. 3. Added a button to toggle between light, dark and side by side modes in the component preview area. 4. Ensured the theme context is properly checked and applied, particularly in the Docs rendering. Additional Context: - We will be implementing the shared UI Component library soon and we can revisit whether having the additional add-on (`storybook-dark-mode`) is valuable enough to add an additional dependency. We can add it to our roadmap for discussion when we are working on the storybook portion of our roadmap. ## Possible Asked Questions - Did you consider that the app theme is not changing? Yes. It is set to the users system, so if the user uses dark mode then the application will run in dark. Made attempts for a fix - Did you consider a fix with the existing package? Yes. The best solution was to revert to the old package version, but that stops us from progressing forward. It's nice to remove dependencies and use built-in options. ## **Related issues** Fixes: - #26703 (Introduced the error after upgrading to Storybook 7.6.20) ## **Manual testing steps** 1. Run `yarn storybook`. 2. Visit the [component docs page running locally](http://localhost:6006/?path=/docs/components-componentlibrary-avataraccount--docs). 3. Verify that no errors related to theme switching appear in the console. 4. Ensure the docs page renders properly in both light and dark themes. 5. Test theme switching using the button added in the component preview. --------- Co-authored-by: legobeat <[email protected]>
- Loading branch information
1 parent
1d686e2
commit 9668df7
Showing
3 changed files
with
79 additions
and
68 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters