From 17b046415ac9baef5e193217a962a20648517c1a Mon Sep 17 00:00:00 2001 From: Riad Benguella Date: Thu, 25 May 2017 16:04:04 +0100 Subject: [PATCH 1/4] Blocks: Animate the controls on appear only - This avois animating the controls when we move the blocks up and down --- editor/modes/visual-editor/block.js | 40 +++++++++++++++++++-------- editor/modes/visual-editor/style.scss | 5 +++- package.json | 1 + 3 files changed, 33 insertions(+), 13 deletions(-) diff --git a/editor/modes/visual-editor/block.js b/editor/modes/visual-editor/block.js index 432fbd5baaef5a..e78f40295ceb96 100644 --- a/editor/modes/visual-editor/block.js +++ b/editor/modes/visual-editor/block.js @@ -5,10 +5,12 @@ import { connect } from 'react-redux'; import classnames from 'classnames'; import { Slot } from 'react-slot-fill'; import { partial } from 'lodash'; +import CSSTransitionGroup from 'react-transition-group/CSSTransitionGroup'; /** * WordPress dependencies */ +import { Children } from 'element'; import Toolbar from 'components/toolbar'; /** @@ -33,6 +35,11 @@ import { isTypingInBlock, } from '../../selectors'; +function FirstChild( { children } ) { + const childrenArray = Children.toArray( children ); + return childrenArray[ 0 ] || null; +} + class VisualEditorBlock extends wp.element.Component { constructor() { super( ...arguments ); @@ -200,18 +207,27 @@ class VisualEditorBlock extends wp.element.Component { > { ( showUI || isHovered ) && } { showUI && -
- - { !! settings.controls && ( - ( { - ...control, - onClick: () => control.onClick( block.attributes, this.setAttributes ), - isActive: control.isActive ? control.isActive( block.attributes ) : false, - } ) ) } /> - ) } - -
+ +
+ + { !! settings.controls && ( + ( { + ...control, + onClick: () => control.onClick( block.attributes, this.setAttributes ), + isActive: control.isActive ? control.isActive( block.attributes ) : false, + } ) ) } /> + ) } + +
+
}
Date: Thu, 25 May 2017 16:36:24 +0100 Subject: [PATCH 2/4] Blocks: Customize blocks controls appearing className --- editor/modes/visual-editor/block.js | 4 ++-- editor/modes/visual-editor/style.scss | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/editor/modes/visual-editor/block.js b/editor/modes/visual-editor/block.js index e78f40295ceb96..a76a55cf76d7a6 100644 --- a/editor/modes/visual-editor/block.js +++ b/editor/modes/visual-editor/block.js @@ -208,9 +208,9 @@ class VisualEditorBlock extends wp.element.Component { { ( showUI || isHovered ) && } { showUI && Date: Fri, 26 May 2017 21:31:46 +0100 Subject: [PATCH 3/4] Blocks: Fix the animation timeout --- editor/modes/visual-editor/block.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/editor/modes/visual-editor/block.js b/editor/modes/visual-editor/block.js index a76a55cf76d7a6..844494b9d7f1a0 100644 --- a/editor/modes/visual-editor/block.js +++ b/editor/modes/visual-editor/block.js @@ -210,7 +210,7 @@ class VisualEditorBlock extends wp.element.Component { Date: Fri, 26 May 2017 22:14:12 +0100 Subject: [PATCH 4/4] Blocks: Change animations classNames to avoid confusion --- editor/modes/visual-editor/block.js | 2 +- editor/modes/visual-editor/style.scss | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/editor/modes/visual-editor/block.js b/editor/modes/visual-editor/block.js index 844494b9d7f1a0..f48ef007115dd6 100644 --- a/editor/modes/visual-editor/block.js +++ b/editor/modes/visual-editor/block.js @@ -208,7 +208,7 @@ class VisualEditorBlock extends wp.element.Component { { ( showUI || isHovered ) && } { showUI &&