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

Add cover image #879

Merged
merged 17 commits into from
Jun 22, 2017
Merged

Add cover image #879

merged 17 commits into from
Jun 22, 2017

Conversation

georgeh
Copy link
Contributor

@georgeh georgeh commented May 23, 2017

Addresses #487

TODO

  • Remove text formatting options
  • Add full-height/parallax options
  • Pre-select image in image chooser when replacing the image

post-content.js Outdated
'<!-- /wp:core/cover-image -->',

'<!-- wp:core/heading -->',
'<h1>Welcome to the Gutenberg Editor</h1>',
Copy link
Member

Choose a reason for hiding this comment

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

This is no longer part of the demo content.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks, must have been a merge conflict.

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 your help on this block. I left some small notes

</div>
<Button isLarge>
{ wp.i18n.__( 'Insert from Media Library' ) }
</Button>
Copy link
Contributor

Choose a reason for hiding this comment

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

The media library integration is already available through the MediaUploadButton. see https://github.com/WordPress/gutenberg/blob/master/blocks/library/image/index.js#L89

Copy link
Member

Choose a reason for hiding this comment

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

We need to start thinking about documenting these (editable, media button, the iframe thing).

title: wp.i18n.__( 'Change Image' ),
isActive: ( { align } ) => 'left' === align,
onClick: toggleAlignment( 'left' ),
},
Copy link
Contributor

Choose a reason for hiding this comment

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

What is this control for? should we drop it?

category: 'common',

attributes: {
url: attr( 'section', 'data-url' ),
Copy link
Contributor

Choose a reason for hiding this comment

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

FWIW, it's possible to drop the url attribute here and the url will be saved in the block opening comment.

import { registerBlock, query } from '../../api';
import Editable from '../../editable';
// TODO: Revisit when we have a common components solution
import Dashicon from '../../../components/dashicon';
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we move this to the WordPress dependencies import Dashicon from 'components/dashicon';?

@georgeh
Copy link
Contributor Author

georgeh commented May 24, 2017

@mtias and @youknowriad thank you for the 👀 , the feedback is really helpful for me (as someone less familiar with the project). I'm still getting the block working, and after that I'll work on cleaning everything up.

@georgeh
Copy link
Contributor Author

georgeh commented Jun 9, 2017

@jasmussen would you kindly try this block out and let me know how it feels? I'm still working on a parallax setting but the core functionality should be there

@jasmussen
Copy link
Contributor

I like it! I have a bunch of small things, including a different UI for adding/changing the image, but I think we might want to try and keep things minimal for the first merge, then iterate.

There isn't any background-attachment: fixed, though — any reason why? I think that'd be a nice feature to have.

@georgeh
Copy link
Contributor Author

georgeh commented Jun 12, 2017

@jasmussen I wanted to make sure I was on the right path before going too far down it. I'm going to play with a few settings for background-attachment: fixed to see what I like

@georgeh
Copy link
Contributor Author

georgeh commented Jun 19, 2017

@youknowriad could you take another look at this? I'm ready to merge

@georgeh georgeh changed the title WIP Add cover image Add cover image Jun 19, 2017
@georgeh georgeh added the [Feature] Blocks Overall functionality of blocks label Jun 20, 2017
@georgeh georgeh added this to the Beta milestone Jun 20, 2017
@jasmussen jasmussen modified the milestones: Beta, Beta 2 Jun 21, 2017
@mkaz
Copy link
Member

mkaz commented Jun 21, 2017

  • Backspace doesn't work in title field

  • I think I get the Pin for background fixed, but it seems to also align-right, should pin be separate then the alignments - ie. I can pin a full bleed image

@georgeh
Copy link
Contributor Author

georgeh commented Jun 21, 2017

@mkaz thanks, I'll check out the backspace.

For alignment vs pin I see the argument for allowing something to be both aligned and pinned. I'll try out a few CSS tweaks to see how they look.

/**
* WordPress dependencies
*/
import Placeholder from 'components/placeholder';
Copy link
Contributor

Choose a reason for hiding this comment

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

We should use import { Placeholder } from 'components'; to avoid duplication in the built files. (We should probably make this clearer in our dev docs)

title: text( 'h2' ),
},

