@wordpress/components
Version:
UI components for WordPress.
43 lines (36 loc) • 931 B
text/typescript
/**
* External dependencies
*/
import type { CSSProperties } from 'react';
/**
* Internal dependencies
*/
import type { Props } from './types';
import { space } from '../utils/space';
import { CONFIG } from '../utils';
export function getLineHeight(
adjustLineHeightForInnerControls: Props[ 'adjustLineHeightForInnerControls' ],
lineHeight: CSSProperties[ 'lineHeight' ]
) {
if ( lineHeight ) {
return lineHeight;
}
if ( ! adjustLineHeightForInnerControls ) {
return;
}
let value = `calc(${ CONFIG.controlHeight } + ${ space( 2 ) })`;
switch ( adjustLineHeightForInnerControls ) {
case 'large':
value = `calc(${ CONFIG.controlHeightLarge } + ${ space( 2 ) })`;
break;
case 'small':
value = `calc(${ CONFIG.controlHeightSmall } + ${ space( 2 ) })`;
break;
case 'xSmall':
value = `calc(${ CONFIG.controlHeightXSmall } + ${ space( 2 ) })`;
break;
default:
break;
}
return value;
}