diff --git a/plugins/woocommerce-blocks/assets/js/atomic/blocks/product-elements/title/block.js b/plugins/woocommerce-blocks/assets/js/atomic/blocks/product-elements/title/block.js index 7de86109bb7..a3f42859bac 100644 --- a/plugins/woocommerce-blocks/assets/js/atomic/blocks/product-elements/title/block.js +++ b/plugins/woocommerce-blocks/assets/js/atomic/blocks/product-elements/title/block.js @@ -3,7 +3,6 @@ */ import PropTypes from 'prop-types'; import classnames from 'classnames'; -import { decodeEntities } from '@wordpress/html-entities'; import { useInnerBlockLayoutContext, useProductDataContext, @@ -12,6 +11,7 @@ import { getColorClassName, getFontSizeClass } from '@wordpress/block-editor'; import { isFeaturePluginBuild } from '@woocommerce/block-settings'; import { gatedStyledText } from '@woocommerce/atomic-utils'; import { withProductDataContext } from '@woocommerce/shared-hocs'; +import ProductName from '@woocommerce/base-components/product-name'; /** * Internal dependencies @@ -79,8 +79,6 @@ export const Block = ( { ); } - const productName = decodeEntities( product.name ); - return ( // @ts-ignore - { productLink ? ( - - { productName } - - ) : ( - - { productName } - - ) } + ); }; diff --git a/plugins/woocommerce-blocks/assets/js/base/components/cart-checkout/index.js b/plugins/woocommerce-blocks/assets/js/base/components/cart-checkout/index.js index 8c023666abd..e7b61349b26 100644 --- a/plugins/woocommerce-blocks/assets/js/base/components/cart-checkout/index.js +++ b/plugins/woocommerce-blocks/assets/js/base/components/cart-checkout/index.js @@ -8,7 +8,6 @@ export { default as ProductImage } from './product-image'; export { default as ProductLowStockBadge } from './product-low-stock-badge'; export { default as ProductSummary } from './product-summary'; export { default as ProductMetadata } from './product-metadata'; -export { default as ProductName } from './product-name'; export { default as ProductSaleBadge } from './product-sale-badge'; export { default as ProductVariationData } from './product-variation-data'; export { default as ReturnToCartButton } from './return-to-cart-button'; diff --git a/plugins/woocommerce-blocks/assets/js/base/components/cart-checkout/order-summary/order-summary-item.js b/plugins/woocommerce-blocks/assets/js/base/components/cart-checkout/order-summary/order-summary-item.js index bf192681226..b99e8ea87b4 100644 --- a/plugins/woocommerce-blocks/assets/js/base/components/cart-checkout/order-summary/order-summary-item.js +++ b/plugins/woocommerce-blocks/assets/js/base/components/cart-checkout/order-summary/order-summary-item.js @@ -5,12 +5,12 @@ import { __, sprintf } from '@wordpress/i18n'; import { getCurrency } from '@woocommerce/base-utils'; import Label from '@woocommerce/base-components/label'; import ProductPrice from '@woocommerce/base-components/product-price'; +import ProductName from '@woocommerce/base-components/product-name'; import { ProductBackorderBadge, ProductImage, ProductLowStockBadge, ProductMetadata, - ProductName, } from '@woocommerce/base-components/cart-checkout'; import PropTypes from 'prop-types'; import Dinero from 'dinero.js'; @@ -60,8 +60,8 @@ const OrderSummaryItem = ( { cartItem } ) => {
{ +const ProductName = ( { + className = '', + disabled = false, + name, + permalink = '', + ...props +} ) => { + const classes = classnames( 'wc-block-components-product-name', className ); return disabled ? ( - + { decodeEntities( name ) } ) : ( - + { decodeEntities( name ) } ); }; ProductName.propTypes = { + className: PropTypes.string, disabled: PropTypes.bool, - name: PropTypes.string, + name: PropTypes.string.isRequired, permalink: PropTypes.string, }; diff --git a/plugins/woocommerce-blocks/assets/js/base/components/cart-checkout/product-name/stories/index.js b/plugins/woocommerce-blocks/assets/js/base/components/product-name/stories/index.js similarity index 100% rename from plugins/woocommerce-blocks/assets/js/base/components/cart-checkout/product-name/stories/index.js rename to plugins/woocommerce-blocks/assets/js/base/components/product-name/stories/index.js diff --git a/plugins/woocommerce-blocks/assets/js/base/components/cart-checkout/product-name/style.scss b/plugins/woocommerce-blocks/assets/js/base/components/product-name/style.scss similarity index 69% rename from plugins/woocommerce-blocks/assets/js/base/components/cart-checkout/product-name/style.scss rename to plugins/woocommerce-blocks/assets/js/base/components/product-name/style.scss index ee0f4f26c29..2dd432a9efa 100644 --- a/plugins/woocommerce-blocks/assets/js/base/components/cart-checkout/product-name/style.scss +++ b/plugins/woocommerce-blocks/assets/js/base/components/product-name/style.scss @@ -1,6 +1,4 @@ .wc-block-components-product-name { @include font-size(regular); @include wrap-break-word(); - display: block; - max-width: max-content; } diff --git a/plugins/woocommerce-blocks/assets/js/base/components/cart-checkout/product-name/test/__snapshots__/index.js.snap b/plugins/woocommerce-blocks/assets/js/base/components/product-name/test/__snapshots__/index.js.snap similarity index 71% rename from plugins/woocommerce-blocks/assets/js/base/components/cart-checkout/product-name/test/__snapshots__/index.js.snap rename to plugins/woocommerce-blocks/assets/js/base/components/product-name/test/__snapshots__/index.js.snap index ab05e894d62..2387fff23f0 100644 --- a/plugins/woocommerce-blocks/assets/js/base/components/cart-checkout/product-name/test/__snapshots__/index.js.snap +++ b/plugins/woocommerce-blocks/assets/js/base/components/product-name/test/__snapshots__/index.js.snap @@ -1,5 +1,15 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP +exports[`ProductName should merge classes and props 1`] = ` + + Test product + +`; + exports[`ProductName should not render a link if disabled is true 1`] = ` Test product @@ -19,6 +30,7 @@ exports[`ProductName should render a link if disabled is false 1`] = ` exports[`ProductName should render a link if disabled is not defined 1`] = ` Test product diff --git a/plugins/woocommerce-blocks/assets/js/base/components/cart-checkout/product-name/test/index.js b/plugins/woocommerce-blocks/assets/js/base/components/product-name/test/index.js similarity index 59% rename from plugins/woocommerce-blocks/assets/js/base/components/cart-checkout/product-name/test/index.js rename to plugins/woocommerce-blocks/assets/js/base/components/product-name/test/index.js index 80af75618f0..890a7aafbe9 100644 --- a/plugins/woocommerce-blocks/assets/js/base/components/cart-checkout/product-name/test/index.js +++ b/plugins/woocommerce-blocks/assets/js/base/components/product-name/test/index.js @@ -11,7 +11,7 @@ import ProductName from '..'; describe( 'ProductName', () => { test( 'should not render a link if disabled is true', () => { const component = TestRenderer.create( - + ); expect( component.toJSON() ).toMatchSnapshot(); @@ -19,7 +19,7 @@ describe( 'ProductName', () => { test( 'should render a link if disabled is false', () => { const component = TestRenderer.create( - + ); expect( component.toJSON() ).toMatchSnapshot(); @@ -27,7 +27,20 @@ describe( 'ProductName', () => { test( 'should render a link if disabled is not defined', () => { const component = TestRenderer.create( - + + ); + + expect( component.toJSON() ).toMatchSnapshot(); + } ); + + test( 'should merge classes and props', () => { + const component = TestRenderer.create( + ); expect( component.toJSON() ).toMatchSnapshot(); diff --git a/plugins/woocommerce-blocks/assets/js/blocks/cart-checkout/cart/full-cart/cart-line-item-row.js b/plugins/woocommerce-blocks/assets/js/blocks/cart-checkout/cart/full-cart/cart-line-item-row.js index 59acd9673d2..6a1047ee3e2 100644 --- a/plugins/woocommerce-blocks/assets/js/blocks/cart-checkout/cart/full-cart/cart-line-item-row.js +++ b/plugins/woocommerce-blocks/assets/js/blocks/cart-checkout/cart/full-cart/cart-line-item-row.js @@ -6,6 +6,7 @@ import { __ } from '@wordpress/i18n'; import PropTypes from 'prop-types'; import QuantitySelector from '@woocommerce/base-components/quantity-selector'; import ProductPrice from '@woocommerce/base-components/product-price'; +import ProductName from '@woocommerce/base-components/product-name'; import { getCurrency } from '@woocommerce/base-utils'; import { useStoreCartItemQuantity } from '@woocommerce/base-hooks'; import { Icon, trash } from '@woocommerce/icons'; @@ -14,7 +15,6 @@ import { ProductImage, ProductLowStockBadge, ProductMetadata, - ProductName, ProductSaleBadge, } from '@woocommerce/base-components/cart-checkout'; import Dinero from 'dinero.js'; @@ -116,9 +116,9 @@ const CartLineItemRow = ( { lineItem = {} } ) => { { showBackorderBadge ? ( diff --git a/plugins/woocommerce-blocks/assets/js/blocks/cart-checkout/cart/full-cart/style.scss b/plugins/woocommerce-blocks/assets/js/blocks/cart-checkout/cart/full-cart/style.scss index 6d5862eefca..2d7d03b0a7e 100644 --- a/plugins/woocommerce-blocks/assets/js/blocks/cart-checkout/cart/full-cart/style.scss +++ b/plugins/woocommerce-blocks/assets/js/blocks/cart-checkout/cart/full-cart/style.scss @@ -74,6 +74,10 @@ table.wc-block-cart-items { display: none; } } + .wc-block-components-product-name { + display: block; + max-width: max-content; + } .wc-block-cart-item__total { @include font-size(regular); text-align: right;