Skip to content

Commit

Permalink
make abstract component for styling previews inside dropdowns
Browse files Browse the repository at this point in the history
  • Loading branch information
marekhrabe committed Jul 31, 2019
1 parent c9ecef0 commit 5bc673e
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/**
* WordPress dependencies
*/
import { __ } from '@wordpress/i18n';

/**
* BlockPreviewDropdownWrapper provides styling so you can show Preview inside
* Dropdown components. It expects BlockPreview as a single child.
*
* @param {Object} props Component props.
*
* @return {WPElement} Rendered element.
*/
export default function BlockPreviewDropdownWrapper( { children } ) {
return (
<div className="block-editor-block-preview__dropdown-wrapper">
<div className="block-editor-block-preview__dropdown-wrapper-title">{ __( 'Preview' ) }</div>
{ children }
</div>
);
}
23 changes: 23 additions & 0 deletions packages/block-editor/src/components/block-preview/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,26 @@
}
}
}

.block-editor-block-preview__dropdown-wrapper {
border: $border-width solid $light-gray-500;
box-shadow: $shadow-popover;
background: $white;
position: absolute;
left: 100%;
top: -1px;
bottom: -1px;
width: 300px;
height: auto;
padding: 10px;
display: none;

@include break-medium {
display: block;
}
}

.block-editor-block-preview__dropdown-wrapper-title {
margin-bottom: 10px;
color: $dark-gray-300;
}

0 comments on commit 5bc673e

Please sign in to comment.