UNPKG

react-color

Version:

A Collection of Color Pickers from Sketch, Photoshop, Chrome & more

62 lines (56 loc) 1.51 kB
import React from 'react'; import reactCSS, { handleHover } from 'reactcss'; import { Swatch } from '../common'; export var CircleSwatch = function CircleSwatch(_ref) { var color = _ref.color, onClick = _ref.onClick, onSwatchHover = _ref.onSwatchHover, hover = _ref.hover, active = _ref.active, circleSize = _ref.circleSize, circleSpacing = _ref.circleSpacing; var styles = reactCSS({ 'default': { swatch: { width: circleSize, height: circleSize, marginRight: circleSpacing, marginBottom: circleSpacing, transform: 'scale(1)', transition: '100ms transform ease' }, Swatch: { borderRadius: '50%', background: 'transparent', boxShadow: 'inset 0 0 0 ' + (circleSize / 2 + 1) + 'px ' + color, transition: '100ms box-shadow ease' } }, 'hover': { swatch: { transform: 'scale(1.2)' } }, 'active': { Swatch: { boxShadow: 'inset 0 0 0 3px ' + color } } }, { hover: hover, active: active }); return React.createElement( 'div', { style: styles.swatch }, React.createElement(Swatch, { style: styles.Swatch, color: color, onClick: onClick, onHover: onSwatchHover, focusStyle: { boxShadow: styles.Swatch.boxShadow + ', 0 0 5px ' + color } }) ); }; CircleSwatch.defaultProps = { circleSize: 28, circleSpacing: 14 }; export default handleHover(CircleSwatch);