Skip to content

docs(web-components): match storybook argTypes to custom element manifest#36271

Open
davatron5000 wants to merge 15 commits into
microsoft:masterfrom
davatron5000:user/rup/feat/storybook-helpers
Open

docs(web-components): match storybook argTypes to custom element manifest#36271
davatron5000 wants to merge 15 commits into
microsoft:masterfrom
davatron5000:user/rup/feat/storybook-helpers

Conversation

@davatron5000
Copy link
Copy Markdown
Contributor

Previous Behavior

Nearly all stories had either an error or some sort of missing property

New Behavior

  • Generated a verify-storybook script that verifies that Storybook matches the CEM
  • verify-storybook will also surface missing JSDocs for cssProps/cssVars/events in the component class
  • Updated all stories with missing attributes, properties, events, etc (nearly all stories)
  • Added sorting for stories
  • Patched up a few quick and styling gaps
  • Removed autofocus from all component classes because this is a feature of HTML, not our components (Tests passed in all browsers locally)

Related Issue(s)

  • Fixes #

@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 30, 2026

📊 Bundle size report

✅ No changes found

@github-actions
Copy link
Copy Markdown

Pull request demo site: URL

Comment thread packages/web-components/.storybook/preview.mjs Outdated
Comment thread packages/web-components/.storybook/preview.mjs Outdated
Comment thread packages/web-components/.storybook/preview.mjs Outdated
Comment thread packages/web-components/.storybook/preview.mjs Outdated
Comment thread packages/web-components/scripts/verify-storybook.js Outdated
Comment thread packages/web-components/src/checkbox/checkbox.spec.ts Outdated
Comment thread packages/web-components/src/combobox/combobox.stories.ts Outdated
ariaLabelledby: {
control: 'text',
name: 'aria-labelledby',
table: { category: 'attributes' },
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a separate category for aria attributes?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I started down that path but abandoned in in the sorting exercises... but I'm willing to add that separation back in. It made the tables a little bit noisy but I do like the separation. LMK if it's a MUST HAVE for you.

Comment thread packages/web-components/src/accordion-item/accordion-item.stories.ts Outdated
Comment thread packages/web-components/src/toggle-button/toggle-button.stories.ts Outdated
Comment thread packages/web-components/.storybook/preview.mjs Outdated
@davatron5000
Copy link
Copy Markdown
Contributor Author

@radium-v @marchbox Thanks for the feedback because it made me realize there's got to be a better way. I pushed up some changes to the extent that this could be considered an entirely different PR. Here's what changed from before:

  • Abandoned the verify-storybook.js script
  • Forked @wc-toolkit/storybook-helpers to support FAST
  • Converted all Storybook stories to use the argTypes from the new .storybook/wc-toolkit-helpers.ts

This has cleaned up a lot of the gnarliness from the previous PR and exposed some documentation pieces my previous verify-storybook script had missed. It also fixes some of the naming consistency issues brought up in the previous PR review.

The wc-toolkit fork is 90% the same but with three critical differences that map to how our stories work:

  • Supports FASTElement - wc-toolkit's version has a peer dependency on lit and tries to negotiate a TemplateResult with Lit for the story template. Becuase we have all our renderComponent() helper logic in there, I removed all the Lit-specific template result and how we pass templates into the story is still the same.
  • **Hides all fooAttributeChanged methods - I found the fooAttributeChanged methods to be a bit noisy. I removed them from the methods block in the argTypes table.
  • Follows our fooSlottedContent pattern - Rather than re-write all our stories, I made the helper follow our pattern for customized slotted content at the story-level.
    • default slots map to slottedContent: () => {}
    • slot="foo" maps to fooSlottedContent: () => {}

The biggest change here is that we're leveraging the CEM for 90% of our storybook argTypes with a few additions here and there. Overall this feels like a major upgrade in terms of maintainability and quality because I was able to surface and fix up broken CEM tags.

Possible future explorations are fixing ordering and using the CEM for default args values as well.

@davatron5000 davatron5000 requested a review from a team as a code owner June 3, 2026 21:09
@davatron5000 davatron5000 changed the title docs(web-components): match storybook argTyples to custom element manifest docs(web-components): match storybook argTypes to custom element manifest Jun 3, 2026
@davatron5000 davatron5000 requested review from marchbox and radium-v June 4, 2026 19:28
Comment thread packages/web-components/.storybook/wc-toolkit-helpers.ts
Comment thread packages/web-components/src/tablist/tablist.stories.ts
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

3 participants