Skip to content

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
@Hotell Hotell force-pushed the feat/add-storybook-9-support branch from f476b1c to 06adc8c Compare February 25, 2025 16:40
@Hotell Hotell force-pushed the feat/add-storybook-9-support branch from ab52db7 to 85be015 Compare February 25, 2025 16:45
@Hotell Hotell force-pushed the feat/add-storybook-9-support branch from 85be015 to 6ffeef8 Compare February 25, 2025 16:46
@Hotell Hotell marked this pull request as ready for review February 25, 2025 16:47
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.

2 participants