Skip to content

Commit

Permalink
Improve util function naming
Browse files Browse the repository at this point in the history
  • Loading branch information
aaronrobertshaw committed Jul 5, 2021
1 parent c3355b1 commit 9bb70c1
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ import { __ } from '@wordpress/i18n';
/**
* Internal dependencies
*/
import { getAllValue, isValuesMixed, isValuesDefined } from './utils';
import { getAllValue, hasMixedValues, hasDefinedValues } from './utils';

export default function AllInputControl( { onChange, values, ...props } ) {
const allValue = getAllValue( values );
const hasValues = isValuesDefined( values );
const isMixed = hasValues && isValuesMixed( values );
const hasValues = hasDefinedValues( values );
const isMixed = hasValues && hasMixedValues( values );
const allPlaceholder = isMixed ? __( 'Mixed' ) : null;

return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ import LinkedButton from './linked-button';
import {
getAllValue,
getAllUnit,
isValuesDefined,
isValuesMixed,
hasDefinedValues,
hasMixedValues,
} from './utils';

const DEFAULT_VALUES = {
Expand All @@ -41,7 +41,7 @@ const MIN_BORDER_RADIUS_VALUE = 0;
*/
export default function BorderRadiusControl( { onChange, values } ) {
const [ isLinked, setIsLinked ] = useState(
! isValuesDefined( values ) || ! isValuesMixed( values )
! hasDefinedValues( values ) || ! hasMixedValues( values )
);

const units = useCustomUnits( { availableUnits: [ 'px', 'em', 'rem' ] } );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ export function getAllValue( values = {} ) {
* @param {Object} values Radius values.
* @return {boolean} Whether values are mixed.
*/
export function isValuesMixed( values = {} ) {
export function hasMixedValues( values = {} ) {
const allValue = getAllValue( values );
const isMixed = isNaN( parseFloat( allValue ) );

Expand All @@ -92,7 +92,7 @@ export function isValuesMixed( values = {} ) {
* @param {Object} values Radius values.
* @return {boolean} Whether values are mixed.
*/
export function isValuesDefined( values ) {
export function hasDefinedValues( values ) {
if ( ! values ) {
return false;
}
Expand Down

0 comments on commit 9bb70c1

Please sign in to comment.