Skip to content

Commit

Permalink
Add margin-bottom lint rules for ToggleControl (WordPress#64213)
Browse files Browse the repository at this point in the history
* Fix in ImageSettingsPanel

* Fix in block hooks

* Fix in Avatar block

* Fix in Details block

* Fix in Latest posts block

* Fix in Query Loop block

* Fix in Tag Cloud block

* Fix in Add New Pattern modal

* Fix in Create pattern modal

* Fix in ReusableBlockConvertButton

* Add eslint rule

* Add prop to docs

* Fix up

Co-authored-by: mirka <[email protected]>
Co-authored-by: tyxla <[email protected]>
  • Loading branch information
3 people authored Aug 6, 2024
1 parent 4efb352 commit 0f81a42
Show file tree
Hide file tree
Showing 13 changed files with 21 additions and 0 deletions.
1 change: 1 addition & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,7 @@ module.exports = {
'SearchControl',
'TextControl',
'TextareaControl',
'ToggleControl',
'ToggleGroupControl',
'TreeSelect',
].map( ( componentName ) => ( {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ export default function ImageSettingsPanel( {
panelId={ panelId }
>
<ToggleControl
__nextHasNoMarginBottom
label={ __( 'Expand on click' ) }
checked={ lightboxChecked }
onChange={ onChangeLightbox }
Expand Down
1 change: 1 addition & 0 deletions packages/block-editor/src/hooks/block-hooks.js
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,7 @@ function BlockHooksControlPure( {

return (
<ToggleControl
__nextHasNoMarginBottom
checked={ checked }
key={ block.title }
label={
Expand Down
1 change: 1 addition & 0 deletions packages/block-library/src/avatar/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ const AvatarInspectorControls = ( {
/>
{ attributes.isLink && (
<ToggleControl
__nextHasNoMarginBottom
label={ __( 'Open in new tab' ) }
onChange={ ( value ) =>
setAttributes( {
Expand Down
1 change: 1 addition & 0 deletions packages/block-library/src/details/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ function DetailsEdit( { attributes, setAttributes, clientId } ) {
<InspectorControls>
<PanelBody title={ __( 'Settings' ) }>
<ToggleControl
__nextHasNoMarginBottom
label={ __( 'Open by default' ) }
checked={ showContent }
onChange={ () =>
Expand Down
1 change: 1 addition & 0 deletions packages/block-library/src/latest-posts/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,7 @@ export default function LatestPostsEdit( { attributes, setAttributes } ) {
<InspectorControls>
<PanelBody title={ __( 'Post content' ) }>
<ToggleControl
__nextHasNoMarginBottom
label={ __( 'Post content' ) }
checked={ displayPostContent }
onChange={ ( value ) =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ export default function EnhancedPaginationControl( {
return (
<>
<ToggleControl
__nextHasNoMarginBottom
label={ __( 'Force page reload' ) }
help={ help }
checked={
Expand Down
1 change: 1 addition & 0 deletions packages/block-library/src/tag-cloud/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,7 @@ function TagCloudEdit( { attributes, setAttributes } ) {
required
/>
<ToggleControl
__nextHasNoMarginBottom
label={ __( 'Show tag counts' ) }
checked={ showTagCounts }
onChange={ () =>
Expand Down
9 changes: 9 additions & 0 deletions packages/components/src/toggle-control/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ const MyToggleControl = () => {

return (
<ToggleControl
__nextHasNoMarginBottom
label="Fixed Background"
help={
hasFixedBackground
Expand Down Expand Up @@ -78,3 +79,11 @@ The class that will be added with `components-base-control` and `components-togg

- Type: `String`
- Required: No

### `__nextHasNoMarginBottom`

Start opting into the new margin-free styles that will become the default in a future version.

- Type: `Boolean`
- Required: No
- Default: `false`
1 change: 1 addition & 0 deletions packages/components/src/toggle-control/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ function UnforwardedToggleControl(
*
* return (
* <ToggleControl
* __nextHasNoMarginBottom
* label="Fixed Background"
* checked={ value }
* onChange={ () => setValue( ( state ) => ! state ) }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ export default function InitPatternModal() {
__next40pxDefaultSize
/>
<ToggleControl
__nextHasNoMarginBottom
label={ _x( 'Synced', 'pattern (singular)' ) }
help={ __(
'Sync this pattern across multiple locations.'
Expand Down
1 change: 1 addition & 0 deletions packages/patterns/src/components/create-pattern-modal.js
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ export function CreatePatternModalContents( {
categoryMap={ categoryMap }
/>
<ToggleControl
__nextHasNoMarginBottom
label={ _x( 'Synced', 'pattern (singular)' ) }
help={ __(
'Sync this pattern across multiple locations.'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,7 @@ export default function ReusableBlockConvertButton( {
placeholder={ __( 'My pattern' ) }
/>
<ToggleControl
__nextHasNoMarginBottom
label={ _x( 'Synced', 'pattern (singular)' ) }
help={ __(
'Sync this pattern across multiple locations.'
Expand Down

0 comments on commit 0f81a42

Please sign in to comment.