@wordpress/components
Version:
UI components for WordPress.
24 lines (23 loc) • 737 B
JavaScript
/**
* External dependencies
*/
import { colord, extend } from 'colord';
import namesPlugin from 'colord/plugins/names';
extend([namesPlugin]);
/**
* Generating a CSS compliant rgba() color value.
*
* @param {string} hexValue The hex value to convert to rgba().
* @param {number} alpha The alpha value for opacity.
* @return {string} The converted rgba() color value.
*
* @example
* rgba( '#000000', 0.5 )
* // rgba(0, 0, 0, 0.5)
*/
export function rgba() {
let hexValue = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
let alpha = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;
return colord(hexValue).alpha(alpha).toRgbString();
}
//# sourceMappingURL=colors.js.map