@gechiui/block-editor
Version:
39 lines (35 loc) • 916 B
JavaScript
/**
* External dependencies
*/
import { isEmpty } from 'lodash';
/**
* GeChiUI dependencies
*/
import { createHigherOrderComponent } from '@gechiui/compose';
/**
* Internal dependencies
*/
import useSetting from '../use-setting';
export default createHigherOrderComponent( ( WrappedComponent ) => {
return ( props ) => {
const colorsFeature = useSetting( 'color.palette' );
const disableCustomColorsFeature = ! useSetting( 'color.custom' );
const colors =
props.colors === undefined ? colorsFeature : props.colors;
const disableCustomColors =
props.disableCustomColors === undefined
? disableCustomColorsFeature
: props.disableCustomColors;
const hasColorsToChoose = ! isEmpty( colors ) || ! disableCustomColors;
return (
<WrappedComponent
{ ...{
...props,
colors,
disableCustomColors,
hasColorsToChoose,
} }
/>
);
};
}, 'withColorContext' );