Skip to content

Commit

Permalink
Use amp-fit-text component in block edit context
Browse files Browse the repository at this point in the history
  • Loading branch information
westonruter committed Aug 16, 2018
1 parent 4a540a4 commit d4ec3bd
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 4 deletions.
3 changes: 3 additions & 0 deletions assets/css/amp-editor-blocks.css
Expand Up @@ -2,3 +2,6 @@
.is-amp-fit-text + .blocks-font-size > .components-font-size-picker__custom-input {
display: none;
}
.edit-post-visual-editor amp-fit-text p {
font-size: inherit;
}
23 changes: 19 additions & 4 deletions assets/js/amp-editor-blocks.js
Expand Up @@ -284,7 +284,8 @@ var ampEditorBlocks = ( function() { // eslint-disable-line no-unused-vars
var attributes = props.attributes,
name = props.name,
ampLayout,
inspectorControls;
inspectorControls,
WrappedBlockEdit;

ampLayout = attributes.ampLayout;

Expand Down Expand Up @@ -324,11 +325,25 @@ var ampEditorBlocks = ( function() { // eslint-disable-line no-unused-vars
];
}

WrappedBlockEdit = el( BlockEdit, _.extend( {
key: 'original'
}, props ) );

if ( -1 !== component.data.textBlocks.indexOf( name ) && props.attributes.ampFitText ) {
WrappedBlockEdit = el(
'amp-fit-text',
{
'min-font-size': props.attributes.minFont,
'max-font-size': props.attributes.maxFont,
height: props.attributes.height
},
WrappedBlockEdit
);
}

return [
inspectorControls,
el( BlockEdit, _.extend( {
key: 'original'
}, props ) )
WrappedBlockEdit
];
};
};
Expand Down
1 change: 1 addition & 0 deletions includes/admin/class-amp-editor-blocks.php
Expand Up @@ -140,6 +140,7 @@ public function enqueue_block_editor_assets() {
);

wp_enqueue_script( 'amp-mathml' );
wp_enqueue_script( 'amp-fit-text' );
}

wp_enqueue_script(
Expand Down

0 comments on commit d4ec3bd

Please sign in to comment.