-
Notifications
You must be signed in to change notification settings - Fork 4.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
187 additions
and
33 deletions.
There are no files selected for viewing
47 changes: 47 additions & 0 deletions
47
packages/block-editor/src/components/block-styles/block-styles-preview-panel.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
/** | ||
* WordPress dependencies | ||
*/ | ||
import { useMemo } from '@wordpress/element'; | ||
|
||
/** | ||
* Internal dependencies | ||
*/ | ||
import BlockPreview from '../block-preview'; | ||
import { getActiveStyle, replaceActiveStyle } from './utils'; | ||
|
||
export default function BlockStylesPreviewPanel( { | ||
genericPreviewBlock, | ||
viewportWidth, | ||
style, | ||
className, | ||
activeStyle, | ||
} ) { | ||
const styleClassName = replaceActiveStyle( | ||
className, | ||
activeStyle, | ||
style | ||
); | ||
const previewBlocks = useMemo( () => { | ||
return { | ||
...genericPreviewBlock, | ||
attributes: { | ||
...genericPreviewBlock.attributes, | ||
className: styleClassName + ' block-editor-block-styles__block-preview-container', | ||
}, | ||
}; | ||
}, [ genericPreviewBlock, styleClassName ] ); | ||
|
||
return ( | ||
<div className="block-editor-block-styles__preview-container"> | ||
<div className="block-editor-block-styles__preview-content"> | ||
<BlockPreview | ||
viewportWidth={ viewportWidth } | ||
blocks={ previewBlocks } | ||
/> | ||
</div> | ||
<div className="block-editor-block-styles__preview-panel-label"> | ||
{ style.label || style.name } | ||
</div> | ||
</div> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters