Skip to content

fix(swc): style API table typography and render markdown in descriptions#6524

Merged
pfulton merged 3 commits into
mainfrom
rubencarvalho/fix-swc-api-table-typography
Jul 17, 2026
Merged

fix(swc): style API table typography and render markdown in descriptions#6524
pfulton merged 3 commits into
mainfrom
rubencarvalho/fix-swc-api-table-typography

Conversation

@rubencarvalho

@rubencarvalho rubencarvalho commented Jul 17, 2026

Copy link
Copy Markdown
Contributor

Description

Before:
Screenshot 2026-07-17 at 16 15 03
(https://spectrum-web-components.adobe.com/?path=/docs/components-tabs--docs#api)

After:
Screenshot 2026-07-17 at 16 18 24
(https://swcpreviews.z13.web.core.windows.net/pr-6524/docs/gen2-storybook-prod/?path=/docs/components-tabs--docs#api)

The Storybook ApiTable block (used on every 2nd-gen component/pattern/controller docs page) rendered its Properties/Slots/Events/CSS Custom Properties/CSS Parts tables at the docs-wide default table font size, and rendered CEM description text as raw strings, so markdown syntax (code spans, links, bold) authored in JSDoc never rendered, and none of the design system's own typography classes were applied.

This PR:

  • Adds swc-Body/swc-Body--sizeM to each API table (bumping from 14px to 16px) and scopes the docs-wide generic table font-size override in preview-head.html to exclude these tables (table:not(.swc-ApiTable)).
  • Adds swc-Code/swc-Code--sizeS to every <code> cell (property/attribute/slot/event/CSS name and default value).
  • Adds swc-Detail/swc-Detail--sizeS to the (reflects) annotation, and swc-Body/swc-Body--sizeM to the empty/error-state fallback messages.
  • Renders description fields through Storybook's Markdown block (forceInline: true) instead of interpolating the raw string, so markdown authored in CEM descriptions (code spans, links, bold) now renders.
  • Configures Markdown's overrides so emitted <code> spans get swc-Code/swc-Code--sizeS, and wraps output in swc-Typography--prose so links inherit the design system's prose link colors/hover/focus states.

Motivation and context

The API reference tables are the primary technical reference on every component's docs page. They were both harder to read (undersized text, inconsistent with the rest of the docs page) and silently dropped any markdown formatting authored in component JSDoc (e.g. `code` references or links to related components), rendering it as literal asterisks/backticks instead.

Related issue(s)

Screenshots (if appropriate)

N/A — text/typography only change, verify visually in Storybook docs for any component (e.g. Badge, Button) under the API section.

Author's checklist

  • I have read the CONTRIBUTING and PULL_REQUESTS documents.
  • I have reviewed at the Accessibility Practices for this feature, see: Aria Practices
  • I have added automated tests to cover my changes.
  • I have included a well-written changeset if my change needs to be published.
  • I have included updated documentation if my change required it.

Reviewer's checklist

  • Includes a Github Issue with appropriate flag or Jira ticket number without a link
  • Includes thoughtfully written changeset if changes suggested include patch, minor, or major features
  • Automated tests cover all use cases and follow best practices for writing
  • Validated on all supported browsers
  • All VRTs are approved before the author can update Golden Hash

Manual review test cases

  • API table renders at increased size and description markdown renders

    1. Run Storybook (yarn storybook, in 2nd-gen/packages/swc) and open any migrated component's docs page (e.g. Badge)
    2. Scroll to the API section (Properties/Slots/Events/CSS Custom Properties/CSS Parts tables)
    3. Expect table text visibly larger than before (16px body / 14px code) and, for any property/slot with a JSDoc description containing `code` or a markdown link, expect it to render as an actual <code> span or <a> link rather than literal backticks/brackets
  • No regression to other docs tables

    1. Open any docs page and inspect a non-API table (e.g. an argTypes Controls table or a Storybook-native table)
    2. Expect font size unchanged (still the smaller docs-wide default), since the override now only excludes .swc-ApiTable

Device review

  • Did it pass in Desktop?
  • Did it pass in (emulated) Mobile?
  • Did it pass in (emulated) iPad?

Accessibility testing checklist

  • Keyboard (required — document steps below)

    • Not applicable: this change only affects static, non-interactive reference tables and prose text (font size, typography classes, and markdown rendering of description text). No focusable elements are added, removed, or reordered. Confirm no regressions in keyboard navigation through the surrounding docs page (Tab order into/out of the API section unchanged).
  • Screen reader (required — document steps below)

    1. Open a component's docs page in Storybook and navigate to the API section with a screen reader active (e.g. VoiceOver)
    2. Read through a Properties table row where the description contains a markdown link (e.g. cross-references to another component)
    3. Expect the link to be announced as a link with its accessible name (not read as literal [text](url) markdown), and expect table structure (row/column headers, cell content) to be announced correctly and unchanged from before this change

The Storybook API table used the docs-wide table font size and rendered
CEM descriptions as raw text, so markdown syntax and design-system
typography classes never applied. Increase the table font size using
swc-Body/swc-Code classes, scope it out of the generic docs table
override, and render descriptions through Markdown with swc typography
overrides for code spans and prose links.
@rubencarvalho
rubencarvalho requested a review from a team as a code owner July 17, 2026 14:09
@changeset-bot

changeset-bot Bot commented Jul 17, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: d70fcf1

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@rubencarvalho rubencarvalho added Component:Documentation Issues or PRs involving changes to docs or docs website. Component prefix is for Jira integration. Status:Ready for review PR ready for review or re-review. labels Jul 17, 2026
@rubencarvalho rubencarvalho mentioned this pull request Jul 17, 2026
21 tasks
@github-actions

Copy link
Copy Markdown
Contributor

📚 Branch Preview Links

🔍 Gen1 Visual Regression Test Results

When a visual regression test fails (or has previously failed while working on this branch), its results can be found in the following URLs:

Deployed to Azure Blob Storage: pr-6524

If the changes are expected, update the current_golden_images_cache hash in the circleci config to accept the new images. Instructions are included in that file.
If the changes are unexpected, you can investigate the cause of the differences and update the code accordingly.

@rubencarvalho rubencarvalho added the skip_vrt Skip VRT build; mark UI Tests green without running Chromatic label Jul 17, 2026

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.

At some point we need to take a look at this preview-head styles, this needs some love.

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.

Just a note I looked into this previously and could not find a way to load a stylesheet separately, hence why it all lives in the HTML :( And the way Storybook applies it's own styles makes some of this trickier than necessary too, leading to the use of scope and some of the other funny looking stuff.

@pfulton pfulton Jul 17, 2026

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

swc-Detail already renders as visually secondary text; the extra 0.8
opacity was unnecessary on top of that.

@5t3ph 5t3ph left a comment

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.

Thanks for addressing this!

@pfulton pfulton left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Yes, thank you for doing this. It looks much better.

@pfulton pfulton added Status:Ready for merge PR has 2 approvals, all tests pass, and is ready to merge and removed Status:Ready for review PR ready for review or re-review. labels Jul 17, 2026
@pfulton
pfulton merged commit 9c6a849 into main Jul 17, 2026
36 checks passed
@pfulton
pfulton deleted the rubencarvalho/fix-swc-api-table-typography branch July 17, 2026 16:09
caseyisonit pushed a commit that referenced this pull request Jul 20, 2026
…ons (#6524)

* fix(swc): style API table typography and render markdown in descriptions

The Storybook API table used the docs-wide table font size and rendered
CEM descriptions as raw text, so markdown syntax and design-system
typography classes never applied. Increase the table font size using
swc-Body/swc-Code classes, scope it out of the generic docs table
override, and render descriptions through Markdown with swc typography
overrides for code spans and prose links.

* fix(swc): remove dimmed opacity on API table reflects annotation

swc-Detail already renders as visually secondary text; the extra 0.8
opacity was unnecessary on top of that.

---------

Co-authored-by: Patrick Fulton <360251+pfulton@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Component:Documentation Issues or PRs involving changes to docs or docs website. Component prefix is for Jira integration. skip_vrt Skip VRT build; mark UI Tests green without running Chromatic Status:Ready for merge PR has 2 approvals, all tests pass, and is ready to merge

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants