Skip to content

Commit

Permalink
RangeControl: Add lint rule for 40px size prop usage (#64558)
Browse files Browse the repository at this point in the history
* Fix in Query Loop block

* Fix in Excerpt block

* Fix in Grid block

* Fix in SpacingSizesControl

* Fix in Image block Zoom control

* Fix in HeightControl

* Fix in BorderRadiusControl

* Add lint rule

* Fixup in HeightControl

* Address in ColorPicker

Co-authored-by: mirka <[email protected]>
Co-authored-by: tyxla <[email protected]>
  • Loading branch information
3 people committed Aug 16, 2024
1 parent c459a7b commit 68dd5ce
Show file tree
Hide file tree
Showing 11 changed files with 27 additions and 29 deletions.
1 change: 1 addition & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,7 @@ module.exports = {
'DimensionControl',
'FontSizePicker',
'NumberControl',
'RangeControl',
'ToggleGroupControl',
].map( ( componentName ) => ( {
// Falsy `__next40pxDefaultSize` without a non-default `size` prop.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ export default function BorderRadiusControl( { onChange, values } ) {
units={ units }
/>
<RangeControl
__next40pxDefaultSize
label={ __( 'Border radius' ) }
hideLabelFromVision
className="components-border-radius-control__range-control"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,6 @@
.components-border-radius-control__range-control {
flex: 1;
margin-right: $grid-unit-15;

> div {
height: 40px;
display: flex;
align-items: center;
}
}

> span {
flex: 0 0 auto;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,7 @@ export default function HeightControl( {
<FlexItem isBlock>
<Spacer marginX={ 2 } marginBottom={ 0 }>
<RangeControl
__next40pxDefaultSize
value={ customRangeValue }
min={ 0 }
max={
Expand Down
26 changes: 17 additions & 9 deletions packages/block-editor/src/components/image-editor/zoom-dropdown.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
/**
* WordPress dependencies
*/
import { ToolbarButton, RangeControl, Dropdown } from '@wordpress/components';
import {
ToolbarButton,
RangeControl,
Dropdown,
__experimentalDropdownContentWrapper as DropdownContentWrapper,
} from '@wordpress/components';
import { __ } from '@wordpress/i18n';
import { search } from '@wordpress/icons';

Expand All @@ -27,14 +32,17 @@ export default function ZoomDropdown() {
/>
) }
renderContent={ () => (
<RangeControl
__nextHasNoMarginBottom
label={ __( 'Zoom' ) }
min={ MIN_ZOOM }
max={ MAX_ZOOM }
value={ Math.round( zoom ) }
onChange={ setZoom }
/>
<DropdownContentWrapper paddingSize="medium">
<RangeControl
__next40pxDefaultSize
__nextHasNoMarginBottom
label={ __( 'Zoom' ) }
min={ MIN_ZOOM }
max={ MAX_ZOOM }
value={ Math.round( zoom ) }
onChange={ setZoom }
/>
</DropdownContentWrapper>
) }
/>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,7 @@ export default function SpacingInputControl( {
} }
/>
<RangeControl
__next40pxDefaultSize
onMouseOver={ onMouseOver }
onMouseOut={ onMouseOut }
onFocus={ onMouseOver }
Expand All @@ -270,6 +271,7 @@ export default function SpacingInputControl( {
) }
{ showRangeControl && ! showCustomValueControl && (
<RangeControl
__next40pxDefaultSize
onMouseOver={ onMouseOver }
onMouseOut={ onMouseOut }
className="spacing-sizes-control__range-control"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,7 @@

.spacing-sizes-control__range-control,
.spacing-sizes-control__custom-value-range {
height: 40px;
/* Vertically center the RangeControl until it has true 40px height. */
display: flex;
align-items: center;
margin-bottom: 0;
flex: 1;

> .components-base-control__field {
/* Fixes RangeControl contents when the outer wrapper is flex */
flex: 1;
}
}

.components-range-control__mark {
Expand Down
2 changes: 2 additions & 0 deletions packages/block-editor/src/layouts/grid.js
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,7 @@ function GridLayoutMinimumWidthControl( { layout, onChange } ) {
</FlexItem>
<FlexItem isBlock>
<RangeControl
__next40pxDefaultSize
__nextHasNoMarginBottom
onChange={ handleSliderChange }
value={ quantity || 0 }
Expand Down Expand Up @@ -368,6 +369,7 @@ function GridLayoutColumnsAndRowsControl( {
/>
) : (
<RangeControl
__next40pxDefaultSize
__nextHasNoMarginBottom
value={ columnCount ?? 0 }
onChange={ ( value ) =>
Expand Down
1 change: 1 addition & 0 deletions packages/block-library/src/post-excerpt/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,7 @@ export default function PostExcerptEditor( {
}
/>
<RangeControl
__next40pxDefaultSize
__nextHasNoMarginBottom
label={ __( 'Max number of words' ) }
value={ excerptLength }
Expand Down
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
__next40pxDefaultSize
__nextHasNoMarginBottom
label={ __( 'Number of links' ) }
help={ __(
Expand Down
1 change: 1 addition & 0 deletions packages/components/src/color-picker/input-with-slider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ export const InputWithSlider = ( {
/>
<RangeControl
__nextHasNoMarginBottom
__next40pxDefaultSize
label={ label }
hideLabelFromVision
min={ min }
Expand Down

0 comments on commit 68dd5ce

Please sign in to comment.