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: implement --stepsApi configuration flag for storybook v8, v9 and vNext support #74

Draft
wants to merge 15 commits into
base: storybook7
Choose a base branch
from

Conversation

Hotell
Copy link

@Hotell Hotell commented Feb 20, 2025

Pre-requirements:

Features

Starting SB v8 using storyStore raw API is deprecated and will be removed in SB v9 (https://github.com/storybookjs/storybook/blob/next/MIGRATION.md#storystore-and-methods-deprecated).

For that reason, we won't be able to render stories dynamically to traverse React Tree to obtains StoryWright component steps prop.

This PR implements new API to obtain stories which uses stable/non-deprecated api to obtain stories dynamically via Preview.extract()

Using the new API

Your steps need to be defined via parameters rather than using decorators with <StoryWright/> component

Before:

import {StoryWright, Steps} from 'storywright';
import {Button} from 'ui'

export default {
  component: Button,
  // 🚨 This wont work anymore 🚨
  decorators: [ 
    (Story)=>{
       return <StoryWright steps={new Steps().snapshot('default').end()}>{ Story() }</StoryWright>
    }
  ]
}

After:

import {Steps, type StoryParameter} from 'storywright';
import {Button} from 'ui'

export default {
  component: Button,
 // 💪 new future proof API 💪
  parameters: {
   storyWright: { 
       steps: new Steps().snapshot('default').end()
   }
  } satisfies StoryParameter
}

Important

In order to avoid breaking changes immediately and to properly support SB versions ranges from V7 to V9, the new API can be turned on by setting --stepsApi=parameters

image

Related Issues

@Hotell Hotell changed the base branch from main to storybook7 February 20, 2025 12:19
@Hotell Hotell changed the title Feat/add storybook 9 support feat: add --stepsApi configuraion for storybook v8 and v9 Feb 20, 2025
@Hotell Hotell changed the title feat: add --stepsApi configuraion for storybook v8 and v9 feat: add --stepsApi configuration for storybook v8 and v9 Feb 20, 2025
@Hotell Hotell changed the title feat: add --stepsApi configuration for storybook v8 and v9 feat: add --stepsApi configuration flag for storybook v8, v9 and vNext support Feb 20, 2025
@Hotell Hotell changed the title feat: add --stepsApi configuration flag for storybook v8, v9 and vNext support feat: implement --stepsApi configuration flag for storybook v8, v9 and vNext support Feb 20, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant