docs: add Figma design links and real Badges to Storybook toolbar#1076
docs: add Figma design links and real Badges to Storybook toolbar#1076frankieyan wants to merge 10 commits into
Conversation
3a5e3fa to
cc7ad5e
Compare
Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Claude <noreply@anthropic.com>
cc7ad5e to
8d750c2
Compare
doistbot
left a comment
There was a problem hiding this comment.
This PR adds Figma design links to the Storybook toolbar for most component stories and switches the a11y/deprecated badges to use the real Reactist <Badge> component.
Few things worth tightening:
- The Figma tool shows a "No Figma link" message on docs pages that define their own MDX
<Meta>(e.g.modal-docs.mdx) instead of inheriting story meta—consider hiding the tool when there are no links, or wiringfigmainto those docs pages. VALID_TONESduplicates the Badge component's tone list as a second source of truth; exporting a runtime tone list or validator from the badge module and reusing it here would prevent valid badges from silently disappearing if tones change.- The bare-string branch in the Figma parameter resolver treats any non-empty string as both label and URL, turning typos into broken links—since all current usages already use
{ label, url }, dropping the string shorthand would keep the parameter shape explicit. IconButton(which always wraps in aTooltipand pulls@ariakit/reactinto the manager bundle) is heavier than needed for a simple external link in the Storybook manager; a lightweight<a>or button with a nativetitlewould reduce startup overhead on every page.
I also included a few optional follow-up notes in the details below.
Optional follow-up note (1)
- [P3] .storybook/figma/figma-tool.tsx:23:
IconButtonis pretty expensive in manager UI. In this code path it always wraps itself inTooltip(tooltip={link.label}), which pulls@ariakit/reactinto the Storybook manager bundle and creates a tooltip store for each Figma link. Becausemanager.tsloads on every Storybook page, this adds avoidable startup and render overhead for a simple external link. A lightweight<a>/button here with a nativetitlewould keep the manager much smaller.
| return ( | ||
| <Inline space="xsmall"> | ||
| {links.length === 0 ? ( | ||
| <Badge tone="info" label="No Figma link" /> |
There was a problem hiding this comment.
🟡 P2 This renders a false negative on docs pages that define their own MDX <Meta> instead of inheriting story meta. For example, src/modal/modal-docs.mdx has no figma parameter, so the modal docs page will now show No Figma link even though src/modal/modal-examples.stories.tsx adds one. Hiding the tool when links.length === 0, or wiring figma into those docs pages, would avoid that misleading state.
| function isRecord(value: unknown): value is UnknownRecord { | ||
| return typeof value === 'object' && value !== null && !Array.isArray(value) | ||
| } | ||
| const VALID_TONES: readonly BadgeTone[] = ['info', 'positive', 'promote', 'attention', 'warning'] |
There was a problem hiding this comment.
🟡 P2 VALID_TONES is now a second source of truth for the Badge tones. Since badgesConfig isn't statically checked, adding or renaming a Badge tone later will silently make valid toolbar badges disappear until this array is updated too. Please export a runtime tone list or validator from the badge module and reuse it here.
| } | ||
|
|
||
| function resolveEntry(entry: unknown): ResolvedFigmaLink[] { | ||
| if (typeof entry === 'string') { |
There was a problem hiding this comment.
🟡 P2 Treating any non-empty string as both label and url makes figma a stringly-typed parameter: a copied label or typo becomes a broken href instead of being rejected. All current usages in this PR already use { label, url }, so I'd drop the bare-string branch and keep the parameter shape explicit.
Short description
This PR adds Figma references to most of our component stories in the Storybook toolbar, sourced from https://github.com/Doist/frontend-issues/issues/1350.
We also switch the a11y/deprecated badges in the toolbar to use the real Reactist
<Badge>.PR Checklist
Demo