import { createElement, Component, createRef, Fragment } from '@wordpress/element' import ColorPickerIris from './color-picker-iris.js' import classnames from 'classnames' export const getNoColorPropFor = option => option.noColorTransparent ? 'transparent' : `CT_CSS_SKIP_RULE` const getLeftForEl = (arrow, el) => { if (!arrow) return if (!el) return const wrapper = arrow.closest('.ct-control').getBoundingClientRect() const modal = arrow.nextElementSibling.getBoundingClientRect() el = el.getBoundingClientRect() arrow = arrow.getBoundingClientRect() return { left: el.left + el.width / 2 - wrapper.left - arrow.width / 2 // top: modal.top - wrapper.top - arrow.height / 2 } } export default class PickerModal extends Component { arrow = createRef() render() { return ( {this.props.el && ( )}
e.nativeEvent.stopImmediatePropagation()}> {!this.props.option.predefined && (
    {[ 'paletteColor1', 'paletteColor2', 'paletteColor3', 'paletteColor4', 'paletteColor5' ].map(color => (
  • this.props.onChange({ ...this.props.value, color: `var(--${color})` }) }>
    { { paletteColor1: 'Color 1', paletteColor2: 'Color 2', paletteColor3: 'Color 3', paletteColor4: 'Color 4', paletteColor5: 'Color 5' }[color] }
  • ))}
{!this.props.option.skipNoColorPill && ( this.props.onChange({ ...this.props.value, color: getNoColorPropFor( this.props.option ) }) } className={classnames('ct-no-color-pill', { active: this.props.value.color === getNoColorPropFor(this.props.option) })}> No Color )}
)} this.props.onChange(v)} value={{ ...this.props.value, color: this.props.value.color === getNoColorPropFor(this.props.option) ? '' : this.props.value.color.indexOf('var') > -1 ? getComputedStyle( document.documentElement ) .getPropertyValue( this.props.value.color .replace(/var\(/, '') .replace(/\)/, '') ) .trim() .replace(/\s/g, '') : this.props.value.color }} />
) } }