Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generate classes from preset slugs in the same way (server & client) #32352

Merged
merged 3 commits into from
Jun 1, 2021
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/block-editor/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -371,7 +371,7 @@ _Parameters_

_Returns_

- `string`: String with the class corresponding to the fontSize passed. The class is generated by appending 'has-' followed by fontSizeSlug in kebabCase and ending with '-font-size'.
- `string`: String with the class corresponding to the fontSize passed. The class is generated by appending 'has-' followed by fontSizeSlug and ending with '-font-size'.

<a name="getFontSizeObjectByValue" href="#getFontSizeObjectByValue">#</a> **getFontSizeObjectByValue**

Expand Down
6 changes: 0 additions & 6 deletions packages/block-editor/src/components/colors/test/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,11 +108,5 @@ describe( 'color utils', () => {
getColorClassName( 'background', undefined )
).toBeUndefined();
} );

it( 'should return a class name with the color slug in kebab case', () => {
expect( getColorClassName( 'background', 'Light Purple' ) ).toBe(
oandregal marked this conversation as resolved.
Show resolved Hide resolved
'has-light-purple-background'
);
} );
} );
} );
4 changes: 2 additions & 2 deletions packages/block-editor/src/components/colors/utils.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* External dependencies
*/
import { find, kebabCase, map } from 'lodash';
import { find, map } from 'lodash';
import tinycolor from 'tinycolor2';

/**
Expand Down Expand Up @@ -60,7 +60,7 @@ export function getColorClassName( colorContextName, colorSlug ) {
return undefined;
}

return `has-${ kebabCase( colorSlug ) }-${ colorContextName }`;
return `has-${ colorSlug }-${ colorContextName }`;
}

/**
Expand Down
6 changes: 3 additions & 3 deletions packages/block-editor/src/components/font-sizes/utils.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* External dependencies
*/
import { find, kebabCase } from 'lodash';
import { find } from 'lodash';

/**
* Returns the font size object based on an array of named font sizes and the namedFontSize and customFontSize values.
Expand Down Expand Up @@ -55,12 +55,12 @@ export function getFontSizeObjectByValue( fontSizes, value ) {
* @param {string} fontSizeSlug Slug of the fontSize.
*
* @return {string} String with the class corresponding to the fontSize passed.
* The class is generated by appending 'has-' followed by fontSizeSlug in kebabCase and ending with '-font-size'.
* The class is generated by appending 'has-' followed by fontSizeSlug and ending with '-font-size'.
*/
export function getFontSizeClass( fontSizeSlug ) {
if ( ! fontSizeSlug ) {
return;
}

return `has-${ kebabCase( fontSizeSlug ) }-font-size`;
return `has-${ fontSizeSlug }-font-size`;
}