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
1 change: 0 additions & 1 deletion packages/block-library/src/playlist-track/block.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,5 @@
},
"reusable": false
},
"editorStyle": "wp-block-playlist-track-editor",
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This file doesn't exist

"style": "wp-block-playlist-track"
}
45 changes: 23 additions & 22 deletions packages/block-library/src/playlist-track/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -230,38 +230,39 @@ const PlaylistTrackEdit = ( { attributes, setAttributes, context } ) => {
</InspectorControls>
<li { ...blockProps }>
{ !! temporaryURL && <Spinner /> }
<Button
<button
className="wp-block-playlist-track__button"
__next40pxDefaultSize
data-wp-context={ JSON.stringify( { uniqueId } ) }
aria-current={
currentTrack === uniqueId ? 'true' : 'false'
}
>
<RichText
tagName="span"
className="wp-block-playlist-track__title"
value={ title }
placeholder={ __( 'Add title' ) }
onChange={ ( value ) => {
setAttributes( { title: value } );
} }
allowedFormats={ [] }
withoutInteractiveFormatting
/>
{ showArtists && (
<span className="wp-block-playlist-track__content">
<RichText
tagName="span"
className="wp-block-playlist-track__artist"
value={ artist }
placeholder={ __( 'Add artist' ) }
onChange={ ( value ) =>
setAttributes( { artist: value } )
}
className="wp-block-playlist-track__title"
value={ title }
placeholder={ __( 'Add title' ) }
onChange={ ( value ) => {
setAttributes( { title: value } );
} }
allowedFormats={ [] }
withoutInteractiveFormatting
/>
) }
{ showArtists && (
<RichText
tagName="span"
className="wp-block-playlist-track__artist"
value={ artist }
placeholder={ __( 'Add artist' ) }
onChange={ ( value ) =>
setAttributes( { artist: value } )
}
allowedFormats={ [] }
withoutInteractiveFormatting
/>
) }
</span>
<span className="wp-block-playlist-track__length">
{ length && (
<span className="screen-reader-text">
Expand All @@ -276,7 +277,7 @@ const PlaylistTrackEdit = ( { attributes, setAttributes, context } ) => {
<span className="screen-reader-text">
{ __( 'Select to play this track' ) }
</span>
</Button>
</button>
</li>
</>
);
Expand Down
12 changes: 6 additions & 6 deletions packages/block-library/src/playlist-track/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,19 +35,19 @@ function render_block_core_playlist_track( $attributes ) {
$html = '<li ' . $wrapper_attributes . '>';
$html .= '<button ' . $context . 'data-wp-on--click="actions.changeTrack" data-wp-bind--aria-current="state.isCurrentTrack" class="wp-block-playlist-track__button">';

$html .= '<span class="wp-block-playlist-track__content">';
if ( $title ) {
$html .= '<span class="wp-block-playlist-track__title">' . wp_kses_post( $title ) . '</span>';
}
if ( $artist ) {
$html .= '<span class="wp-block-playlist-track__artist">' . wp_kses_post( $artist ) . '</span>';
}
$html .= '</span>';

if ( $length ) {
$html .= '<span class="wp-block-playlist-track__length">' .
sprintf(
/* translators: %s: track length in minutes:seconds */
'<span class="screen-reader-text">' . esc_html__( 'Length: %s' ) . ' </span>',
$length
);
$html .= '<span class="wp-block-playlist-track__length">';
$html .= '<span class="screen-reader-text">' . esc_html__( 'Length:' ) . ' </span>';
$html .= esc_html( $length );
$html .= '</span>';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@scruffian I believe this change makes it difficult to translate it correctly in for example, korean? I don't think we can assume that the number should be after the text in all languages.

@SergeyBiryukov may know for sure.

}

Expand Down
59 changes: 42 additions & 17 deletions packages/block-library/src/playlist-track/style.scss
Original file line number Diff line number Diff line change
@@ -1,33 +1,58 @@
@use "@wordpress/base-styles/variables" as *;

.wp-block-playlist-track {
border-bottom: 1px solid color-mix(in srgb, currentColor 20%, transparent);
padding: $grid-unit-10;
&:has([aria-current="true"]) {
background-color: color-mix(in srgb, currentColor 10%, transparent);
}

&:hover {
background-color: color-mix(in srgb, currentColor 15%, transparent);
}

.wp-block-playlist__tracklist-show-numbers & {
counter-increment: playlist-track;
}

.wp-block-playlist-track__button {
display: flex;
flex-wrap: wrap;
height: auto;
min-width: 100%;
padding: 0;
font-size: 14px;
align-items: center;
width: 100%;
padding: var(--wp--preset--spacing--20, 0.5em);
font-size: inherit;
font-family: inherit;
text-align: left; // Override default button text-align.
line-height: 1.5;
text-align: left;
background-color: transparent;
color: inherit;
border: 0;
border-radius: 1px;
outline-offset: 2px;
cursor: pointer;

.wp-block-playlist__tracklist-show-numbers &::before {
content: counter(playlist-track);
width: 2ch;
margin-right: var(--wp--preset--spacing--20, 0.5em);
font-size: 0.85em;
opacity: 0.7;
}

.wp-block-playlist-track__content {
flex: 1 1 0;
min-width: 0;
}

span {
margin-right: $grid-unit-10;
.wp-block-playlist-track__title {
display: block;
}

.wp-block-playlist-track__artist {
display: block;
font-size: 0.85em;
opacity: 0.7;
margin-top: 0.125em;
}

.wp-block-playlist-track__length {
margin-left: auto;
}
&[aria-current="true"] {
font-weight: 600;
font-size: 0.85em;
opacity: 0.7;
}
}
}
10 changes: 7 additions & 3 deletions packages/block-library/src/playlist/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,6 @@ const PlaylistEdit = ( {
showImages,
showArtists,
currentTrack,
tagName: TagName = showNumbers ? 'ol' : 'ul',
} = attributes;
const [ trackListIndex, setTrackListIndex ] = useState( 0 );
const blockProps = useBlockProps();
Expand Down Expand Up @@ -506,9 +505,14 @@ const PlaylistEdit = ( {
/>
</Disabled>
{ showTracklist && (
<TagName className="wp-block-playlist__tracklist">
<ol
className={ clsx( 'wp-block-playlist__tracklist', {
'wp-block-playlist__tracklist-show-numbers':
showNumbers,
} ) }
>
{ innerBlocksProps.children }
</TagName>
</ol>
) }
<Caption
attributes={ attributes }
Expand Down
13 changes: 4 additions & 9 deletions packages/block-library/src/playlist/save.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,27 +14,22 @@ import {
} from '@wordpress/block-editor';

export default function saveWithInnerBlocks( { attributes } ) {
const {
caption,
showNumbers,
showTracklist,
showArtists,
tagName: TagName = showNumbers ? 'ol' : 'ul',
} = attributes;
const { caption, showNumbers, showTracklist, showArtists } = attributes;

const blockProps = useBlockProps.save();
const innerBlocksProps = useInnerBlocksProps.save( blockProps );
return (
<figure { ...innerBlocksProps }>
<TagName
<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-show-numbers': showNumbers,
} ) }
>
{ innerBlocksProps.children }
</TagName>
</ol>
{ ! RichText.isEmpty( caption ) && (
<RichText.Content
tagName="figcaption"
Expand Down
42 changes: 12 additions & 30 deletions packages/block-library/src/playlist/style.scss
Original file line number Diff line number Diff line change
@@ -1,51 +1,38 @@
@use "@wordpress/base-styles/variables" as *;

.wp-block-playlist {
padding: $grid-unit-20;

.wp-block-playlist__current-item {
display: flex;
align-items: center;
gap: var(--Spacing-6, 24px);
gap: var(--wp--preset--spacing--40, 1.5em);
align-self: stretch;
padding-bottom: $grid-unit-20;
border-bottom: 1px solid color-mix(in srgb, currentColor 20%, transparent);
margin-bottom: $grid-unit-20;

img {
border-radius: 2px;
}
padding-bottom: var(--wp--preset--spacing--30, 1em);
margin-bottom: var(--wp--preset--spacing--30, 1em);

div {
display: flex;
flex-direction: column;
align-items: flex-start;
gap: 8px;
gap: var(--wp--preset--spacing--20, 0.5em);
}

& .wp-block-playlist__current-item-artist-album {
flex-direction: row;
font-weight: 400;
font-size: 16px;
}

.wp-block-playlist__item-title {
font-weight: 600;
word-break: break-all;
}

.wp-block-playlist__item-album {
font-style: italic;
}
}

audio {
width: 100%;
margin-top: 10px;
margin-top: var(--wp--preset--spacing--20, 0.625em);
}

.wp-block-playlist__tracklist {
font-size: 14px;
margin: 0;
padding-left: 0;
list-style: none;

&.wp-block-playlist__tracklist-is-hidden {
display: none;
Expand All @@ -57,19 +44,14 @@
display: none;
}
}
}

ul.wp-block-playlist__tracklist {
padding-left: 0;
list-style: none;
}

ol.wp-block-playlist__tracklist {
padding-left: $grid-unit-20;
&.wp-block-playlist__tracklist-show-numbers {
counter-reset: playlist-track;
}
}

li.block-list-appender.block-list-appender {
position: initial;
margin-top: $grid-unit-20;
margin-top: var(--wp--preset--spacing--30, 1em);
}
}
Loading