etchteam / storybook-addon-css-variables-theme

Change the CSS variable based design tokens in your storybook on the fly
MIT License
28 stars 12 forks source link

Not compatible with Storybook v7 #38

Closed goldst closed 1 year ago

goldst commented 1 year ago

Hello there, once more thanks for the addon. We're still big fans of it.

We are in the process of moving from Storybook 6 to Storybook 7 beta and would like to keep switching themes.

Storybook-addon-css-variables-theme does not load themes in the current prerelease of Storybook 7.

The reason is that the channel API doesn't work anymore. Importing useChannel from the new location doesn't seem to fix it.

This can be reproduced by running npx storybook@next upgrade --prerelease on an existing Storybook (not this repository), accepting all migrations, and installing this addon. I would appreciate it if you could try to reproduce it because I see there already was a Storybook 7-related PR and nobody mentioned that it wasn't working.

I pushed a fix to our fork that replaces the Storybook API calls with iframe message events. This works with both Storybook 6 and 7. If you can reproduce the problem above, I can create a PR. For now, it is incomplete though because in sb7 there are cases in which it only works after reloading.

jonniebigodes commented 1 year ago

I'm one of the Storybook maintainers. I focus primarily on documentation and community outreach. Just wanted to follow up on this issue letting you know that the Storybook API for building addons is currently being updated to factor in the changes introduced by the upcoming 7.0 release. If you're interested in making the required changes to help the community from benefiting from using your addon, we've prepared an abridged guide for the required changes here, and if you have any questions or issues, please reach out to us in the #prerelease channel in our Discord Server.

Hope you have a great day!

Stay safe

johantor commented 1 year ago

Added a fix for this in #40 , only change needed was the named import. Running this on 7.0.0-beta.48 locally.

goldst commented 1 year ago

Thanks @johantor, I updated our storybook and all official addons from 7.0.0-beta.21 to 7.0.0-beta.49 and can confirm that your change to named import now fixes the problem!

JReinhold commented 1 year ago

Hey @johantor and @DanWebb, Storybook v7.0.0 is out! It's only on the next tag for now, but it's still targetable with the ^7.0.0 semver range, so you should be able to develop against it with no dependency issues.

It seems like you've already sorted out v7 support, but it would be a great help to users if you would upgrade the dependencies in package.json from ^7.0.0-beta.49 to just ^7.0.0.

If you hit any issues with v7, we've written a migration guide for addon authors here and here.

You're also free to reach out to us in the #prerelease channel on our Discord Server and we'll happily help you out!

cc @ndelangen