Skip to content

Commit

Permalink
Fix popover positioning
Browse files Browse the repository at this point in the history
  • Loading branch information
talldan committed Oct 27, 2022
1 parent 65a57c0 commit cb5967f
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -229,40 +229,54 @@ export default function BlockAlignmentVisualizer( {
</head>
<body className="editor-styles-wrapper">
{ alignments.map( ( alignment ) => (
<div
<BlockAlignmentVisualizerStep
key={ alignment.name }
className={ classnames(
'block-editor__alignment-visualizer-step',
{
[ `is-content-justification-${ layout.justifyContent }` ]:
layout.justifyContent,
}
) }
>
<div
className={ classnames(
'block-editor__alignment-visualizer-step-inner',
alignment.className
) }
>
<Popover
className="block-editor__alignment-visualizer-step-label-popover"
placement="top-end"
flip
>
<div className="block-editor__alignment-visualizer-step-label">
{ alignment.label }
</div>
</Popover>
</div>
</div>
alignment={ alignment }
justification={ layout.justifyContent }
/>
) ) }
</body>
</Iframe>
</Popover>
);
}

function BlockAlignmentVisualizerStep( { alignment, justification } ) {
const [ popoverAnchor, setPopoverAnchor ] = useState( null );

return (
<>
<div
className={ classnames(
'block-editor__alignment-visualizer-step',
{
[ `is-content-justification-${ justification }` ]:
justification,
}
) }
>
<div
className={ classnames(
'block-editor__alignment-visualizer-step-inner',
alignment.className
) }
ref={ setPopoverAnchor }
/>
</div>
<Popover
anchor={ popoverAnchor }
className="block-editor__alignment-visualizer-step-label-popover"
placement="top-end"
flip
>
<div className="block-editor__alignment-visualizer-step-label">
{ alignment.label }
</div>
</Popover>
</>
);
}

function Iframe( { children, ...props } ) {
const [ iframeDocument, setIframeDocument ] = useState( null );

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
.block-editor__alignment-visualizer-step-label-popover .components-popover__content {
outline: none;
box-shadow: none;
background: none;
}

.block-editor__alignment-visualizer-step-label {
Expand Down

0 comments on commit cb5967f

Please sign in to comment.