import React from 'react' import ImagePicker from './ImagePicker' import ColorPicker from './ColorPicker' import Button from './Button' import Popout, { managePopout } from './Popout' import { COLORS, DEFAULT_BG_COLOR } from '../lib/constants' import { stringifyColor } from '../lib/util' function validateColor(str) { if (/#\d{3,6}|rgba{0,1}\(.*?\)/gi.test(str) || /\w+/gi.test(str)) { return str } } class BackgroundSelect extends React.PureComponent { selectTab = name => { if (this.props.mode !== name) { this.props.onChange({ backgroundMode: name }) } } handlePickColor = color => this.props.onChange({ backgroundColor: stringifyColor(color) }) render() { const { color, mode, image, onChange, isVisible, toggleVisibility, carbonRef, updateHighlights, } = this.props const background = validateColor(color) ? color : DEFAULT_BG_COLOR const aspectRatio = carbonRef ? carbonRef.clientWidth / carbonRef.clientHeight : 1 return (
) } } export default managePopout(BackgroundSelect)