Allow themes to remove the Mini Cart title on overridden template parts (https://github.com/woocommerce/woocommerce-blocks/pull/8779)
* Allow themes to remove the Mini Cart title on overridden template parts * Remove unused file
This commit is contained in:
parent
82c59ffb29
commit
5235f6c392
|
@ -1,5 +0,0 @@
|
|||
const Block = ( { children }: { children: JSX.Element } ): JSX.Element => {
|
||||
return <>{ children }</>;
|
||||
};
|
||||
|
||||
export default Block;
|
|
@ -41,6 +41,7 @@ registerCheckoutBlock( {
|
|||
|
||||
registerCheckoutBlock( {
|
||||
metadata: miniCartTitleMetadata,
|
||||
force: false,
|
||||
component: lazy(
|
||||
() =>
|
||||
import(
|
||||
|
|
|
@ -6,7 +6,6 @@ import { registerBlockComponent } from '@woocommerce/blocks-registry';
|
|||
/**
|
||||
* Internal dependencies
|
||||
*/
|
||||
import type { CheckoutBlockOptions } from './types';
|
||||
import {
|
||||
assertBlockName,
|
||||
assertBlockParent,
|
||||
|
@ -14,6 +13,7 @@ import {
|
|||
assertBlockComponent,
|
||||
} from './utils';
|
||||
import { registeredBlocks } from './registered-blocks';
|
||||
import type { CheckoutBlockOptions } from './types';
|
||||
|
||||
/**
|
||||
* Main API for registering a new checkout block within areas.
|
||||
|
@ -34,6 +34,13 @@ export const registerCheckoutBlock = (
|
|||
component: options.component,
|
||||
} );
|
||||
|
||||
// Infer the `force` value from whether the block is locked or not. But
|
||||
// allow overriding it on block registration.
|
||||
const force =
|
||||
typeof options.force === 'boolean'
|
||||
? options.force
|
||||
: Boolean( options.metadata?.attributes?.lock?.default?.remove );
|
||||
|
||||
/**
|
||||
* Store block metadata for later lookup.
|
||||
*/
|
||||
|
@ -41,6 +48,6 @@ export const registerCheckoutBlock = (
|
|||
blockName: options.metadata.name,
|
||||
metadata: options.metadata,
|
||||
component: options.component,
|
||||
force: !! options.metadata?.attributes?.lock?.default?.remove,
|
||||
force,
|
||||
};
|
||||
};
|
||||
|
|
|
@ -46,6 +46,7 @@ export type RegisteredBlocks = Record< string, RegisteredBlock >;
|
|||
|
||||
export type CheckoutBlockOptions = {
|
||||
metadata: CheckoutBlockOptionsMetadata;
|
||||
force?: boolean;
|
||||
component:
|
||||
| LazyExoticComponent< React.ComponentType< unknown > >
|
||||
| ( () => JSX.Element | null )
|
||||
|
|
Loading…
Reference in New Issue