Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/reference-guides/core-blocks.md
Original file line number Diff line number Diff line change
Expand Up @@ -627,7 +627,7 @@ Embed a simple playlist. ([Source](https://github.com/WordPress/gutenberg/tree/t
- **Category:** media
- **Allowed Blocks:** core/playlist-track
- **Supports:** align, anchor, color (background, gradients, link, text), interactivity, spacing (margin, padding)
- **Attributes:** caption, currentTrack, order, showArtists, showImages, showNumbers, showTracklist, type
- **Attributes:** caption, currentTrack, order, showArtists, showImages, showNumbers, showTrackLength, showTracklist, type

## Playlist track

Expand Down
4 changes: 4 additions & 0 deletions packages/block-library/src/playlist/block.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@
"type": "boolean",
"default": true
},
"showTrackLength": {
"type": "boolean",
"default": true
},
"caption": {
"type": "string"
}
Expand Down
22 changes: 22 additions & 0 deletions packages/block-library/src/playlist/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ const PlaylistEdit = ( {
showNumbers,
showImages,
showArtists,
showTrackLength,
currentTrack,
} = attributes;

Expand Down Expand Up @@ -280,6 +281,7 @@ const PlaylistEdit = ( {
showTracklist: true,
showArtists: true,
showNumbers: true,
showTrackLength: true,
showImages: true,
order: 'asc',
} );
Expand Down Expand Up @@ -336,6 +338,24 @@ const PlaylistEdit = ( {
checked={ showNumbers }
/>
</ToolsPanelItem>
<ToolsPanelItem
label={ __( 'Show track length in Tracklist' ) }
isShownByDefault
hasValue={ () => showTrackLength !== true }
onDeselect={ () =>
setAttributes( { showTrackLength: true } )
}
>
<ToggleControl
label={ __(
'Show track length in Tracklist'
) }
onChange={ toggleAttribute(
'showTrackLength'
) }
checked={ showTrackLength }
/>
</ToolsPanelItem>
</>
) }
<ToolsPanelItem
Expand Down Expand Up @@ -387,6 +407,8 @@ const PlaylistEdit = ( {
className={ clsx( 'wp-block-playlist__tracklist', {
'wp-block-playlist__tracklist-show-numbers':
showNumbers,
'wp-block-playlist__tracklist-length-is-hidden':
! showTrackLength,
} ) }
>
{ innerBlocksProps.children }
Expand Down
10 changes: 9 additions & 1 deletion packages/block-library/src/playlist/save.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,13 @@ import {
} from '@wordpress/block-editor';

export default function saveWithInnerBlocks( { attributes } ) {
const { caption, showNumbers, showTracklist, showArtists } = attributes;
const {
caption,
showNumbers,
showTracklist,
showArtists,
showTrackLength,
} = attributes;

const blockProps = useBlockProps.save();
const innerBlocksProps = useInnerBlocksProps.save( blockProps );
Expand All @@ -25,6 +31,8 @@ export default function saveWithInnerBlocks( { attributes } ) {
'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,
} ) }
>
Expand Down
7 changes: 7 additions & 0 deletions packages/block-library/src/playlist/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,13 @@ $waveform-player-height: 100px;
}
}

&.wp-block-playlist__tracklist-length-is-hidden {
// Hide the track length, which is in the playlist-track block.
.wp-block-playlist-track__length {
display: none;
}
}

&.wp-block-playlist__tracklist-show-numbers {
counter-reset: playlist-track;
}
Expand Down
Loading