import React from 'react' import ImagePicker from './ImagePicker' import ColorPicker from './ColorPicker' import Popout, { managePopout } from './Popout' import { COLORS, DEFAULT_BG_COLOR } from '../lib/constants' import { validateColor } from '../lib/colors' import { capitalize, stringifyRGBA } from '../lib/util' class BackgroundSelect extends React.PureComponent { state = { mounted: false } componentDidMount() { this.setState({ mounted: true }) } selectTab = name => { if (this.props.mode !== name) { this.props.onChange({ backgroundMode: name }) } } handlePickColor = ({ rgb }) => this.props.onChange({ backgroundColor: stringifyRGBA(rgb) }) render() { const { color, mode, image, onChange, aspectRatio, isVisible, toggleVisibility } = this.props const { mounted } = this.state let background = typeof color === 'string' ? color .replace(/&/g, '&') .replace(//g, '>') .replace(/"/g, '"') .replace(/'/g, ''') .replace(/\//g, '/') : color if (!validateColor(background)) { background = DEFAULT_BG_COLOR } return (
) } } export default managePopout(BackgroundSelect)