Storybook: add synonyms for UI components#78951
Conversation
Centralize synonym terms so sidebar search can find components by common names (e.g. "form" matches Input), and patch the Storybook manager at dev/build time because search only indexes name and path by default.
|
|
||
| const meta: Meta< typeof Badge > = { | ||
| title: 'Design System/Components/Badge/Choosing intent', | ||
| synonyms: [ 'chip', 'intent', 'label', 'status', 'tag' ], |
There was a problem hiding this comment.
Tag is fine here, can we add that also to FormTokenField?
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message. To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
|
I like it, only on a code review 👍 👍 Perhaps need a deeper test before the green check. |
|
Size Change: 0 B Total Size: 8.19 MB ℹ️ View Unchanged
|
| @@ -0,0 +1,101 @@ | |||
| /** | |||
| * Patches Storybook manager runtime so sidebar search includes design system synonyms. | |||
There was a problem hiding this comment.
Apparently, Storybook doesn’t allow add-ons to extend the sidebar search (didn’t dig deeper if that’s true), so the agent went and built some scripts for it. I don’t have experience with Storybook to tell if that’s typical or not, but I'm not super thrilled to see it myself. :-)
It works, but gives me a big pause for merging tho.
|
|
||
| // Fuse.js requires key weights to sum to at most 1. | ||
| const FUSE_KEYS_REPLACEMENT = `keys: [ | ||
| { name: "name", weight: 0.5 }, |
There was a problem hiding this comment.
Name weight was 0.7 before so could prolly bump it back up.
jasmussen
left a comment
There was a problem hiding this comment.
Tentative green light.
| { "path": "../style-runtime" }, | ||
| { "path": "./tsconfig.src.json" }, | ||
| { "path": "./tsconfig.bin.json" } | ||
| { "path": "./tsconfig.src.json" } |
There was a problem hiding this comment.
I wouldn't expect this change. It means we're no longer type-checking files in bin. Was there a reason it was needed?
There was a problem hiding this comment.
Ideally, I think this would use the same glob file patterns that the main Storybook build uses, rather than hard-coding specific folders and filename conventions.
It also reminds me a bit of what I'm doing in #78472 , which is: How do we get story metadata out of the stories without reparsing all of the story files. I don't know that a centralized registry of keywords is the best solution, but it's where I landed when confronted with the reality of what this walking/parsing ends up looking like 😅
There was a problem hiding this comment.
Interestingly, I first had synonyms centralised in one file (b9206dd), but I switched to having them in each file separately for better dev-ergonomics; easier not to miss them when they're directly in the component file.
|
FYI I'm planning to open PR upstream for Storybook to suggest synonyms in ~couple weeks when I have time next time. |
What?
Makes easier to find components by adding synonyms to each UI component:
Screenshots or screencast
Before
"Modal" finds only the old


@wordpress/componentsModal component:"Chip" doesn't find anything:
After
"Modal" surfaces the new

@wordpress/uiDialog, AlertDialog and Drawer components:"Chip" surfaces the new

@wordpress/uiBadge component:Why?
Just quicker to discover right components.
How?
Testing Instructions
Run
npm run storybook:devand try different search terms.Skim through the synonyms added in this PR to see if they make sense; would you remove/add any?
Testing Instructions for Keyboard
Use of AI Tools
yes