Skip to content

Commit

Permalink
Do not kebabCase fontFamily slugs.
Browse files Browse the repository at this point in the history
  • Loading branch information
jffng committed Nov 13, 2023
1 parent 01fe4d9 commit ec565b8
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -83,10 +83,12 @@ function getPresetsDeclarations( blockPresets = {}, mergedSettings ) {
if ( presetByOrigin[ origin ] ) {
presetByOrigin[ origin ].forEach( ( value ) => {
if ( valueKey && ! valueFunc ) {
let slug = kebabCase( value.slug );
if ( valueKey === 'fontFamily' ) {
slug = value.slug;
}
declarations.push(
`--wp--preset--${ cssVarInfix }--${ kebabCase(
value.slug
) }: ${ value[ valueKey ] }`
`--wp--preset--${ cssVarInfix }--${ slug }: ${ value[ valueKey ] }`
);
} else if (
valueFunc &&
Expand Down
3 changes: 1 addition & 2 deletions packages/block-editor/src/hooks/font-family.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import TokenList from '@wordpress/token-list';
*/
import { shouldSkipSerialization } from './utils';
import { TYPOGRAPHY_SUPPORT_KEY } from './typography';
import { kebabCase } from '../utils/object';

export const FONT_FAMILY_SUPPORT_KEY = 'typography.__experimentalFontFamily';

Expand Down Expand Up @@ -67,7 +66,7 @@ function addSaveProps( props, blockType, attributes ) {

// Use TokenList to dedupe classes.
const classes = new TokenList( props.className );
classes.add( `has-${ kebabCase( attributes?.fontFamily ) }-font-family` );
classes.add( `has-${ attributes?.fontFamily }-font-family` );
const newClassName = classes.value;
props.className = newClassName ? newClassName : undefined;

Expand Down
3 changes: 1 addition & 2 deletions packages/block-editor/src/hooks/use-typography-props.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import {
getTypographyFontSizeValue,
getFluidTypographyOptionsFromSettings,
} from '../components/global-styles/typography-utils';
import { kebabCase } from '../utils/object';

/*
* This utility is intended to assist where the serialization of the typography
Expand Down Expand Up @@ -43,7 +42,7 @@ export function getTypographyClassesAndStyles( attributes, settings ) {

const style = getInlineStyles( { typography: typographyStyles } );
const fontFamilyClassName = !! attributes?.fontFamily
? `has-${ kebabCase( attributes.fontFamily ) }-font-family`
? `has-${ attributes.fontFamily }-font-family`
: '';

const className = classnames(
Expand Down

0 comments on commit ec565b8

Please sign in to comment.