From a0ec88565b6f1ddeb89d09b4ad22b47d827eebda Mon Sep 17 00:00:00 2001 From: Pascal Birchler Date: Thu, 2 May 2019 21:39:45 +0200 Subject: [PATCH 01/19] Prevent themes from overriding font sizes in stories --- includes/class-amp-story-post-type.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/includes/class-amp-story-post-type.php b/includes/class-amp-story-post-type.php index ab85742e631..a7562d6cde2 100644 --- a/includes/class-amp-story-post-type.php +++ b/includes/class-amp-story-post-type.php @@ -439,7 +439,7 @@ public static function enqueue_general_styles() { */ public static function filter_block_editor_settings( $editor_settings, $post ) { if ( self::POST_TYPE_SLUG === $post->post_type ) { - unset( $editor_settings['colors'] ); + unset( $editor_settings['fontSizes'], $editor_settings['colors'] ); } if ( get_current_screen()->is_block_editor && isset( $editor_settings['styles'] ) ) { From 489bbe6c9faf569155e2b4428494fb21b2f00507 Mon Sep 17 00:00:00 2001 From: Pascal Birchler Date: Thu, 2 May 2019 22:09:03 +0200 Subject: [PATCH 02/19] Revert de81615e3af6ce79cac8dc09208608d758306d3b --- assets/src/helpers.js | 25 +++---------------------- 1 file changed, 3 insertions(+), 22 deletions(-) diff --git a/assets/src/helpers.js b/assets/src/helpers.js index 318dccb6be6..baad3d1a412 100644 --- a/assets/src/helpers.js +++ b/assets/src/helpers.js @@ -13,7 +13,7 @@ import { count } from '@wordpress/wordcount'; import { __, _x, sprintf } from '@wordpress/i18n'; import { select, dispatch } from '@wordpress/data'; import { createBlock } from '@wordpress/blocks'; -import { getColorClassName, getColorObjectByAttributeValues, RichText } from '@wordpress/block-editor'; +import { getColorClassName, getColorObjectByAttributeValues, getFontSize, RichText } from '@wordpress/block-editor'; /** * Internal dependencies @@ -887,14 +887,14 @@ export const getStylesFromBlockAttributes = ( { } ) => { const textClass = getColorClassName( 'color', textColor ); - const { colors } = select( 'core/block-editor' ).getSettings(); + const { colors, fontSizes } = select( 'core/block-editor' ).getSettings(); /* * Calculate font size using vw to make it responsive. * * Get the font size in px based on the slug with fallback to customFontSize. */ - const userFontSize = fontSize ? getFontSizeFromSlug( fontSize ) : customFontSize; + const userFontSize = fontSize ? getFontSize( fontSizes, fontSize, customFontSize ).size : customFontSize; const fontSizeResponsive = userFontSize && ( ( userFontSize / STORY_PAGE_INNER_WIDTH ) * 100 ).toFixed( 2 ) + 'vw'; const appliedBackgroundColor = getBackgroundColorWithOpacity( colors, backgroundColor, customBackgroundColor, opacity ); @@ -909,25 +909,6 @@ export const getStylesFromBlockAttributes = ( { }; }; -/** - * Get font size from slug. - * - * @param {string} slug Font slug. - * @return {number} Font size in pixels. - */ -const getFontSizeFromSlug = ( slug ) => { - switch ( slug ) { - case 'small': - return 19.5; - case 'large': - return 36.5; - case 'huge': - return 49.5; - default: - return 16; - } -}; - export const getMetaBlockSettings = ( { attribute, placeholder, tagName = 'p', isEditable = false } ) => { const supports = { anchor: true, From bd7d5f0cdda5a805f9cc99af69a90084b5b0c880 Mon Sep 17 00:00:00 2001 From: Ryan Kienstra Date: Thu, 2 May 2019 16:02:10 -0500 Subject: [PATCH 03/19] Remove the inline height styling on the Latest Stores block This seemed to make the height too high. Though more testing might show it was needed. --- includes/class-amp-story-post-type.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/includes/class-amp-story-post-type.php b/includes/class-amp-story-post-type.php index ab85742e631..adc4f98ee7c 100644 --- a/includes/class-amp-story-post-type.php +++ b/includes/class-amp-story-post-type.php @@ -1196,7 +1196,7 @@ public static function render_block_latest_stories( $attributes ) { -