Skip to content
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

MediaToolbar component: Allow configuring labels #242

Closed
1 task done
benlk opened this issue Jul 14, 2023 · 1 comment · Fixed by #334
Closed
1 task done

MediaToolbar component: Allow configuring labels #242

benlk opened this issue Jul 14, 2023 · 1 comment · Fixed by #334
Labels

Comments

@benlk
Copy link
Contributor

benlk commented Jul 14, 2023

Is your enhancement related to a problem? Please describe.

Use case: I want to use the MediaToolbar with the Video component introduced in #225, but the labels on this component assume that the bound media is an image: "Add Image", "Replace Image", "Remove Image".

<MediaReplaceFlow
mediaUrl={media?.source_url}
onSelect={onSelect}
name={__('Replace Image', '10up-block-components')}
/>

{!!isOptional && (
<ToolbarButton onClick={onRemove}>
{__('Remove Image', '10up-block-components')}
</ToolbarButton>
)}

<ToolbarButton onClick={open}>
{__('Add Image', '10up-block-components')}
</ToolbarButton>

Designs

Ideally, we'd be able to pass a labels argument to MediaToolbar, something like:

<BlockControls>
	<MediaToolbar
		isOptional
		id={ video }
		onSelect={( media ) => setAttributes( {video: media.id} )}
		labels={{
			add: __( 'Add Video' ),
			replace: __( 'Replace Video' ),
			remove: __( 'Remove Video' )
		}}
	/>
</BlockControls>

Describe alternatives you've considered

No response

Code of Conduct

  • I agree to follow this project's Code of Conduct
@Firestorm980
Copy link
Contributor

@benlk @fabiankaegy WIP PR above that adds this feature.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants