fix(swc): style API table typography and render markdown in descriptions#6524
Conversation
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.
|
📚 Branch Preview Links🔍 Gen1 Visual Regression Test ResultsWhen 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: If the changes are expected, update the |
There was a problem hiding this comment.
At some point we need to take a look at this preview-head styles, this needs some love.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Are we able to import a separate stylesheet, ala: https://github.com/adobe/spectrum-css/blob/37620864c60c4c142a506017e1a15348a26abb0e/.storybook/preview.js#L18 ? Importing from files kept here: https://github.com/adobe/spectrum-css/tree/main/.storybook/assets
swc-Detail already renders as visually secondary text; the extra 0.8 opacity was unnecessary on top of that.
5t3ph
left a comment
There was a problem hiding this comment.
Thanks for addressing this!
pfulton
left a comment
There was a problem hiding this comment.
Yes, thank you for doing this. It looks much better.
…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>
Description
Before:

(https://spectrum-web-components.adobe.com/?path=/docs/components-tabs--docs#api)
After:

(https://swcpreviews.z13.web.core.windows.net/pr-6524/docs/gen2-storybook-prod/?path=/docs/components-tabs--docs#api)
The Storybook
ApiTableblock (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 CEMdescriptiontext 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:
swc-Body/swc-Body--sizeMto each API table (bumping from 14px to 16px) and scopes the docs-wide generictablefont-size override inpreview-head.htmlto exclude these tables (table:not(.swc-ApiTable)).swc-Code/swc-Code--sizeSto every<code>cell (property/attribute/slot/event/CSS name and default value).swc-Detail/swc-Detail--sizeSto the(reflects)annotation, andswc-Body/swc-Body--sizeMto the empty/error-state fallback messages.descriptionfields through Storybook'sMarkdownblock (forceInline: true) instead of interpolating the raw string, so markdown authored in CEM descriptions (code spans, links, bold) now renders.Markdown'soverridesso emitted<code>spans getswc-Code/swc-Code--sizeS, and wraps output inswc-Typography--proseso 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
Reviewer's checklist
patch,minor, ormajorfeaturesManual review test cases
API table renders at increased size and description markdown renders
yarn storybook, in2nd-gen/packages/swc) and open any migrated component's docs page (e.g. Badge)`code`or a markdown link, expect it to render as an actual<code>span or<a>link rather than literal backticks/bracketsNo regression to other docs tables
.swc-ApiTableDevice review
Accessibility testing checklist
Keyboard (required — document steps below)
Screen reader (required — document steps below)
[text](url)markdown), and expect table structure (row/column headers, cell content) to be announced correctly and unchanged from before this change