@wordpress/block-library
Version:
Block library for the WordPress editor.
51 lines (47 loc) • 1.15 kB
JavaScript
/**
* External dependencies
*/
import clsx from 'clsx';
/**
* WordPress dependencies
*/
import {
RichText,
useBlockProps,
useInnerBlocksProps,
__experimentalGetElementClassName,
} from '@wordpress/block-editor';
export default function saveWithInnerBlocks( { attributes } ) {
const {
caption,
showNumbers,
showTracklist,
showArtists,
showTrackLength,
} = attributes;
const blockProps = useBlockProps.save();
const innerBlocksProps = useInnerBlocksProps.save( blockProps );
return (
<figure { ...innerBlocksProps }>
<ol
className={ clsx( 'wp-block-playlist__tracklist', {
'wp-block-playlist__tracklist-is-hidden': ! showTracklist,
'wp-block-playlist__tracklist-artist-is-hidden':
! showArtists,
'wp-block-playlist__tracklist-length-is-hidden':
! showTrackLength,
'wp-block-playlist__tracklist-show-numbers': showNumbers,
} ) }
>
{ innerBlocksProps.children }
</ol>
{ ! RichText.isEmpty( caption ) && (
<RichText.Content
tagName="figcaption"
className={ __experimentalGetElementClassName( 'caption' ) }
value={ caption }
/>
) }
</figure>
);
}