Skip to content

Commit

Permalink
position and style button correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
MaggieCabrera committed May 2, 2024
1 parent e118f77 commit 07ae1ee
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 15 deletions.
7 changes: 7 additions & 0 deletions packages/block-editor/src/components/block-tools/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -262,3 +262,10 @@
.is-dragging-components-draggable .components-tooltip {
display: none;
}

/* Add pattern button for zoom-out mode */

.block-editor-button-pattern-inserter .block-editor-block-list__insertion-point-inserter {
left: 50%;
top: 50%;
}
Original file line number Diff line number Diff line change
@@ -1,15 +1,11 @@
/**
* External dependencies
*/
import classnames from 'classnames';

/**
* WordPress dependencies
*/
import { useSelect } from '@wordpress/data';
import { __unstableMotion as motion } from '@wordpress/components';
import { __unstableMotion as motion, Button } from '@wordpress/components';
import { useReducedMotion } from '@wordpress/compose';
import { useEffect, useState } from '@wordpress/element';
import { _x } from '@wordpress/i18n';

/**
* Internal dependencies
Expand Down Expand Up @@ -38,11 +34,6 @@ function ZoomOutModeInserters( { __unstableContentRef } ) {
};
}, [] );

const toggleProps = {
type: 'button',
icon: undefined,
};

const disableMotion = useReducedMotion();
const lineVariants = {
// Initial position starts from the center and invisible.
Expand All @@ -66,6 +57,8 @@ function ZoomOutModeInserters( { __unstableContentRef } ) {
const inserterVariants = {
start: {
scale: disableMotion ? 1 : 0,
translateX: '-50%',
translateY: '-50%',
},
rest: {
scale: 1,
Expand All @@ -87,6 +80,7 @@ function ZoomOutModeInserters( { __unstableContentRef } ) {
previousClientId={ clientId }
nextClientId={ blockOrder[ index + 1 ] }
__unstableContentRef={ __unstableContentRef }
className="block-editor-button-pattern-inserter"
>
<motion.div
layout={ ! disableMotion }
Expand All @@ -105,15 +99,33 @@ function ZoomOutModeInserters( { __unstableContentRef } ) {

<motion.div
variants={ inserterVariants }
className={ classnames(
'block-editor-block-list__insertion-point-inserter'
) }
className="block-editor-block-list__insertion-point-inserter"
>
<Inserter
position="bottom center"
clientId={ blockOrder[ index + 1 ] }
__experimentalIsQuick
{ ...toggleProps }
renderToggle={ ( { disabled, onToggle } ) => {
const label = _x(
'Add pattern',
'Generic label for pattern inserter button'
);

const inserterButton = (
<Button
variant="primary"
size="compact"
className="block-editor-button-pattern-inserter__button"
onClick={ onToggle }
label={ label }
disabled={ disabled }
>
{ label }
</Button>
);

return inserterButton;
} }
/>
</motion.div>
</motion.div>
Expand Down

0 comments on commit 07ae1ee

Please sign in to comment.