-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Replace CSS variables with block context approach (#29330)
kses are stripping out the CSS variable inline style for roles without unfiltered_html capabilities. This changes the approach to pass the colors via block context to the inner blocks to be rendered as normal inline color & background-color styles.
- Loading branch information
1 parent
ff0d663
commit 51613ca
Showing
9 changed files
with
130 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
/** | ||
* External dependencies | ||
*/ | ||
import classNames from 'classnames'; | ||
|
||
/** | ||
* WordPress dependencies | ||
*/ | ||
import { InnerBlocks, useBlockProps } from '@wordpress/block-editor'; | ||
|
||
// Social Links block deprecations. | ||
const deprecated = [ | ||
// V1. Remove CSS variable use for colors. | ||
{ | ||
attributes: { | ||
iconColor: { | ||
type: 'string', | ||
}, | ||
customIconColor: { | ||
type: 'string', | ||
}, | ||
iconColorValue: { | ||
type: 'string', | ||
}, | ||
iconBackgroundColor: { | ||
type: 'string', | ||
}, | ||
customIconBackgroundColor: { | ||
type: 'string', | ||
}, | ||
iconBackgroundColorValue: { | ||
type: 'string', | ||
}, | ||
openInNewTab: { | ||
type: 'boolean', | ||
default: false, | ||
}, | ||
size: { | ||
type: 'string', | ||
}, | ||
}, | ||
providesContext: { | ||
openInNewTab: 'openInNewTab', | ||
}, | ||
supports: { | ||
align: [ 'left', 'center', 'right' ], | ||
anchor: true, | ||
}, | ||
save: ( props ) => { | ||
const { | ||
attributes: { | ||
iconBackgroundColorValue, | ||
iconColorValue, | ||
itemsJustification, | ||
size, | ||
}, | ||
} = props; | ||
|
||
const className = classNames( size, { | ||
'has-icon-color': iconColorValue, | ||
'has-icon-background-color': iconBackgroundColorValue, | ||
[ `items-justified-${ itemsJustification }` ]: itemsJustification, | ||
} ); | ||
|
||
const style = { | ||
'--wp--social-links--icon-color': iconColorValue, | ||
'--wp--social-links--icon-background-color': iconBackgroundColorValue, | ||
}; | ||
|
||
return ( | ||
<ul { ...useBlockProps.save( { className, style } ) }> | ||
<InnerBlocks.Content /> | ||
</ul> | ||
); | ||
}, | ||
}, | ||
]; | ||
|
||
export default deprecated; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters