-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
BaseControl: Add opt-in prop for margin-free styles #39325
Conversation
export const StyledHelp = styled.p` | ||
margin-top: ${ space( 2 ) }; |
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.
We can go ahead and add this margin-top regardless of whether StyledField
still has a margin-bottom, because this margin-top will collapse together with StyledField
's margin-bottom anyway.
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.
Makes sense
Size Change: +66 B (0%) Total Size: 1.16 MB
ℹ️ View Unchanged
|
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.
Left a couple of small comments, but overall changes LGTM and test well as per instructions 🚀
<StyledField className="components-base-control__field"> | ||
<StyledField | ||
className="components-base-control__field" | ||
// TODO: Official deprecation for this should start after all internal usages have been migrated |
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.
Official deprecation for this should start after all internal usages have been migrated
👍
@@ -15,13 +14,14 @@ export default { | |||
const BaseControlWithTextarea = ( { id, ...props } ) => { | |||
return ( | |||
<BaseControl id={ id } { ...props }> | |||
<TextareaControl id={ id } /> | |||
<textarea style={ { display: 'block' } } id={ id } /> |
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.
Is there a particular reason why we'd swap the library's component with the vanilla HTML one? Do you think this should be a pattern that we apply to stories across the package?
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.
Haha so when I was working on this PR there was a weird issue I was debugging for half an hour, and I finally realized that TextareaControl
is already built with BaseControl
🤦🏻♀️ 15095fb
return ( | ||
! __nextHasNoMarginBottom && | ||
css` | ||
margin-bottom: revert; |
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.
TIL (or rediscovered) revert
— very cool!
export const StyledHelp = styled.p` | ||
margin-top: ${ space( 2 ) }; |
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.
Makes sense
Co-authored-by: Marco Ciampini <[email protected]>
Also fixes a conflict resolution mishap in #39325
* Divider: Display inline by default when orientation is vertical * Improve type docs for `orientation` * Improve stories * Add changelog entry * Simplify prop types * Fixup changelog Also fixes a conflict resolution mishap in #39325
Part 1 of #38730
Prerequisite for #38720
What?
Adds a
__nextHasNoMarginBottom
prop so consumers can opt-in to the new styles without outer margins.Why?
As described in #38730, components that include outer margins are hard to reuse in different contexts.
How?
Generally follows the style deprecation procedure in the docs, except we aren't formally deprecating the margin styles yet. We should initiate the formal deprecation (i.e. trigger a deprecation warning) only after all internal usages have been migrated.
Testing Instructions
npm run storybook:dev
and check out the stories forBaseControl
.__nextHasNoMarginBottom
istrue
, the component should have no outer bottom margin. (Regardless of whether it includes ahelp
text.)