Repository navigation
Move styles into specific waveform styles dropdown area #80060
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 |
|---|---|---|
|
|
@@ -140,6 +140,7 @@ const StylesTab = ( { | |
| label={ __( 'Background' ) } | ||
| className="background-block-support-panel__inner-wrapper" | ||
| /> | ||
| <InspectorControls.Slot group="styles" /> | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Reverted in #80111 |
||
| <InspectorControls.Slot group="filter" /> | ||
| <InspectorControls.Slot | ||
| group="layout" | ||
|
|
@@ -159,7 +160,6 @@ const StylesTab = ( { | |
| className="elements-block-support-panel__inner-wrapper" | ||
| /> | ||
| <PositionControls /> | ||
| <InspectorControls.Slot group="styles" /> | ||
| </> | ||
| ) } | ||
| </> | ||
|
|
||
This file contains hidden or 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 hidden or 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 hidden or 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 |
|---|---|---|
|
|
@@ -41,6 +41,15 @@ import { PlaylistContext } from './context'; | |
| import { getTrackAttributes } from './utils'; | ||
|
|
||
| const ALLOWED_MEDIA_TYPES = [ 'audio' ]; | ||
| const DEFAULT_WAVEFORM_STYLE = 'bars'; | ||
| const WAVEFORM_STYLE_OPTIONS = [ | ||
| { label: __( 'Bars' ), value: 'bars' }, | ||
| { label: __( 'Mirror' ), value: 'mirror' }, | ||
| { label: __( 'Line' ), value: 'line' }, | ||
| { label: __( 'Blocks' ), value: 'blocks' }, | ||
| { label: __( 'Dots' ), value: 'dots' }, | ||
| { label: __( 'Seekbar' ), value: 'seekbar' }, | ||
| ]; | ||
|
Comment on lines
+45
to
+52
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's not immediately clear what these terms refer to, so I think we need to add a translation context. |
||
|
|
||
| const PlaylistEdit = ( { | ||
| attributes, | ||
|
|
@@ -56,12 +65,11 @@ const PlaylistEdit = ( { | |
| showImages, | ||
| showArtists, | ||
| showTrackLength, | ||
| waveformStyle = DEFAULT_WAVEFORM_STYLE, | ||
| } = attributes; | ||
|
|
||
| // Extract the waveform style from the block style variation class. | ||
| const waveformStyle = | ||
| attributes.className?.match( /is-style-([\w-]+)/ )?.[ 1 ] || 'bars'; | ||
| const blockProps = useBlockProps(); | ||
| const waveformPanelId = `${ clientId }-waveform`; | ||
| const { replaceInnerBlocks } = useDispatch( blockEditorStore ); | ||
| const { createErrorNotice } = useDispatch( noticesStore ); | ||
| const dropdownMenuProps = useToolsPanelDropdownMenuProps(); | ||
|
|
@@ -189,6 +197,18 @@ const PlaylistEdit = ( { | |
| }; | ||
| } | ||
|
|
||
| const onChangeWaveformStyle = useCallback( | ||
| ( newWaveformStyle ) => { | ||
| setAttributes( { | ||
| waveformStyle: | ||
| newWaveformStyle === DEFAULT_WAVEFORM_STYLE | ||
| ? undefined | ||
| : newWaveformStyle, | ||
| } ); | ||
| }, | ||
| [ setAttributes ] | ||
| ); | ||
|
|
||
| const hasSelectedChild = useSelect( | ||
| ( select ) => | ||
| select( blockEditorStore ).hasSelectedInnerBlock( clientId ), | ||
|
|
@@ -358,6 +378,37 @@ const PlaylistEdit = ( { | |
| </ToolsPanelItem> | ||
| </ToolsPanel> | ||
| </InspectorControls> | ||
| <InspectorControls group="styles"> | ||
| <ToolsPanel | ||
| label={ __( 'Waveform' ) } | ||
| resetAll={ () => { | ||
| setAttributes( { | ||
| waveformStyle: undefined, | ||
| } ); | ||
| } } | ||
| panelId={ waveformPanelId } | ||
| dropdownMenuProps={ dropdownMenuProps } | ||
| > | ||
| <ToolsPanelItem | ||
| label={ __( 'Shape' ) } | ||
| isShownByDefault | ||
| hasValue={ () => | ||
| waveformStyle !== DEFAULT_WAVEFORM_STYLE | ||
| } | ||
| onDeselect={ () => | ||
| onChangeWaveformStyle( DEFAULT_WAVEFORM_STYLE ) | ||
| } | ||
| panelId={ waveformPanelId } | ||
| > | ||
| <SelectControl | ||
| label={ __( 'Shape' ) } | ||
| value={ waveformStyle } | ||
| options={ WAVEFORM_STYLE_OPTIONS } | ||
| onChange={ onChangeWaveformStyle } | ||
| /> | ||
| </ToolsPanelItem> | ||
| </ToolsPanel> | ||
| </InspectorControls> | ||
| <figure { ...blockProps }> | ||
| <Disabled isDisabled={ ! isSelected }> | ||
| <WaveformPlayer | ||
|
|
||
This file contains hidden or 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 hidden or 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change will affect all consumers using this slot group, won't it? Why is this reordering necessary?
By the way, for all block-specific settings, we use a panel labeled "Settings".
See: #67813
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This shouldn't have been there. Thanks for catching!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reverted in #80111