/** * External dependencies */ import { InspectorControls, useBlockProps } 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 { cartOutline, bag, bagAlt } from '@woocommerce/icons'; import { Icon } from '@wordpress/icons'; import { WC_BLOCKS_IMAGE_URL } from '@woocommerce/block-settings'; import { ColorPanel } from '@woocommerce/editor-components/color-panel'; import type { ColorPaletteOption } from '@woocommerce/editor-components/color-panel/types'; /** * Internal dependencies */ import QuantityBadge from './quantity-badge'; import { defaultColorItem } from './utils/defaults'; import { migrateAttributesToColorPanel } from './utils/data'; import './editor.scss'; export interface Attributes { miniCartIcon: 'cart' | 'bag' | 'bag-alt'; addToCartBehaviour: string; hasHiddenPrice: boolean; cartAndCheckoutRenderStyle: boolean; priceColor: ColorPaletteOption; iconColor: ColorPaletteOption; productCountColor: ColorPaletteOption; } 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 }: Props ): ReactElement => { const { cartAndCheckoutRenderStyle, addToCartBehaviour, hasHiddenPrice, priceColor = defaultColorItem, iconColor = defaultColorItem, productCountColor = defaultColorItem, miniCartIcon, } = migrateAttributesToColorPanel( attributes ); const miniCartColorAttributes = { priceColor: { label: __( 'Price', 'woo-gutenberg-products-block' ), context: 'price-color', }, iconColor: { label: __( 'Icon', 'woo-gutenberg-products-block' ), context: 'icon-color', }, productCountColor: { label: __( 'Product Count', 'woo-gutenberg-products-block' ), context: 'product-count-color', }, }; const blockProps = useBlockProps( { className: 'wc-block-mini-cart', } ); const isSiteEditor = isSiteEditorPage( select( 'core/edit-site' ) ); const templatePartEditUri = getSetting( 'templatePartEditUri', '' ) as string; const productCount = 0; const productTotal = 0; return (
{ __( 'When opened, the Mini-Cart drawer gives shoppers quick access to view their selected products and checkout.', 'woo-gutenberg-products-block' ) }