-
Notifications
You must be signed in to change notification settings - Fork 249
docs(swc): convert 2nd-gen component story JSDoc to per-component MDX #6349
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
caseyisonit
wants to merge
14
commits into
main
Choose a base branch
from
caseyisonit/docs-to-mdx
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+1,974
−1,265
Open
Changes from 13 commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
6a462d9
feat(storybook): add DocsHeader and DocsFooter blocks for per-unit MDX
caseyisonit 90ab5ce
docs(badge): convert story JSDoc to badge.mdx
caseyisonit 9b4040c
docs(avatar): convert story JSDoc to avatar.mdx
caseyisonit 9f7cc1e
docs(color-loupe): convert story JSDoc to color-loupe.mdx
caseyisonit 76556ee
docs(divider): convert story JSDoc to divider.mdx
caseyisonit a2b9381
docs(progress-circle): convert story JSDoc to progress-circle.mdx
caseyisonit 2a864d5
docs(status-light): convert story JSDoc to status-light.mdx
caseyisonit e80c509
docs(typography): convert story JSDoc to typography.mdx
caseyisonit 83b3737
docs(illustrated-message): convert story JSDoc to illustrated-message…
caseyisonit 4cc3c14
docs(button): convert story JSDoc to button.mdx
caseyisonit afdbcf4
docs(tabs): convert story JSDoc to tabs.mdx
caseyisonit 3f49ffc
docs(asset,icon): convert internal story JSDoc to internal MDX
caseyisonit 6271d31
chore(storybook): refresh contributor-docs sidebar registrations
caseyisonit 2f74c9e
Merge branch 'main' into caseyisonit/docs-to-mdx
caseyisonit File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,74 @@ | ||
| /** | ||
| * Copyright 2026 Adobe. All rights reserved. | ||
| * This file is licensed to you under the Apache License, Version 2.0 (the "License"); | ||
| * you may not use this file except in compliance with the License. You may obtain a copy | ||
| * of the License at http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software distributed under | ||
| * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS | ||
| * OF ANY KIND, either express or implied. See the License for the specific language | ||
| * governing permissions and limitations under the License. | ||
| */ | ||
|
|
||
| import { | ||
| Controls, | ||
| HeaderMdx, | ||
| Primary, | ||
| useOf, | ||
| } from '@storybook/addon-docs/blocks'; | ||
| import React from 'react'; | ||
|
|
||
| import { ApiTable } from './ApiTable'; | ||
| import { SpectrumStories } from './SpectrumStories'; | ||
|
|
||
| /** | ||
| * The standard bottom of a Storybook docs page: API table, primary story, | ||
| * controls, and the feedback link. Genre-aware via meta tags; controllers | ||
| * (tagged `controller`) skip the API table because they expose a TypeScript | ||
| * class rather than a custom element manifest. | ||
| * | ||
| * Authors compose a docs page as: | ||
| * | ||
| * <Meta of={Stories} /> | ||
| * <DocsHeader /> | ||
| * ...component-specific sections... | ||
| * <DocsFooter /> | ||
| */ | ||
| export const DocsFooter = () => { | ||
| const resolvedOf = useOf('meta', ['meta']); | ||
| const tags: string[] = resolvedOf?.preparedMeta?.tags ?? []; | ||
| const isController = tags.includes('controller'); | ||
|
|
||
| // Per-unit pages may flag custom API content by tagging stories with `api`. | ||
| const hasCustomApiStories = Object.values( | ||
| resolvedOf?.csfFile?.stories ?? {} | ||
| ).some((story: any) => story.tags?.includes('api')); | ||
|
|
||
| return ( | ||
| <> | ||
| <HeaderMdx as="h2" id="api"> | ||
| API | ||
| </HeaderMdx> | ||
| {!isController && <ApiTable />} | ||
| <Primary /> | ||
| <Controls /> | ||
| {hasCustomApiStories && ( | ||
| <> | ||
| <hr /> | ||
| <SpectrumStories tag="api" hideTitle={true} /> | ||
| </> | ||
| )} | ||
|
|
||
| <HeaderMdx as="h2" id="feedback"> | ||
| Feedback | ||
| </HeaderMdx> | ||
| <p> | ||
| Have feedback or questions?{' '} | ||
| <a href="https://github.com/adobe/spectrum-web-components/issues/new/choose"> | ||
| Open an issue | ||
| </a> | ||
| . | ||
| </p> | ||
| </> | ||
| ); | ||
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,52 @@ | ||
| /** | ||
| * Copyright 2026 Adobe. All rights reserved. | ||
| * This file is licensed to you under the Apache License, Version 2.0 (the "License"); | ||
| * you may not use this file except in compliance with the License. You may obtain a copy | ||
| * of the License at http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software distributed under | ||
| * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS | ||
| * OF ANY KIND, either express or implied. See the License for the specific language | ||
| * governing permissions and limitations under the License. | ||
| */ | ||
|
|
||
| import { | ||
| Description, | ||
| Subtitle, | ||
| Title, | ||
| useOf, | ||
| } from '@storybook/addon-docs/blocks'; | ||
| import React from 'react'; | ||
|
|
||
| import { GettingStarted } from './GettingStarted'; | ||
| import { OverviewStory } from './OverviewStory'; | ||
| import { StatusBadge } from './StatusBadge'; | ||
|
|
||
| /** | ||
| * The standard top of a Storybook docs page: title, status badge, subtitle, | ||
| * description, overview story, and getting-started instructions. Genre-aware | ||
| * via meta tags (`migrated`, `controller`, `utility`); component, pattern, | ||
| * and controller pages all use this single block. | ||
| * | ||
| * Authors compose a docs page as: | ||
| * | ||
| * <Meta of={Stories} /> | ||
| * <DocsHeader /> | ||
| * ...component-specific sections... | ||
| * <DocsFooter /> | ||
| */ | ||
| export const DocsHeader = () => { | ||
| const resolvedOf = useOf('meta', ['meta']); | ||
| const tags: string[] = resolvedOf?.preparedMeta?.tags ?? []; | ||
|
|
||
| return ( | ||
| <> | ||
| <Title /> | ||
| <StatusBadge /> | ||
| <Subtitle /> | ||
| <Description /> | ||
| <OverviewStory /> | ||
| <GettingStarted tags={tags} /> | ||
| </> | ||
| ); | ||
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Auto generated from merges to main that werent picked up before |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,66 @@ | ||
| import { Canvas, Meta } from '@storybook/addon-docs/blocks'; | ||
| import { DocsFooter, DocsHeader } from '../../.storybook/blocks'; | ||
|
|
||
| import * as AssetStories from './stories/asset.internal.stories'; | ||
|
|
||
| <Meta of={AssetStories} /> | ||
|
|
||
| <DocsHeader /> | ||
|
|
||
| ## Anatomy | ||
|
|
||
| An asset consists of: | ||
|
|
||
| 1. **Icon or image content**: either a file/folder icon or custom slotted content | ||
| 2. **Accessible label**: provides context for assistive technologies | ||
|
|
||
| The asset automatically centers its content both horizontally and vertically within the available space. | ||
|
|
||
| ### Content | ||
|
|
||
| - **Default slot**: custom content to display (typically an image) when variant is not set | ||
| - **Label**: accessible label for screen readers (used as `aria-label` on the icon SVGs) | ||
|
|
||
| <Canvas of={AssetStories.Anatomy} /> | ||
|
|
||
| ## Options | ||
|
|
||
| ### Variants | ||
|
|
||
| Assets support two built-in icon variants for representing files and folders: | ||
|
|
||
| - **`file`**: displays a file icon, useful for representing documents, files, or file types | ||
| - **`folder`**: displays a folder icon, useful for representing directories or collections | ||
|
|
||
| When no variant is specified, the asset displays custom content provided via the default slot (typically an image). | ||
|
|
||
| <Canvas of={AssetStories.Variants} /> | ||
|
|
||
| ## Accessibility | ||
|
|
||
| ### Features | ||
|
|
||
| The `<swc-asset>` element implements several accessibility features: | ||
|
|
||
| #### ARIA implementation | ||
|
|
||
| - **Icon labeling**: file and folder SVG icons automatically use the `label` property as `aria-label` | ||
| - **Non-interactive**: assets have no interactive behavior and are not focusable | ||
|
|
||
| #### Visual accessibility | ||
|
|
||
| - Icons use sufficient color contrast in both light and dark modes | ||
| - High contrast mode is supported with appropriate color overrides | ||
| - Content automatically centers for consistent layout and visual balance | ||
|
|
||
| ### Best practices | ||
|
|
||
| - Always provide a descriptive `label` attribute for file and folder variants | ||
| - Use specific, meaningful labels or alt text (e.g., "Project proposal PDF", "projects/2025/proposal.pdf", or not just "File") | ||
| - The `label` on the asset itself should describe the asset's purpose or context | ||
| - For decorative images, use an empty `alt=""` attribute on the img tag | ||
| - Test with screen readers to verify assets are announced appropriately in context | ||
|
|
||
| <Canvas of={AssetStories.Accessibility} /> | ||
|
|
||
| <DocsFooter /> |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This and the DocsHeader blocks will be refined in a future PR but this reflects the current patterns that are consistent across all docs so far. Heavily based on DocumentTemplate.