controls: [
Copy link
Contributor

Choose a reason for hiding this comment

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

If you rebase master, you'll notice this property doesn't work anymore and I suggest using <BlockAlignmentToolbar> for alignment controls. See #1019 for examples.

};

registerBlockType( 'core/cover-image', {
title: wp.i18n.__( 'Cover Image' ),
Copy link
Contributor

Choose a reason for hiding this comment

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

We're trying to avoid using the wp global variable as much as we can in favor of import { __ } from 'i18n. See #1332 for context on this.


editFrame.on( 'insert', updateFn );
editFrame.open( 'cover-image' );
};
Copy link
Contributor

Choose a reason for hiding this comment

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

This is the second block allowing to edit a media. I wonder if should try to factorize this in MediaUploadButton or similar. This could be done in a separate PR.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm going to remove this for now but I think it may make sense as a follow-up as it's own InspectorControl.

buttonProps={ uploadButtonProps }
onSelect={ setMediaUrl }
type="image"
auto-open
Copy link
Contributor

Choose a reason for hiding this comment

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

auto-open has been rename autoOpen

@mtias
Copy link
Member

mtias commented Jun 22, 2017

@georgeh we should try to use git rebase instead of merges from master.

@@ -25,6 +25,10 @@ const BLOCK_ALIGNMENTS_CONTROLS = {
icon: 'align-full-width',
title: __( 'Full width' ),
},
fixed: {
Copy link
Member

@mtias mtias Jun 22, 2017

Choose a reason for hiding this comment

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

I think this should be a toggle in the inspector, not a shared alignment.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm going to make a CheckboxControl to use in the inspector

Copy link
Member

@mtias mtias Jun 22, 2017

Choose a reason for hiding this comment

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

Should probably just use the existing toggle component for this (see the drop cap setting for text). cc @jasmussen

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Looking at the code for TextboxControl it looks like I can pass type="checkbox" - how do you feel about me renaming that to InputControl?

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes if we were to make a toggle for this it should just be the existing switch:

screen shot 2017-06-22 at 19 57 02

But I think it's okay to actually remove this advanced property for now to just get the PR merged, if that's simpler.

Alternately, I feel pretty strongly that the fixed background should be applied by default. And it should not be a data-align value. It should be something you can toggle in addition to the image alignment.

Copy link
Member

Choose a reason for hiding this comment

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

Yes, it's not an alignment, just an extra attribute.

Copy link
Contributor

Choose a reason for hiding this comment

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

I gave George the go-ahead to merge this without this fixed position toggle (which we just removed). I think it's good to merge this block, and we can add the toggle separately if we desire it.

George Hotelling and others added 3 commits June 22, 2017 13:27
Now using the new `<BlockControls>` to manage the image position.

Also removed the ability to change the picture pending moving it into the inspector

Also addressed changes in the PR to remove `wp` global and fix autoOpen the MediaUploadButton
- Make background attachment fixed by default. Let's either remove the option to pin it entirely, or move it to the inspector and make it something that's on by default.
- Added gray scrim, removed text shadow, reduced font size
- Removed alignments because these are now inherited

Future improvements we should also consider: add the full-wide button that images have now, and make it so the dark scrim is only present when there's text.
@mtias mtias removed this from the Beta 2 milestone Jun 22, 2017
@jasmussen
Copy link
Contributor

Okay I think this is good to go! 👍 👍

@georgeh georgeh merged commit b995440 into master Jun 22, 2017
@ellatrix ellatrix deleted the add/487-cover-image branch July 2, 2017 08:34
@StaggerLeee
Copy link

May I suggest you make Caption field (Cover Image Title) a bit different than rest of the image ?
To make it clear it is a editable element inside image. Right now only visual help is a mouse cursor.


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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants