storybookjs/storybook

[Feature Request]: Upgrade `Primary`, `Title`, `Subtitle` and `Stories` blocks to the new v7 blocks API

Open

#22,490 opened on May 10, 2023

View on GitHub
 (14 comments) (0 reactions) (0 assignees)TypeScript (89,909 stars) (10,058 forks)batch import
feature requestgood first issue

Description

Is your feature request related to a problem? Please describe

Storybook v7 introduced a new API for doc blocks that is based on an of prop and change in parameters location. See https://storybook.js.org/blog/storybook-7-docs/#doc-blocks-api-is-powerful-yet-simple

However the blocks Primary, Title and Subtitle were not fully migrated to the new API.

Describe the solution you'd like

Each block should be changed to match the general blocks API, similar to how eg. the Description block is implemented: https://github.com/storybookjs/storybook/blob/next/code/ui/blocks/src/blocks/Description.tsx It's important that the changes are backwards compatible, and the current usage is still supported, but with a deprecation warning.

Primary

  • Add support for of prop via useOf - only the "meta" type is valid here
  • Document changes
  • Add stories
  • Make sure it is backwards compatible - should still work with name prop, or no prop at all (infers the current component)

Title

  • Add support for of prop via useOf - only the "meta" type is valid here
  • Document changes
  • Add stories
  • Make sure it is backwards compatible - children prop should not be deprecated

Subtitle — #22552 by @joaonunomota

  • Add support for of prop via useOf - only the "meta" type is valid here
  • Default to extracting content from parameters.docs.subtitle
  • Deprecate extracting content from parameters.componentSubtitle
  • Document changes
  • Add stories
  • Make sure it is backwards compatible - children prop should not be deprecated.

Stories

  • Add support for of prop via useOf - only the "meta" type is valid here
  • Default to get title from parameters.docs.stories.title
  • Default to get includePrimaryStory from parameters.docs.stories.includePrimaryStory
  • Document changes
  • Add stories

Additional context

These changes are rather small, so they can be made in one PR or in 4 different PRs. Any new or experienced contributor is free to pick these up.

Note Anyone are free to work on these issues, you don't need to "reserve" it by asking here, just open a pull request with your work when you're done.

Contributor guide

[Feature Request]: Upgrade `Primary`, `Title`, `Subtitle` and `Stories` blocks to the new v7 blocks API · storybookjs/storybook#22490 | Good First Issue