diff --git a/edit-post/components/sidebar/block-sidebar/style.scss b/edit-post/components/sidebar/block-sidebar/style.scss index 3ca2bfe2eba338..30e7e33e4f6d80 100644 --- a/edit-post/components/sidebar/block-sidebar/style.scss +++ b/edit-post/components/sidebar/block-sidebar/style.scss @@ -4,9 +4,9 @@ margin: 0 -16px; .components-base-control { - margin: 0 0 1em 0; + margin: 0 0 1.5em 0; &:last-child { - margin-bottom: 0; + margin-bottom: 0.5em; } } diff --git a/packages/block-library/src/style.scss b/packages/block-library/src/style.scss index 78e1f0410e9ca0..8ca793de2c0558 100644 --- a/packages/block-library/src/style.scss +++ b/packages/block-library/src/style.scss @@ -110,11 +110,11 @@ } .has-small-font-size { - font-size: 14px; + font-size: 13px; } .has-regular-font-size { - font-size: 16px; + font-size: 20px; } .has-large-font-size { @@ -122,5 +122,5 @@ } .has-larger-font-size { - font-size: 48px; + font-size: 42px; } diff --git a/packages/components/src/base-control/index.js b/packages/components/src/base-control/index.js index f7b155ef56b460..925914b7824154 100644 --- a/packages/components/src/base-control/index.js +++ b/packages/components/src/base-control/index.js @@ -7,7 +7,8 @@ function BaseControl( { id, label, help, className, children } ) { return (
{ help }
} diff --git a/packages/components/src/base-control/style.scss b/packages/components/src/base-control/style.scss index 6472df6fa23e90..fe065ce93fac58 100644 --- a/packages/components/src/base-control/style.scss +++ b/packages/components/src/base-control/style.scss @@ -1,22 +1,23 @@ .components-base-control { font-family: $default-font; font-size: $default-font-size; -} -.components-base-control__field { - margin-bottom: $grid-size; + .components-base-control__field { + margin-bottom: $grid-size; - .components-panel__row & { - margin-bottom: inherit; + .components-panel__row & { + margin-bottom: inherit; + } } -} -.components-base-control__label { - display: block; - margin-bottom: $grid-size-small; -} + .components-base-control__label { + display: block; + margin-bottom: $grid-size-small; + } -.components-base-control__help { - font-style: italic; - margin-bottom: 0; + .components-base-control__help { + margin-top: -$grid-size; + font-style: italic; + margin-bottom: 0; + } } diff --git a/packages/components/src/font-size-picker/index.js b/packages/components/src/font-size-picker/index.js index e3ba345ca2ff80..2387bc640e6efc 100644 --- a/packages/components/src/font-size-picker/index.js +++ b/packages/components/src/font-size-picker/index.js @@ -6,51 +6,110 @@ import { map } from 'lodash'; /** * WordPress dependencies */ -import { Fragment } from '@wordpress/element'; import { __ } from '@wordpress/i18n'; +import { withInstanceId } from '@wordpress/compose'; /** * Internal dependencies */ +import Dashicon from '../dashicon'; +import BaseControl from '../base-control'; import Button from '../button'; -import ButtonGroup from '../button-group'; +import Dropdown from '../dropdown'; import RangeControl from '../range-control'; +import { NavigableMenu } from '../navigable-container'; + +function FontSizePicker( { + fallbackFontSize, + fontSizes = [], + onChange, + value, + withSlider, +} ) { + const onChangeValue = ( event ) => { + const newValue = event.target.value; + if ( newValue === '' ) { + onChange( undefined ); + return; + } + onChange( Number( newValue ) ); + }; + + const currentFont = fontSizes.find( ( font ) => font.size === value ); -export default function FontSizePicker( { fontSizes = [], fallbackFontSize, value, onChange } ) { return ( -Hello world!
' ); // Change the font size using the sidebar. - const changeSizeButton = await page.waitForXPath( '//button[text()="L"]' ); + await page.click( '.components-font-size-picker__selector' ); + const changeSizeButton = await page.waitForSelector( '.components-button.is-font-large' ); await changeSizeButton.click(); // Make sure the HTML content updated. diff --git a/test/e2e/specs/font-size-picker.test.js b/test/e2e/specs/font-size-picker.test.js index 9792a5735ab1e2..4a55dd3e0dbc83 100644 --- a/test/e2e/specs/font-size-picker.test.js +++ b/test/e2e/specs/font-size-picker.test.js @@ -17,8 +17,9 @@ describe( 'Font Size Picker', () => { await clickBlockAppender(); await page.keyboard.type( 'Paragraph to be made "large"' ); - const largeButton = ( await page.$x( '//*[contains(concat(" ", @class, " "), " components-font-size-picker__buttons ")]//*[text()=\'L\']' ) )[ 0 ]; - await largeButton.click(); + await page.click( '.components-font-size-picker__selector' ); + const changeSizeButton = await page.waitForSelector( '.components-button.is-font-large' ); + await changeSizeButton.click(); // Ensure content matches snapshot. const content = await getEditedPostContent(); @@ -31,7 +32,7 @@ describe( 'Font Size Picker', () => { await page.keyboard.type( 'Paragraph to be made "small"' ); await page.click( '.blocks-font-size .components-range-control__number' ); - await page.keyboard.type( '14' ); + await page.keyboard.type( '13' ); // Ensure content matches snapshot. const content = await getEditedPostContent(); @@ -57,7 +58,10 @@ describe( 'Font Size Picker', () => { await page.keyboard.type( 'Paragraph with font size reset using button' ); await page.click( '.blocks-font-size .components-range-control__number' ); - await page.keyboard.type( '14' ); + await page.keyboard.type( '13' ); + + // Blur the range control + await page.click( '.components-base-control__label' ); const resetButton = ( await page.$x( '//*[contains(concat(" ", @class, " "), " components-font-size-picker__buttons ")]//*[text()=\'Reset\']' ) )[ 0 ]; await resetButton.click(); @@ -72,8 +76,9 @@ describe( 'Font Size Picker', () => { await clickBlockAppender(); await page.keyboard.type( 'Paragraph with font size reset using input field' ); - const largeButton = ( await page.$x( '//*[contains(concat(" ", @class, " "), " components-font-size-picker__buttons ")]//*[text()=\'L\']' ) )[ 0 ]; - await largeButton.click(); + await page.click( '.components-font-size-picker__selector' ); + const changeSizeButton = await page.waitForSelector( '.components-button.is-font-large' ); + await changeSizeButton.click(); await page.click( '.blocks-font-size .components-range-control__number' ); await page.keyboard.press( 'Backspace' );