Skip to content

Commit

Permalink
Add deprecation for the site-tagline block
Browse files Browse the repository at this point in the history
  • Loading branch information
oandregal committed Sep 24, 2021
1 parent 29f9016 commit 846e8de
Show file tree
Hide file tree
Showing 2 changed files with 68 additions and 0 deletions.
66 changes: 66 additions & 0 deletions packages/block-library/src/site-tagline/deprecated.js
@@ -0,0 +1,66 @@
/**
* Internal dependencies
*/
import cleanEmptyObject from '../utils/clean-empty-object';

/**
* Migrates the current style.typography.fontFamily attribute,
* whose value was "var:preset|font-family|helvetica-arial",
* to the style.fontFamily attribute, whose value will be "helvetica-arial".
*
* @param {Object} attributes The current attributes
* @return {Object} The updated attributes.
*/
const oldFontFamilyMigration = ( attributes ) => {
if ( ! attributes?.style?.typography?.fontFamily ) {
return attributes;
}

const fontFamily = attributes.style.typography.fontFamily
.split( '|' )
.pop();
delete attributes.style.typography.fontFamily;
attributes.style = cleanEmptyObject( attributes.style );

return {
...attributes,
fontFamily,
};
};

const deprecated = [
{
attributes: {
textAlign: {
type: 'string',
},
},
supports: {
html: false,
color: {
gradients: true,
},
spacing: {
margin: true,
padding: true,
},
typography: {
fontSize: true,
lineHeight: true,
__experimentalFontFamily: true,
__experimentalFontWeight: true,
__experimentalTextTransform: true,
__experimentalLetterSpacing: true,
},
},
save() {
return null;
},
migrate: oldFontFamilyMigration,
isEligible( { style } ) {
return style?.typography?.fontFamily;
},
},
];

export default deprecated;
2 changes: 2 additions & 0 deletions packages/block-library/src/site-tagline/index.js
Expand Up @@ -4,11 +4,13 @@
import metadata from './block.json';
import edit from './edit';
import icon from './icon';
import deprecated from './deprecated';

const { name } = metadata;
export { metadata, name };

export const settings = {
icon,
edit,
deprecated,
};

0 comments on commit 846e8de

Please sign in to comment.