UNPKG

@gechiui/block-editor

Version:
70 lines (65 loc) 2.17 kB
import _extends from "@babel/runtime/helpers/esm/extends"; import { createElement } from "@gechiui/element"; /** * External dependencies */ import { map } from 'lodash'; /** * Internal dependencies */ import PanelColorSettings from '../panel-color-settings'; import ContrastChecker from '../contrast-checker'; const resolveContrastCheckerColor = (color, colorSettings, detectedColor) => { if (typeof color === 'function') { return color(colorSettings); } else if (color === true) { return detectedColor; } return color; }; export default function ColorPanel(_ref) { let { title, colorSettings, colorPanelProps, contrastCheckers, detectedBackgroundColor, detectedColor, panelChildren, initialOpen } = _ref; return createElement(PanelColorSettings, _extends({ title: title, initialOpen: initialOpen, colorSettings: Object.values(colorSettings) }, colorPanelProps), contrastCheckers && (Array.isArray(contrastCheckers) ? contrastCheckers.map(_ref2 => { let { backgroundColor, textColor, ...rest } = _ref2; backgroundColor = resolveContrastCheckerColor(backgroundColor, colorSettings, detectedBackgroundColor); textColor = resolveContrastCheckerColor(textColor, colorSettings, detectedColor); return createElement(ContrastChecker, _extends({ key: `${backgroundColor}-${textColor}`, backgroundColor: backgroundColor, textColor: textColor }, rest)); }) : map(colorSettings, _ref3 => { let { value } = _ref3; let { backgroundColor, textColor } = contrastCheckers; backgroundColor = resolveContrastCheckerColor(backgroundColor || value, colorSettings, detectedBackgroundColor); textColor = resolveContrastCheckerColor(textColor || value, colorSettings, detectedColor); return createElement(ContrastChecker, _extends({}, contrastCheckers, { key: `${backgroundColor}-${textColor}`, backgroundColor: backgroundColor, textColor: textColor })); })), typeof panelChildren === 'function' ? panelChildren(colorSettings) : panelChildren); } //# sourceMappingURL=color-panel.js.map