refactor(docs): extract SetValueButton shared component from control components#34263
refactor(docs): extract SetValueButton shared component from control components#34263mixelburg wants to merge 2 commits intostorybookjs:nextfrom
Conversation
…components The 'Set X' button pattern (rendered when a control value is undefined) was duplicated verbatim across four control files: Boolean, Number, Text, and Object. The only differences were the button label and the onClick handler. Extract a shared SetValueButton component to eliminate the repetition. As a side effect, Object's button now consistently uses variant='outline' and size='medium', matching the other three controls. Closes storybookjs#34211
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (5)
📝 WalkthroughWalkthroughExtracted repeated "set value" button rendering logic from control components (Boolean, Number, Object, Text) into a new Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes Possibly related PRs
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment Tip CodeRabbit can scan for known vulnerabilities in your dependencies using OSV Scanner.OSV Scanner will automatically detect and report security vulnerabilities in your project's dependencies. No additional configuration is required. |
JReinhold
left a comment
There was a problem hiding this comment.
Thanks. 🙏 Added a few suggestions.
There was a problem hiding this comment.
Can you move this into the ./helpers file directly?
| onClick={onClick} | ||
| disabled={disabled} | ||
| > | ||
| {label} |
There was a problem hiding this comment.
let's use the children prop here instead of a label prop
Summary
The 'Set X' button pattern was duplicated across four control components in
code/addons/docs/src/blocks/controls/. All four shared the sameButtonprops (ariaLabel={false},variant='outline',size='medium') with only theonClickhandler and label text differing.Closes #34211
Changes
SetValueButton.tsx— a small shared component that acceptsname,storyId,label,onClick, anddisabled<SetValueButton />Bonus: Object's button now consistently uses
variant='outline'andsize='medium', matching the other three controls (previously these props were missing from the Object control's button).Impact
Any future change to the button's appearance, accessibility attributes, or sizing now only needs to be made in one place.
Summary by CodeRabbit