Skip to content

Commit

Permalink
Add margin-bottom lint rules for CheckboxControl, ComboboxControl, Se…
Browse files Browse the repository at this point in the history
…archControl (#63679)

Co-authored-by: mirka <[email protected]>
Co-authored-by: ciampo <[email protected]>
  • Loading branch information
3 people authored Jul 18, 2024
1 parent c380af5 commit 83f671f
Show file tree
Hide file tree
Showing 9 changed files with 28 additions and 2 deletions.
3 changes: 3 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,10 @@ module.exports = {
...restrictedSyntax,
...restrictedSyntaxComponents,
...[
'CheckboxControl',
'ComboboxControl',
'FocalPointPicker',
'SearchControl',
'TextareaControl',
'TreeSelect',
].map( ( componentName ) => ( {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ export function MediaCategoryPanel( { rootClientId, onInsert, category } ) {
return (
<div className={ baseCssClass }>
<SearchControl
__nextHasNoMarginBottom
className={ `${ baseCssClass }-search` }
onChange={ setSearch }
value={ search }
Expand Down
4 changes: 2 additions & 2 deletions packages/block-editor/src/components/inserter/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -523,11 +523,11 @@ $block-inserter-tabs-height: 44px;
}

.block-editor-inserter__media-panel-search {
margin-bottom: $grid-unit-20;
margin-bottom: $grid-unit-30;
// TODO: Consider using the Theme component to automatically adapt to a gray background.
@include break-medium() {
margin-bottom: 0;
padding: $grid-unit-20 $grid-unit-30 $grid-unit-10;
padding: $grid-unit-20 $grid-unit-30 $grid-unit-20;

&:not(:focus-within) {
--wp-components-color-background: #{$white};
Expand Down
2 changes: 2 additions & 0 deletions packages/block-library/src/form-input/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ function InputFieldBlock( { attributes, setAttributes, className } ) {
<PanelBody title={ __( 'Settings' ) }>
{ 'checkbox' !== type && (
<CheckboxControl
__nextHasNoMarginBottom
label={ __( 'Inline label' ) }
checked={ inlineLabel }
onChange={ ( newVal ) => {
Expand All @@ -48,6 +49,7 @@ function InputFieldBlock( { attributes, setAttributes, className } ) {
/>
) }
<CheckboxControl
__nextHasNoMarginBottom
label={ __( 'Required' ) }
checked={ required }
onChange={ ( newVal ) => {
Expand Down
1 change: 1 addition & 0 deletions packages/block-library/src/page-list/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -319,6 +319,7 @@ export default function PageListEdit( {
{ pagesTree.length > 0 && (
<PanelBody>
<ComboboxControl
__nextHasNoMarginBottom
__next40pxDefaultSize
className="editor-page-attributes__parent"
label={ __( 'Parent' ) }
Expand Down
8 changes: 8 additions & 0 deletions packages/components/src/checkbox-control/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ const MyCheckboxControl = () => {
const [ isChecked, setChecked ] = useState( true );
return (
<CheckboxControl
__nextHasNoMarginBottom
label="Is author"
help="Is the user a author or not?"
checked={ isChecked }
Expand Down Expand Up @@ -102,6 +103,13 @@ If indeterminate is true the state of the checkbox will be indeterminate.

- Required: No

#### `__nextHasNoMarginBottom`: `boolean`

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

- Required: No
- Default: `false`

## Related components

- To select one option from a set, and you want to show all the available options at once, use the `RadioControl` component.
Expand Down
1 change: 1 addition & 0 deletions packages/components/src/checkbox-control/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import type { WordPressComponentProps } from '../context';
* const [ isChecked, setChecked ] = useState( true );
* return (
* <CheckboxControl
* __nextHasNoMarginBottom
* label="Is author"
* help="Is the user a author or not?"
* checked={ isChecked }
Expand Down
9 changes: 9 additions & 0 deletions packages/components/src/combobox-control/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ function MyComboboxControl() {
const [ filteredOptions, setFilteredOptions ] = useState( options );
return (
<ComboboxControl
__nextHasNoMarginBottom
label="Font Size"
value={ fontSize }
onChange={ setFontSize }
Expand Down Expand Up @@ -117,6 +118,14 @@ Custom renderer invoked for each option in the suggestion list. The render prop
- Type: `( args: { item: object } ) => ReactNode`
- 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`

## Related components

- Like this component, but without a search input, the [`CustomSelectControl`](https://developer.wordpress.org/block-editor/reference-guides/components/custom-select-control/) component.
Expand Down
1 change: 1 addition & 0 deletions packages/components/src/combobox-control/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ const getIndexOfMatchingSuggestion = (
* const [ filteredOptions, setFilteredOptions ] = useState( options );
* return (
* <ComboboxControl
* __nextHasNoMarginBottom
* label="Font Size"
* value={ fontSize }
* onChange={ setFontSize }
Expand Down

1 comment on commit 83f671f

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Flaky tests detected in 83f671f.
Some tests passed with failed attempts. The failures may not be related to this commit but are still reported for visibility. See the documentation for more information.

🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/9989077204
📝 Reported issues:

Please sign in to comment.