-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Changes from all commits
349ccc4
15095fb
7560629
dfcaa30
6d7d2f1
9c24d1d
c0e010c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,7 +4,6 @@ | |
import BaseControl from '../'; | ||
import Button from '../../button'; | ||
import { Spacer } from '../../spacer'; | ||
import TextareaControl from '../../textarea-control'; | ||
|
||
export default { | ||
title: 'Components/BaseControl', | ||
|
@@ -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 commentThe 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 commentThe 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 |
||
</BaseControl> | ||
); | ||
}; | ||
|
||
export const Default = BaseControlWithTextarea.bind( {} ); | ||
Default.args = { | ||
__nextHasNoMarginBottom: true, | ||
id: 'textarea-1', | ||
label: '', | ||
hideLabelFromVision: false, | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,8 +15,17 @@ export const Wrapper = styled.div` | |
font-size: ${ font( 'default.fontSize' ) }; | ||
`; | ||
|
||
const deprecatedMarginField = ( { __nextHasNoMarginBottom = false } ) => { | ||
return ( | ||
! __nextHasNoMarginBottom && | ||
css` | ||
margin-bottom: ${ space( 2 ) }; | ||
` | ||
); | ||
}; | ||
|
||
export const StyledField = styled.div` | ||
margin-bottom: ${ space( 2 ) }; | ||
${ deprecatedMarginField } | ||
|
||
.components-panel__row & { | ||
margin-bottom: inherit; | ||
|
@@ -32,10 +41,23 @@ export const StyledLabel = styled.label` | |
${ labelStyles } | ||
`; | ||
|
||
const deprecatedMarginHelp = ( { __nextHasNoMarginBottom = false } ) => { | ||
return ( | ||
! __nextHasNoMarginBottom && | ||
css` | ||
margin-bottom: revert; | ||
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. TIL (or rediscovered) |
||
` | ||
); | ||
}; | ||
|
||
export const StyledHelp = styled.p` | ||
margin-top: ${ space( 2 ) }; | ||
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. We can go ahead and add this margin-top regardless of whether 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. Makes sense |
||
margin-bottom: 0; | ||
font-size: ${ font( 'helpText.fontSize' ) }; | ||
font-style: normal; | ||
color: ${ COLORS.mediumGray.text }; | ||
|
||
${ deprecatedMarginHelp } | ||
`; | ||
|
||
export const StyledVisualLabel = styled.span` | ||
|
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.
👍