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

Fix: Allow decimals in spacing controls #32692

Merged
merged 2 commits into from Jun 18, 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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/components/src/number-control/index.js
Expand Up @@ -155,7 +155,7 @@ export function NumberControl(
type === inputControlActionTypes.PRESS_ENTER ||
type === inputControlActionTypes.COMMIT
) {
state.value = roundClamp( currentValue, min, max );
state.value = roundClamp( currentValue, min, max, step );
}

return state;
Expand Down
15 changes: 15 additions & 0 deletions packages/components/src/unit-control/utils.js
Expand Up @@ -17,90 +17,105 @@ const allUnits = {
label: isWeb ? 'px' : __( 'Pixels (px)' ),
default: '',
a11yLabel: __( 'Pixels (px)' ),
step: 1,
},
percent: {
value: '%',
label: isWeb ? '%' : __( 'Percentage (%)' ),
default: '',
a11yLabel: __( 'Percent (%)' ),
step: 0.1,
},
em: {
value: 'em',
label: isWeb ? 'em' : __( 'Relative to parent font size (em)' ),
default: '',
a11yLabel: _x( 'ems', 'Relative to parent font size (em)' ),
step: 0.01,
},
rem: {
value: 'rem',
label: isWeb ? 'rem' : __( 'Relative to root font size (rem)' ),
default: '',
a11yLabel: _x( 'rems', 'Relative to root font size (rem)' ),
step: 0.01,
},
vw: {
value: 'vw',
label: isWeb ? 'vw' : __( 'Viewport width (vw)' ),
default: '',
a11yLabel: __( 'Viewport width (vw)' ),
step: 0.1,
},
vh: {
value: 'vh',
label: isWeb ? 'vh' : __( 'Viewport height (vh)' ),
default: '',
a11yLabel: __( 'Viewport height (vh)' ),
step: 0.1,
},
vmin: {
value: 'vmin',
label: isWeb ? 'vmin' : __( 'Viewport smallest dimension (vmin)' ),
default: '',
a11yLabel: __( 'Viewport smallest dimension (vmin)' ),
step: 0.1,
},
vmax: {
value: 'vmax',
label: isWeb ? 'vmax' : __( 'Viewport largest dimension (vmax)' ),
default: '',
a11yLabel: __( 'Viewport largest dimension (vmax)' ),
step: 0.1,
},
ch: {
value: 'ch',
label: isWeb ? 'ch' : __( 'Width of the zero (0) character (ch)' ),
default: '',
a11yLabel: __( 'Width of the zero (0) character (ch)' ),
step: 0.01,
},
ex: {
value: 'ex',
label: isWeb ? 'ex' : __( 'x-height of the font (ex)' ),
default: '',
a11yLabel: __( 'x-height of the font (ex)' ),
step: 0.01,
},
cm: {
value: 'cm',
label: isWeb ? 'cm' : __( 'Centimeters (cm)' ),
default: '',
a11yLabel: __( 'Centimeters (cm)' ),
step: 0.001,
},
mm: {
value: 'mm',
label: isWeb ? 'mm' : __( 'Millimeters (mm)' ),
default: '',
a11yLabel: __( 'Millimeters (mm)' ),
step: 0.1,
},
in: {
value: 'in',
label: isWeb ? 'in' : __( 'Inches (in)' ),
default: '',
a11yLabel: __( 'Inches (in)' ),
step: 0.001,
},
pc: {
value: 'pc',
label: isWeb ? 'pc' : __( 'Picas (pc)' ),
default: '',
a11yLabel: __( 'Picas (pc)' ),
step: 1,
},
pt: {
value: 'pt',
label: isWeb ? 'pt' : __( 'Points (pt)' ),
default: '',
a11yLabel: __( 'Points (pt)' ),
step: 1,
},
};

Expand Down