Skip to content
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

Add margin-bottom lint rules for RangeControl #63821

Merged
merged 2 commits into from
Jul 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,7 @@ module.exports = {
'CheckboxControl',
'ComboboxControl',
'FocalPointPicker',
'RangeControl',
'SearchControl',
'TextareaControl',
'TreeSelect',
Expand Down
2 changes: 2 additions & 0 deletions packages/block-editor/src/layouts/grid.js
Copy link
Member Author

Choose a reason for hiding this comment

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

Testing instructions

Add a Grid block and see the Layout section in the block inspector. Toggle the Grid Item Position to switch between the two RangeControls. No visual changes.

Auto Manual
RangeControl in Grid block, Auto mode RangeControl in Grid block, Manual mode

Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,7 @@ function GridLayoutMinimumWidthControl( { layout, onChange } ) {
</FlexItem>
<FlexItem isBlock>
<RangeControl
__nextHasNoMarginBottom
onChange={ handleSliderChange }
value={ quantity || 0 }
min={ 0 }
Expand Down Expand Up @@ -367,6 +368,7 @@ function GridLayoutColumnsAndRowsControl( {
/>
) : (
<RangeControl
__nextHasNoMarginBottom
value={ columnCount ?? 0 }
onChange={ ( value ) =>
onChange( {
Expand Down
1 change: 1 addition & 0 deletions packages/block-library/src/post-excerpt/edit.js
Copy link
Member Author

Choose a reason for hiding this comment

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

Testing instructions

Add a Post Excerpt block, and see the block inspector. No visual changes.

RangeControl in Post Excerpt block

Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,7 @@ export default function PostExcerptEditor( {
}
/>
<RangeControl
__nextHasNoMarginBottom
label={ __( 'Max number of words' ) }
value={ excerptLength }
onChange={ ( value ) => {
Expand Down
Copy link
Member Author

Choose a reason for hiding this comment

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

Testing instructions

Add a Query block and click the pagination numbers to select the Page Numbers block. See the block inspector.

Before After
RangeControl in Page Numbers, before RangeControl in Page Numbers, after

Excessive margin at the bottom of the help text is slightly reduced.

Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ export default function QueryPaginationNumbersEdit( {
<InspectorControls>
<PanelBody title={ __( 'Settings' ) }>
<RangeControl
__nextHasNoMarginBottom
label={ __( 'Number of links' ) }
help={ __(
'Specify how many links can appear before and after the current page number. Links to the first, current and last page are always visible.'
Expand Down
8 changes: 8 additions & 0 deletions packages/components/src/range-control/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ const MyRangeControl = () => {

return(
<RangeControl
__nextHasNoMarginBottom
label="Columns"
value={ columns }
onChange={ ( value ) => setColumns( value ) }
Expand Down Expand Up @@ -361,6 +362,13 @@ Determines if the `input` number field will render next to the RangeControl. Thi
- Required: No
- Platform: Web

### `__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 collect a numerical input in a text field, use the `TextControl` component.
1 change: 1 addition & 0 deletions packages/components/src/range-control/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -360,6 +360,7 @@ function UnforwardedRangeControl(
* const [ isChecked, setChecked ] = useState( true );
* return (
* <RangeControl
* __nextHasNoMarginBottom
* help="Please select how transparent you would like this."
* initialPosition={50}
* label="Opacity"
Expand Down
Loading