Skip to content

Commit

Permalink
Quality: Replace wpKebabCase function with kebabCase function from co…
Browse files Browse the repository at this point in the history
…mponents package (#57038)
  • Loading branch information
t-hamano committed Dec 15, 2023
1 parent b8edcb7 commit 6e30f08
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 41 deletions.
@@ -1,12 +1,13 @@
/**
* External dependencies
* WordPress dependencies
*/
import { paramCase as kebabCase } from 'change-case';
import { privateApis as componentsPrivateApis } from '@wordpress/components';

/**
* Internal dependencies
*/
import { FONT_WEIGHTS, FONT_STYLES } from './constants';
import { unlock } from '../../../../lock-unlock';

export function setUIValuesNeeded( font, extraValues = {} ) {
if ( ! font.name && ( font.fontFamily || font.slug ) ) {
Expand Down Expand Up @@ -129,20 +130,11 @@ export function getDisplaySrcFromFontFace( input, urlPrefix ) {
return src;
}

// This function replicates one behavior of _wp_to_kebab_case().
// Additional context: https://github.com/WordPress/gutenberg/issues/53695
export function wpKebabCase( str ) {
// If a string contains a digit followed by a number, insert a dash between them.
return kebabCase( str ).replace(
/([a-zA-Z])(\d)|(\d)([a-zA-Z])/g,
'$1$3-$2$4'
);
}

export function makeFormDataFromFontFamilies( fontFamilies ) {
const formData = new FormData();
const newFontFamilies = fontFamilies.map( ( family, familyIndex ) => {
family.slug = wpKebabCase( family.slug );
const { kebabCase } = unlock( componentsPrivateApis );
family.slug = kebabCase( family.slug );
if ( family?.fontFace ) {
family.fontFace = family.fontFace.map( ( face, faceIndex ) => {
if ( face.file ) {
Expand Down

This file was deleted.

1 comment on commit 6e30f08

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Flaky tests detected in 6e30f08.
Some tests passed with failed attempts. The failures may not be related to this commit but are still reported for visibility. See the documentation for more information.

🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/7217070664
📝 Reported issues:

Please sign in to comment.