From 8dd786b48cd31e94f3fd16350fb2e4a74a8ef991 Mon Sep 17 00:00:00 2001 From: Lena Morita Date: Sat, 4 Dec 2021 02:19:45 +0900 Subject: [PATCH 01/14] Add story for LineHeightControl --- .../line-height-control/stories/index.js | 32 +++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 packages/block-editor/src/components/line-height-control/stories/index.js diff --git a/packages/block-editor/src/components/line-height-control/stories/index.js b/packages/block-editor/src/components/line-height-control/stories/index.js new file mode 100644 index 0000000000000..a6e12d59eb310 --- /dev/null +++ b/packages/block-editor/src/components/line-height-control/stories/index.js @@ -0,0 +1,32 @@ +/** + * WordPress dependencies + */ +import { useState } from '@wordpress/element'; + +/** + * Internal dependencies + */ +import LineHeightControl from '../'; + +export default { + component: LineHeightControl, + title: 'BlockEditor/LineHeightControl', +}; + +const Template = ( props ) => { + const [ value, setValue ] = useState(); + return ( + <> + +
+

value: { value }

+

type: { typeof value }

+ + ); +}; + +export const Default = Template.bind( {} ); From d0ad242b56fff0c863249ce7f38749f8b43e910e Mon Sep 17 00:00:00 2001 From: Lena Morita Date: Sun, 5 Dec 2021 03:31:58 +0900 Subject: [PATCH 02/14] Keep legacy styling --- .../components/line-height-control/index.js | 44 +++++++++++++++++-- .../line-height-control/stories/index.js | 35 ++++++++++++++- .../components/line-height-control/style.scss | 15 ++++++- 3 files changed, 89 insertions(+), 5 deletions(-) diff --git a/packages/block-editor/src/components/line-height-control/index.js b/packages/block-editor/src/components/line-height-control/index.js index f4b5261b40ace..7ae0438e9fc24 100644 --- a/packages/block-editor/src/components/line-height-control/index.js +++ b/packages/block-editor/src/components/line-height-control/index.js @@ -1,8 +1,16 @@ +/** + * External dependencies + */ +import classNames from 'classnames'; + /** * WordPress dependencies */ import { __ } from '@wordpress/i18n'; -import { TextControl } from '@wordpress/components'; +import { + __experimentalNumberControl as NumberControl, + TextControl, +} from '@wordpress/components'; import { ZERO } from '@wordpress/keycodes'; /** @@ -15,7 +23,8 @@ import { isLineHeightDefined, } from './utils'; -export default function LineHeightControl( { value: lineHeight, onChange } ) { +// TODO: Remove before merging +export function LegacyLineHeightControl( { value: lineHeight, onChange } ) { const isDefined = isLineHeightDefined( lineHeight ); const handleOnKeyDown = ( event ) => { @@ -64,7 +73,7 @@ export default function LineHeightControl( { value: lineHeight, onChange } ) { const value = isDefined ? lineHeight : RESET_VALUE; return ( -
+
); } + +export default function LineHeightControl( { + value: lineHeight, + onChange, + __unstableHasLegacyStyles = true, +} ) { + const isDefined = isLineHeightDefined( lineHeight ); + const value = isDefined ? lineHeight : RESET_VALUE; + + return ( +
+ +
+ ); +} diff --git a/packages/block-editor/src/components/line-height-control/stories/index.js b/packages/block-editor/src/components/line-height-control/stories/index.js index a6e12d59eb310..ac50a2b866be5 100644 --- a/packages/block-editor/src/components/line-height-control/stories/index.js +++ b/packages/block-editor/src/components/line-height-control/stories/index.js @@ -6,7 +6,7 @@ import { useState } from '@wordpress/element'; /** * Internal dependencies */ -import LineHeightControl from '../'; +import LineHeightControl, { LegacyLineHeightControl } from '../'; export default { component: LineHeightControl, @@ -30,3 +30,36 @@ const Template = ( props ) => { }; export const Default = Template.bind( {} ); +Default.args = { + __unstableHasLegacyStyles: true, +}; + +// TODO: Remove before merge +export const TemporaryTest = () => { + const [ value, setValue ] = useState(); + return ( +
+
+

Migrated

+