/** * External dependencies */ import { InspectorControls, useBlockProps, withColors, __experimentalColorGradientSettingsDropdown as ColorGradientSettingsDropdown, __experimentalUseMultipleOriginColorsAndGradients as useMultipleOriginColorsAndGradients, } from '@wordpress/block-editor'; import { formatPrice } from '@woocommerce/price-format'; import { PanelBody, ExternalLink, ToggleControl, BaseControl, __experimentalToggleGroupControlOption as ToggleGroupControlOption, __experimentalToggleGroupControl as ToggleGroupControl, } from '@wordpress/components'; import { getSetting } from '@woocommerce/settings'; import { __, isRTL } from '@wordpress/i18n'; import Noninteractive from '@woocommerce/base-components/noninteractive'; import { isSiteEditorPage } from '@woocommerce/utils'; import type { ReactElement } from 'react'; import { select } from '@wordpress/data'; import classNames from 'classnames'; import { cartOutline, bag, bagAlt } from '@woocommerce/icons'; import { Icon } from '@wordpress/icons'; import { WC_BLOCKS_IMAGE_URL } from '@woocommerce/block-settings'; /** * Internal dependencies */ import QuantityBadge from './quantity-badge'; import './editor.scss'; interface Attributes { miniCartIcon: 'cart' | 'bag' | 'bag-alt'; addToCartBehaviour: string; hasHiddenPrice: boolean; cartAndCheckoutRenderStyle: boolean; priceColor: string; iconColor: string; productCountColor: string; priceColorValue: string; iconColorValue: string; productCountColorValue: string; } interface Props { attributes: Attributes; setAttributes: ( attributes: Record< string, unknown > ) => void; clientId: number; setPriceColor: ( colorValue: string | undefined ) => void; setIconColor: ( colorValue: string | undefined ) => void; setProductCountColor: ( colorValue: string | undefined ) => void; } const Edit = ( { attributes, setAttributes, clientId, setPriceColor, setIconColor, setProductCountColor, }: Props ): ReactElement => { const { cartAndCheckoutRenderStyle, addToCartBehaviour, hasHiddenPrice, priceColorValue, iconColorValue, productCountColorValue, miniCartIcon, } = attributes; const className = classNames( { 'wc-block-mini-cart': true, 'has-price-color': priceColorValue, 'has-icon-color': iconColorValue, 'has-product-count-color': productCountColorValue, } ); const blockProps = useBlockProps( { className } ); const isSiteEditor = isSiteEditorPage( select( 'core/edit-site' ) ); const templatePartEditUri = getSetting( 'templatePartEditUri', '' ) as string; const productCount = 0; const productTotal = 0; const colorGradientSettings = useMultipleOriginColorsAndGradients(); const colorSettings = [ { value: priceColorValue, onChange: ( colorValue: string ) => { setPriceColor( colorValue ); setAttributes( { priceColorValue: colorValue } ); }, label: __( 'Price', 'woo-gutenberg-products-block' ), resetAllFilter: () => { setPriceColor( undefined ); setAttributes( { priceColorValue: undefined } ); }, }, { value: iconColorValue, onChange: ( colorValue: string ) => { setIconColor( colorValue ); setAttributes( { iconColorValue: colorValue } ); }, label: __( 'Icon', 'woo-gutenberg-products-block' ), resetAllFilter: () => { setIconColor( undefined ); setAttributes( { iconColorValue: undefined } ); }, }, { value: productCountColorValue, onChange: ( colorValue: string ) => { setProductCountColor( colorValue ); setAttributes( { productCountColorValue: colorValue } ); }, label: __( 'Product count', 'woo-gutenberg-products-block' ), resetAllFilter: () => { setProductCountColor( undefined ); setAttributes( { productCountColorValue: undefined } ); }, }, ]; return (
{ __( 'When opened, the Mini-Cart drawer gives shoppers quick access to view their selected products and checkout.', 'woo-gutenberg-products-block' ) }