Skip to content

Commit

Permalink
Fix for default labels
Browse files Browse the repository at this point in the history
  • Loading branch information
Firestorm980 committed Jun 25, 2024
1 parent 2510b9d commit aa6e141
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions components/media-toolbar/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,12 @@ interface MediaToolbarProps {
};
}

const DEFAULT_LABELS = {
add: __('Add Image', '10up-block-components'),
remove: __('Remove Image', '10up-block-components'),
replace: __('Replace Image', '10up-block-components'),
};

/*
* MediaToolbar
*
Expand All @@ -49,14 +55,11 @@ export const MediaToolbar: React.FC<MediaToolbarProps> = ({
onRemove,
isOptional = false,
id,
labels = {
add: __('Add Image', '10up-block-components'),
remove: __('Remove Image', '10up-block-components'),
replace: __('Replace Image', '10up-block-components'),
},
labels = {},
}) => {
const hasImage = !!id;
const { media } = useMedia(id);
const mergedLabels = { ...DEFAULT_LABELS, ...labels };

return (
<ToolbarGroup>
Expand All @@ -65,11 +68,11 @@ export const MediaToolbar: React.FC<MediaToolbarProps> = ({
<MediaReplaceFlow
mediaUrl={media?.source_url}
onSelect={onSelect}
name={labels.replace}
name={mergedLabels.replace}
/>
{!!isOptional && (
<ToolbarButton onClick={onRemove}>
{labels.remove}
{mergedLabels.remove}
</ToolbarButton>
)}
</>
Expand All @@ -79,7 +82,7 @@ export const MediaToolbar: React.FC<MediaToolbarProps> = ({
onSelect={onSelect}
render={({ open }) => (
<ToolbarButton onClick={open}>
{labels.add}
{mergedLabels.add}
</ToolbarButton>
)}
/>
Expand Down

0 comments on commit aa6e141

Please sign in to comment.