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

Replace placeholder handling for MediaPlaceholder instructions #10861

Merged
merged 8 commits into from
Oct 25, 2018

Conversation

ocean90
Copy link
Member

@ocean90 ocean90 commented Oct 21, 2018

Description

Fixes #10855.

  • Removes labels.name
  • Builds instructions string based on allowed types
  • Adds support for labels.instructions

How has this been tested?

Add blocks with media uploads and verify that all instructions still make sense. Run npm run test to check unit tests.

@ocean90 ocean90 added Internationalization (i18n) Issues or PRs related to internationalization efforts [Feature] Blocks Overall functionality of blocks [Package] Editor /packages/editor labels Oct 21, 2018
instructions = __( 'Drag an audio, upload a new one or select a file from your library.' );
} else if ( isEmpty( difference( allowedTypes, [ 'image', 'video' ] ) ) ) {
instructions = __( 'Drag an image or a video, upload a new one or select a file from your library.' );
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Instead of adding all these if/else here, can we use just a generic string here and pass these as props where appropriate? that way we stay consistent in how we deal with labels in this component.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah, had the same thought. One point for doing it like this is having the translations provided by core. So third-party usage of MediaPlaceholder don't have to provide their own translations for the same strings.

Copy link
Contributor

@youknowriad youknowriad Oct 21, 2018

Choose a reason for hiding this comment

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

I'd be ok with it if the "title" is handled similarily...

Copy link
Contributor

Choose a reason for hiding this comment

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

I also wonder if we should have a generic "Media" in the text if the allowedTypes contains more than one item.

Copy link
Member Author

Choose a reason for hiding this comment

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

instructions = __( 'Drag an image, upload a new one or select a file from your library.' );
} else if ( isAudio ) {
instructions = __( 'Drag an audio, upload a new one or select a file from your library.' );
} else if ( isImageAndAudio ) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Do you think we should leave this one as a prop (image and video) as it seems too specific to be bundled in the component?

Copy link
Member Author

Choose a reason for hiding this comment

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

Good point, I already left out the title definition for this case.

@ocean90 ocean90 added this to the 4.2 milestone Oct 22, 2018

### Breaking Changes

- The `labels.name` property has been removed from `MediaPlaceholder` in favor of the new `labels.instructions` prop.
Copy link
Contributor

Choose a reason for hiding this comment

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

So yes, this is a breaking change but I don't expect it to have big negative impacts on people already using the component, so I think I'm fine shipping without deprecation handling. Thoughts @ocean90 ?

Copy link
Member Author

Choose a reason for hiding this comment

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

I agree, the deprecation handling is actually the new handling for default title/instructions. No JS errors or similar will be produced by this change.

Copy link
Contributor

@youknowriad youknowriad left a comment

Choose a reason for hiding this comment

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

Thanks for the updates. LGTM 👍

@ocean90 ocean90 merged commit 07d27f4 into master Oct 25, 2018
@ocean90 ocean90 deleted the fix/media-placeholder-instructions branch October 25, 2018 08:39
antpb pushed a commit to antpb/gutenberg that referenced this pull request Oct 26, 2018
…ress#10861)

Add default title and instructions labels to MediaPlaceholder based on allowed types.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] Blocks Overall functionality of blocks Internationalization (i18n) Issues or PRs related to internationalization efforts [Package] Editor /packages/editor
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants