Skip to content

Commit

Permalink
Try unlocking kebabCase once
Browse files Browse the repository at this point in the history
  • Loading branch information
ellatrix committed Dec 14, 2023
1 parent d9ea8d0 commit d5c5b6c
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
3 changes: 2 additions & 1 deletion packages/block-editor/src/hooks/font-family.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ import { shouldSkipSerialization } from './utils';
import { TYPOGRAPHY_SUPPORT_KEY } from './typography';
import { unlock } from '../lock-unlock';

const { kebabCase } = unlock( componentsPrivateApis );

export const FONT_FAMILY_SUPPORT_KEY = 'typography.__experimentalFontFamily';

/**
Expand Down Expand Up @@ -68,7 +70,6 @@ function addSaveProps( props, blockType, attributes ) {

// Use TokenList to dedupe classes.
const classes = new TokenList( props.className );
const { kebabCase } = unlock( componentsPrivateApis );
classes.add( `has-${ kebabCase( attributes?.fontFamily ) }-font-family` );
const newClassName = classes.value;
props.className = newClassName ? newClassName : undefined;
Expand Down
5 changes: 2 additions & 3 deletions packages/block-editor/src/hooks/layout.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ import { LAYOUT_DEFINITIONS } from '../layouts/definitions';
import { useBlockSettings, useStyleOverride } from './utils';
import { unlock } from '../lock-unlock';

const { kebabCase } = unlock( componentsPrivateApis );

const layoutBlockSupportKey = 'layout';

function hasLayoutBlockSupport( blockName ) {
Expand All @@ -49,7 +51,6 @@ function hasLayoutBlockSupport( blockName ) {
* @return { Array } Array of CSS classname strings.
*/
export function useLayoutClasses( blockAttributes = {}, blockName = '' ) {
const { kebabCase } = unlock( componentsPrivateApis );
const rootPaddingAlignment = useSelect( ( select ) => {
const { getSettings } = select( blockEditorStore );
return getSettings().__experimentalFeatures
Expand Down Expand Up @@ -349,8 +350,6 @@ function BlockWithLayoutStyles( { block: BlockListBlock, props } ) {
? { ...layout, type: 'constrained' }
: layout || defaultBlockLayout || {};
const layoutClasses = useLayoutClasses( attributes, name );

const { kebabCase } = unlock( componentsPrivateApis );
const selectorPrefix = `wp-container-${ kebabCase( name ) }-layout-`;
// Higher specificity to override defaults from theme.json.
const selector = `.${ selectorPrefix }${ id }.${ selectorPrefix }${ id }`;
Expand Down
3 changes: 2 additions & 1 deletion packages/block-editor/src/hooks/use-typography-props.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ import {
} from '../components/global-styles/typography-utils';
import { unlock } from '../lock-unlock';

const { kebabCase } = unlock( componentsPrivateApis );

/*
* This utility is intended to assist where the serialization of the typography
* block support is being skipped for a block but the typography related CSS
Expand All @@ -34,7 +36,6 @@ import { unlock } from '../lock-unlock';
* @return {Object} Typography block support derived CSS classes & styles.
*/
export function getTypographyClassesAndStyles( attributes, settings ) {
const { kebabCase } = unlock( componentsPrivateApis );
let typographyStyles = attributes?.style?.typography || {};
const fluidTypographySettings =
getFluidTypographyOptionsFromSettings( settings );
Expand Down

0 comments on commit d5c5b6c

Please sign in to comment.