Skip to content
This repository has been archived by the owner on Feb 23, 2024. It is now read-only.

Commit

Permalink
Allow themes to remove the Mini Cart title on overridden template par…
Browse files Browse the repository at this point in the history
…ts (#8779)

* Allow themes to remove the Mini Cart title on overridden template parts

* Remove unused file
  • Loading branch information
Aljullu authored Mar 22, 2023
1 parent 7b2075b commit 003d2d8
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 7 deletions.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ registerCheckoutBlock( {

registerCheckoutBlock( {
metadata: miniCartTitleMetadata,
force: false,
component: lazy(
() =>
import(
Expand Down
11 changes: 9 additions & 2 deletions packages/checkout/blocks-registry/register-checkout-block.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@ import { registerBlockComponent } from '@woocommerce/blocks-registry';
/**
* Internal dependencies
*/
import type { CheckoutBlockOptions } from './types';
import {
assertBlockName,
assertBlockParent,
assertOption,
assertBlockComponent,
} from './utils';
import { registeredBlocks } from './registered-blocks';
import type { CheckoutBlockOptions } from './types';

/**
* Main API for registering a new checkout block within areas.
Expand All @@ -34,13 +34,20 @@ 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.
*/
registeredBlocks[ options.metadata.name ] = {
blockName: options.metadata.name,
metadata: options.metadata,
component: options.component,
force: !! options.metadata?.attributes?.lock?.default?.remove,
force,
};
};
1 change: 1 addition & 0 deletions packages/checkout/blocks-registry/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 )
Expand Down

0 comments on commit 003d2d8

Please sign in to comment.