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

Post Tags: Feature Parity for Customization #24069

Merged
merged 9 commits into from
Aug 3, 2020
13 changes: 12 additions & 1 deletion packages/block-library/src/post-tags/block.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,20 @@
{
"name": "core/post-tags",
"category": "design",
"attributes": {
"textAlign": {
"type": "string"
}
},
"usesContext": [ "postId", "postType" ],
"supports": {
"html": false,
"lightBlockWrapper": true
"lightBlockWrapper": true,
"__experimentalFontSize": true,
"__experimentalColor": {
"gradients": true,
"linkColor": true
},
"__experimentalLineHeight": true
}
}
36 changes: 33 additions & 3 deletions packages/block-library/src/post-tags/edit.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,24 @@
/**
* External dependencies
*/
import classnames from 'classnames';

/**
* WordPress dependencies
*/
import { useEntityProp } from '@wordpress/core-data';
import { Warning, __experimentalBlock as Block } from '@wordpress/block-editor';
import {
BlockControls,
Warning,
__experimentalBlock as Block,
AlignmentToolbar,
} from '@wordpress/block-editor';
import { useSelect } from '@wordpress/data';
import { __ } from '@wordpress/i18n';

export default function PostTagsEdit( { context } ) {
export default function PostTagsEdit( { context, attributes, setAttributes } ) {
const { textAlign } = attributes;

const [ tags ] = useEntityProp(
'postType',
context.postType,
Expand Down Expand Up @@ -65,5 +77,23 @@ export default function PostTagsEdit( { context } ) {
);
}

return <Block.div>{ display }</Block.div>;
return (
<>
<BlockControls>
<AlignmentToolbar
value={ textAlign }
onChange={ ( nextAlign ) => {
setAttributes( { textAlign: nextAlign } );
} }
/>
</BlockControls>
<Block.div
className={ classnames( {
[ `has-text-align-${ textAlign }` ]: textAlign,
} ) }
>
{ display }
</Block.div>
</>
);
}