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

Border Support: Add support for custom border units #33315

Merged
merged 3 commits into from
Jul 14, 2021
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
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import { __ } from '@wordpress/i18n';
import AllInputControl from './all-input-control';
import InputControls from './input-controls';
import LinkedButton from './linked-button';
import useSetting from '../use-setting';
import {
getAllValue,
getAllUnit,
Expand Down Expand Up @@ -49,9 +50,11 @@ export default function BorderRadiusControl( { onChange, values } ) {
! hasDefinedValues( values ) || ! hasMixedValues( values )
);

const units = useCustomUnits( { availableUnits: [ 'px', 'em', 'rem' ] } );
const units = useCustomUnits( {
availableUnits: useSetting( 'spacing.units' ) || [ 'px', 'em', 'rem' ],
} );
const unit = getAllUnit( values );
const unitConfig = units.find( ( item ) => item.value === unit );
const unitConfig = units && units.find( ( item ) => item.value === unit );
const step = unitConfig?.step || 1;

const [ allValue ] = parseUnit( getAllValue( values ) );
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
.components-border-style-control {
legend {
line-height: 1.2;
padding-bottom: $grid-unit-05;
}

Expand Down
2 changes: 1 addition & 1 deletion packages/edit-site/src/components/sidebar/border-panel.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ export default function BorderPanel( {
setStyle,
} ) {
const units = useCustomUnits( {
availableUnits: [ 'px', 'em', 'rem' ],
availableUnits: useSetting( 'spacing.units' ) || [ 'px', 'em', 'rem' ],
} );

// Border width.
Expand Down