-
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
ComboboxControl: Add lint rule for 40px size prop usage #64560
Changes from 3 commits
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 |
---|---|---|
|
@@ -66,5 +66,6 @@ | |
"clientNavigation": true | ||
} | ||
}, | ||
"editorStyle": "wp-block-post-author-editor", | ||
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. Why is this change needed? 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. It's necessary because we're readding the editor style file and we want it to be taken into consideration when previewing the blocks in the editor. |
||
"style": "wp-block-post-author" | ||
} |
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -18,6 +18,7 @@ import { | |||||
PanelBody, | ||||||
SelectControl, | ||||||
ToggleControl, | ||||||
__experimentalVStack as VStack, | ||||||
} from '@wordpress/components'; | ||||||
import { useSelect, useDispatch } from '@wordpress/data'; | ||||||
import { __ } from '@wordpress/i18n'; | ||||||
|
@@ -100,74 +101,82 @@ function PostAuthorEdit( { | |||||
<> | ||||||
<InspectorControls> | ||||||
<PanelBody title={ __( 'Settings' ) }> | ||||||
{ showAuthorControl && | ||||||
( ( showCombobox && ( | ||||||
<ComboboxControl | ||||||
__nextHasNoMarginBottom | ||||||
label={ __( 'Author' ) } | ||||||
options={ authorOptions } | ||||||
value={ authorId } | ||||||
onChange={ handleSelect } | ||||||
allowReset={ false } | ||||||
/> | ||||||
) ) || ( | ||||||
<VStack | ||||||
spacing={ 4 } | ||||||
className="wp-block-post-author__inspector-settings" | ||||||
> | ||||||
{ showAuthorControl && | ||||||
( ( showCombobox && ( | ||||||
<ComboboxControl | ||||||
__next40pxDefaultSize | ||||||
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. The spacing gets messed up when a ComboboxControl enters the mix, because it has an additional div wrapper outside the BaseControl. The auto margin added to BaseControls by the block inspector interprets this as a So here we add a
Looks like this when 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.
:hug: |
||||||
__nextHasNoMarginBottom | ||||||
label={ __( 'Author' ) } | ||||||
options={ authorOptions } | ||||||
value={ authorId } | ||||||
onChange={ handleSelect } | ||||||
allowReset={ false } | ||||||
/> | ||||||
) ) || ( | ||||||
<SelectControl | ||||||
__next40pxDefaultSize | ||||||
__nextHasNoMarginBottom | ||||||
label={ __( 'Author' ) } | ||||||
value={ authorId } | ||||||
options={ authorOptions } | ||||||
onChange={ handleSelect } | ||||||
/> | ||||||
) ) } | ||||||
<ToggleControl | ||||||
__nextHasNoMarginBottom | ||||||
label={ __( 'Show avatar' ) } | ||||||
checked={ showAvatar } | ||||||
onChange={ () => | ||||||
setAttributes( { showAvatar: ! showAvatar } ) | ||||||
} | ||||||
/> | ||||||
{ showAvatar && ( | ||||||
<SelectControl | ||||||
__next40pxDefaultSize | ||||||
__nextHasNoMarginBottom | ||||||
label={ __( 'Author' ) } | ||||||
value={ authorId } | ||||||
options={ authorOptions } | ||||||
onChange={ handleSelect } | ||||||
label={ __( 'Avatar size' ) } | ||||||
value={ attributes.avatarSize } | ||||||
options={ avatarSizes } | ||||||
onChange={ ( size ) => { | ||||||
setAttributes( { | ||||||
avatarSize: Number( size ), | ||||||
} ); | ||||||
} } | ||||||
/> | ||||||
) ) } | ||||||
<ToggleControl | ||||||
__nextHasNoMarginBottom | ||||||
label={ __( 'Show avatar' ) } | ||||||
checked={ showAvatar } | ||||||
onChange={ () => | ||||||
setAttributes( { showAvatar: ! showAvatar } ) | ||||||
} | ||||||
/> | ||||||
{ showAvatar && ( | ||||||
<SelectControl | ||||||
__next40pxDefaultSize | ||||||
) } | ||||||
<ToggleControl | ||||||
__nextHasNoMarginBottom | ||||||
label={ __( 'Avatar size' ) } | ||||||
value={ attributes.avatarSize } | ||||||
options={ avatarSizes } | ||||||
onChange={ ( size ) => { | ||||||
setAttributes( { | ||||||
avatarSize: Number( size ), | ||||||
} ); | ||||||
} } | ||||||
label={ __( 'Show bio' ) } | ||||||
checked={ showBio } | ||||||
onChange={ () => | ||||||
setAttributes( { showBio: ! showBio } ) | ||||||
} | ||||||
/> | ||||||
) } | ||||||
<ToggleControl | ||||||
__nextHasNoMarginBottom | ||||||
label={ __( 'Show bio' ) } | ||||||
checked={ showBio } | ||||||
onChange={ () => | ||||||
setAttributes( { showBio: ! showBio } ) | ||||||
} | ||||||
/> | ||||||
<ToggleControl | ||||||
__nextHasNoMarginBottom | ||||||
label={ __( 'Link author name to author page' ) } | ||||||
checked={ isLink } | ||||||
onChange={ () => setAttributes( { isLink: ! isLink } ) } | ||||||
/> | ||||||
{ isLink && ( | ||||||
<ToggleControl | ||||||
__nextHasNoMarginBottom | ||||||
label={ __( 'Open in new tab' ) } | ||||||
onChange={ ( value ) => | ||||||
setAttributes( { | ||||||
linkTarget: value ? '_blank' : '_self', | ||||||
} ) | ||||||
label={ __( 'Link author name to author page' ) } | ||||||
checked={ isLink } | ||||||
onChange={ () => | ||||||
setAttributes( { isLink: ! isLink } ) | ||||||
} | ||||||
checked={ linkTarget === '_blank' } | ||||||
/> | ||||||
) } | ||||||
{ isLink && ( | ||||||
<ToggleControl | ||||||
__nextHasNoMarginBottom | ||||||
label={ __( 'Open in new tab' ) } | ||||||
onChange={ ( value ) => | ||||||
setAttributes( { | ||||||
linkTarget: value ? '_blank' : '_self', | ||||||
} ) | ||||||
} | ||||||
checked={ linkTarget === '_blank' } | ||||||
/> | ||||||
) } | ||||||
</VStack> | ||||||
</PanelBody> | ||||||
</InspectorControls> | ||||||
|
||||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
.wp-block-post-author__inspector-settings { | ||
// Counteract the margin added by the block inspector. | ||
.components-base-control, | ||
.components-base-control:last-child { | ||
margin-bottom: 0; | ||
} | ||
} |
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.