Skip to content
This repository has been archived by the owner on Sep 30, 2024. It is now read-only.

Update Storybook stories to use Component Story Format #25227

Closed
umpox opened this issue Sep 22, 2021 · 7 comments · Fixed by #37403 or #38080
Closed

Update Storybook stories to use Component Story Format #25227

umpox opened this issue Sep 22, 2021 · 7 comments · Fixed by #37403 or #38080
Assignees
Labels
gitstart Contract partner good first issue Good for newcomers

Comments

@umpox
Copy link
Contributor

umpox commented Sep 22, 2021

Problem statement

The Component Story Format is the recommended way to write stories in Storybook. The new format is easier to understand and it is also important that we update our existing stories to ensure we stay up to date with new features, and are able to follow future documentation.

Check out this Sourcegraph search result to view these stories.

Success criteria

  • All stories in the repo are using the Component Story Format
  • All stories still usable when running yarn storybook

Implementation details

Please see this PR description as an example of how this change can be implemented.

In summary, follow these implementation steps:

  1. Modify existing storiesOf usage to ensure any add or alternative function calls are chained onto the original storiesOf function call. See this diff for an example of this change: https://github.com/sourcegraph/sourcegraph/pull/25222/commits/e3a39cae40c69cb74de1d0461bd70fb31bdb281a
  2. Run the storiesof-to-csf Storybook codemod with this command: npx sb migrate storiesof-to-csf --glob="client/web/**/*.story.tsx". For an expected diff (on different files) see this commit: https://github.com/sourcegraph/sourcegraph/commit/5a5b716337da4a768b4b26157d06728035c57816
  3. Run the csf-hoist-story-annotations Storybook codemod with this command: npx sb migrate csf-hoist-story-annotations --glob="client/web/**/*.story.tsx". For an expected diff (on different files) see this commit: https://github.com/sourcegraph/sourcegraph/commit/b228f5d5879b5164d23565c7d63480793e6004da
  4. You will likely see TypeScript warnings on the newly-modified files. Update these by adding the Storybook types. See this commit for reference: https://github.com/sourcegraph/sourcegraph/commit/810e8e217d6a665f109ca2a0a92ba4125f6b27ea

Time estimate

  • Pull requests with ~450 lines changed should take 6 hours at maximum. Ping the reviewer in the spec pull request if time-consuming changes are required.
  • Split the work into multiple pull requests if the total diff is bigger than 450 lines of code.
@umpox umpox added the good first issue Good for newcomers label Sep 22, 2021
@sourcegraph sourcegraph deleted a comment from valerybugakov Oct 21, 2021
@valerybugakov valerybugakov added the gitstart Contract partner label Jun 2, 2022
@valerybugakov valerybugakov changed the title Update 'web' Storybook stories to use Component Story Format Update Storybook stories to use Component Story Format Jun 2, 2022
@gitstart-app
Copy link
Contributor

gitstart-app bot commented Jun 2, 2022

Here is the GitStart Ticket for this issue: https://app.gitstart.com/clients/sourcegraph/tickets/SG-25227

@valerybugakov
Copy link
Member

Hey @gitstart-sourcegraph, it seems that this issue is not completed yet. We still have several storiesOf usages in the codebase.

@gitstart-sourcegraph
Copy link
Collaborator

gitstart-sourcegraph commented Jun 28, 2022

@valerybugakov Thanks. This is closed by accident when merging a PR linked to this issue. There are some remaining sub issues which we have created and we are working on them

@gitstart-sourcegraph
Copy link
Collaborator

@valerybugakov,
We skipped some stories during migration based on based on some limitation as mentioned here,
Sample story?

@valerybugakov
Copy link
Member

valerybugakov commented Jun 29, 2022

@gitstart, for the linked case with the for of loop, we need to migrate it to multiple named exports using template and args. What do you think?

@raph941
Copy link

raph941 commented Jun 29, 2022

@gitstart, for the linked case with the for of loop, we need to migrate it to multiple named exports using template and args. What do you think?

Thanks, that works.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.