diff --git a/packages/components/src/custom-gradient-picker/constants.js b/packages/components/src/custom-gradient-picker/constants.js index 4a2c509753b36..bb5f826f5ccd4 100644 --- a/packages/components/src/custom-gradient-picker/constants.js +++ b/packages/components/src/custom-gradient-picker/constants.js @@ -11,3 +11,8 @@ export const COLOR_POPOVER_PROPS = { className: 'components-custom-gradient-picker__color-picker-popover', position: 'top', }; +export const DEFAULT_LINEAR_GRADIENT_ANGLE = 180; +export const HORIZONTAL_GRADIENT_ORIENTATION = { + type: 'angular', + value: 90, +}; diff --git a/packages/components/src/custom-gradient-picker/custom-gradient-bar.js b/packages/components/src/custom-gradient-picker/custom-gradient-bar.js new file mode 100644 index 0000000000000..9b7a1a6527ada --- /dev/null +++ b/packages/components/src/custom-gradient-picker/custom-gradient-bar.js @@ -0,0 +1,258 @@ +/** + * External dependencies + */ + +import { some } from 'lodash'; +import classnames from 'classnames'; + +/** + * WordPress dependencies + */ +import { useRef, useReducer, useState } from '@wordpress/element'; +import { plusCircle } from '@wordpress/icons'; + +/** + * Internal dependencies + */ +import Button from '../button'; +import ColorPicker from '../color-picker'; +import Dropdown from '../dropdown'; +import ControlPoints from './control-points'; +import { + INSERT_POINT_WIDTH, + COLOR_POPOVER_PROPS, + MINIMUM_DISTANCE_BETWEEN_POINTS, +} from './constants'; +import { serializeGradient } from './serializer'; +import { + getGradientWithColorAtPositionChanged, + getGradientWithColorStopAdded, + getHorizontalRelativeGradientPosition, + getMarkerPoints, + getGradientParsed, + getLinearGradientRepresentationOfARadial, +} from './utils'; + +function InsertPoint( { + onChange, + gradientAST, + onOpenInserter, + onCloseInserter, + insertPosition, +} ) { + const [ alreadyInsertedPoint, setAlreadyInsertedPoint ] = useState( false ); + return ( + { + onCloseInserter(); + } } + renderToggle={ ( { isOpen, onToggle } ) => ( +