import classnames from 'classnames/dedupe'; import { BlockControls, InspectorControls, useBlockProps, } from '@wordpress/block-editor'; import { PanelBody, SelectControl, TabPanel, ToolbarDropdownMenu, ToolbarGroup, } from '@wordpress/components'; import { applyFilters } from '@wordpress/hooks'; import { __ } from '@wordpress/i18n'; import ApplyFilters from '../../components/apply-filters'; import ColorIndicator from '../../components/color-indicator'; import ColorPicker from '../../components/color-picker'; import IconPicker from '../../components/icon-picker'; import RangeControl from '../../components/range-control'; import getIcon from '../../utils/get-icon'; /** * Block Edit Class. * * @param props */ export default function BlockEdit(props) { const { attributes, setAttributes } = props; let { className = '' } = props; const { type, size, icon, iconSize, color, iconColor, hoverColor, hoverIconColor, } = attributes; className = classnames( 'ghostkit-divider', `ghostkit-divider-type-${type}`, className ); if (icon) { className = classnames(className, 'ghostkit-divider-with-icon'); } className = applyFilters('ghostkit.editor.className', className, props); const blockProps = useBlockProps({ className }); return ( <> setAttributes({ type: 'solid' }), }, { label: __('Dashed', 'ghostkit'), icon: getIcon('border-dashed'), isActive: type === 'dashed', onClick: () => setAttributes({ type: 'dashed' }), }, { label: __('Dotted', 'ghostkit'), icon: getIcon('border-dotted'), isActive: type === 'dotted', onClick: () => setAttributes({ type: 'dotted' }), }, { label: __('Double', 'ghostkit'), icon: getIcon('border-double'), isActive: type === 'double', onClick: () => setAttributes({ type: 'double' }), }, ]} /> setAttributes({ type: value })} __next40pxDefaultSize __nextHasNoMarginBottom /> setAttributes({ size: value })} min={1} max={7} beforeIcon="editor-textcolor" afterIcon="editor-textcolor" allowCustomMax __next40pxDefaultSize __nextHasNoMarginBottom /> setAttributes({ icon: value })} insideInspector /> {icon ? ( setAttributes({ iconSize: value }) } min={10} beforeIcon="editor-textcolor" afterIcon="editor-textcolor" allowCustomMin allowCustomMax __next40pxDefaultSize __nextHasNoMarginBottom /> ) : null} {__('Colors', 'ghostkit')} {icon ? ( ) : null} } initialOpen={false} > {(tabData) => { const isHover = tabData.name === 'hover'; return ( <> setAttributes( isHover ? { hoverColor: val } : { color: val } ) } alpha /> {icon ? ( setAttributes( isHover ? { hoverIconColor: val, } : { iconColor: val } ) } alpha /> ) : null} ); }}
{icon ? (
setAttributes({ icon: value })} value={icon} renderToggle={({ onToggle }) => ( )} />
) : null}
); }