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

Image Block: Add "full width" control option #518

Merged
merged 3 commits into from
May 2, 2017
Merged

Conversation

aduth
Copy link
Member

@aduth aduth commented Apr 26, 2017

Related: #310
Related: #416

This pull request seeks to add a new "Full width" option to the image block controls, intended for cases where the image is to break out of any constraining container.

full

Open questions:

  • Label name? There's some heated debate in the original issue.

Testing instructions:

Verify that the full width option can be toggled like other image alignment controls (#416), and that it visually breaks out of the editor container.

Future considerations:

  • Currently I'm using an align-center icon, as there's not a Dashicon yet which fits well for the intended action. @jasmussen has committed to incorporating one.
  • As a new option, existing themes are unlikely to support this. We'll need to consider some hooks by which a theme can define its support and conditionally show the control.

@aduth aduth added the [Feature] Blocks Overall functionality of blocks label Apr 26, 2017
@aduth aduth added this to the Prototype Parity milestone Apr 26, 2017
&[data-align="full"] {
width: 90%;
max-width: none;
}
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 center the image as well?

&[data-align="full"] {
    img {
        margin: 0 auto;
    }
}

Not a huge fan of over nesting selectors but YOLO!

@BE-Webdesign
Copy link
Contributor

The formatting and application of the attribute works 👌, however when the image goes full width on a larger screen it is not centered, like I would expect it to be. Not sure what the expected behavior should be. Other than that, it looks good to me.

Also totally 👍 on data-align=full, I saw somewhere else where it was brought up that full-width was not an alignment. Maybe that is true, but I am pretty sure most people will understand and this works a lot cleaner than having all sorts of names.

<Inserter />
<div className="editor-visual-editor__container">
<Inserter />
</div>
Copy link
Contributor

Choose a reason for hiding this comment

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

Any context to this change for this PR?

Copy link
Member Author

@aduth aduth Apr 27, 2017

Choose a reason for hiding this comment

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

Any context to this change for this PR?

To preserve the common max-width of 700px across blocks while still allowing blocks to escape out of it, the responsibility of assigning the max width was moved from the listing to the block itself. Without the changes here, the inserter would be shown to the far left of the editor canvas since it's not a true block, but should respect alignment with the rest the blocks (effected with the container).

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah makes perfect sense.

@@ -15,6 +15,11 @@
float: right;
margin-left: 15px;
}

&[data-align="full"] {
width: 90%;
Copy link
Member

Choose a reason for hiding this comment

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

What's 90% here?

Copy link
Contributor

Choose a reason for hiding this comment

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

I think it is trying to go full-width but not too full-width. 100% would probably make more sense though.

Copy link
Member Author

Choose a reason for hiding this comment

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

It was a number pulled out of the air 😄 But yes, specifically it's a value close to 100% while still allowing space for the block mover.

jasmussen added a commit that referenced this pull request Apr 27, 2017
This includes a new `align-full-width` icon.

Heads up #518

Dashicons PR here: WordPress/dashicons#180
@jasmussen
Copy link
Contributor

Added a new full width icon in #521

7a0f4a74-2b35-11e7-8be7-8f8d832c8fe6

align-full-width

@mtias
Copy link
Member

mtias commented Apr 27, 2017

Maybe just wide as attribute name?

@mtias mtias added the [Priority] High Used to indicate top priority items that need quick attention label Apr 27, 2017
@aduth
Copy link
Member Author

aduth commented Apr 27, 2017

however when the image goes full width on a larger screen it is not centered, like I would expect it to be.

Good catch on this @BE-Webdesign . I guess there's a question of: Do we want to force the image to take up the full width of the canvas? Its natural width (with margin: 0 auto)? Some arbitrary "expanded" width (like max-width: 900px instead of 700px)?

@BE-Webdesign
Copy link
Contributor

BE-Webdesign commented Apr 27, 2017

I would say natural width to prevent images from overly distorting. If you want an image to fill up more space, use a bigger image. On super hi res screens, if we go full width of the canvas, images will look really silly compared to the text content. The arbitrary "expanded" might work the best, I would go with 1130px for the max-width for a nice ratio between the two. Whatever works really, I wouldn't over think it too much, the 0 auto at least will guarantee the image is centered setting the width of the image might make more sense though and a theme can change how full width looks for that theme.

@jasmussen
Copy link
Contributor

Good catch on this @BE-Webdesign . I guess there's a question of: Do we want to force the image to take up the full width of the canvas? Its natural width (with margin: 0 auto)? Some arbitrary "expanded" width (like max-width: 900px instead of 700px)?

I meant to respond to this previously, but clearly missed out on this one too.

Full-width, née "full bleed", is close to my heart. I feel strongly that it should be truly full width. Edge to edge. Definitely in the editor, and depending on technical implementations, also in the theme itself.

Try viewing the example post, and scroll down to this image:

screen shot 2017-04-27 at 16 53 59

That's the look that we're going for with this one. Big and bold. If we are too concerned about it being mega huge, we could add another option which is could be the "wide", but I still think there's a case for going edge to edge.

That being said, there are some technical challenges. The UI prototype used this trick to go edge to edge, despite any max-widths applied to the main content colum:

.align-full-bleed {
    margin-left: calc(50% - 50vw);
    width: 100vw;
}

The problem with that one is that the vw unit does not account for scrollbars, which means any browser that doesn't have fancy mac auto hiding scrollbars will also get a horizontal scrollbar. In my mind that is a blocker for this method of full width images. The example post referenced above explicitly avoids this implementation by not having a max-width on the main column.

This suggests that we may want to leave it up to the theme itself to decide what to do, and simply apply a CSS class to the image.

@aduth
Copy link
Member Author

aduth commented Apr 27, 2017

This suggests that we may want to leave it up to the theme itself to decide what to do, and simply apply a CSS class to the image.

Yeah, I think it really depends on how the theme authors would use this attribute. The class already exists with the changes here, it's just deciding how to display it in the editor. The problem with the prototype version is that there's no way to move the block up and down, hence the 90% here.

@jasmussen
Copy link
Contributor

Yeah, I think it really depends on how the theme authors would use this attribute. The class already exists with the changes here, it's just deciding how to display it in the editor. The problem with the prototype version is that there's no way to move the block up and down, hence the 90% here.

Yep. We had some ideas for this, and I'm still thinking about that. Right at this moment, I think it's okay that you can't move it when full bleed (because the controls are off screen). If you need to move it, you can temporarily pick a different alignment, or move the blocks before and after, or use drag and drop.

However if in practice we find that this is annoying, let's revisit and perhaps we can move the position of the mover for this look.

@aduth aduth force-pushed the update/full-bleed-image branch from df1a6b6 to 9e5ad31 Compare April 27, 2017 21:10
@aduth
Copy link
Member Author

aduth commented Apr 27, 2017

Rebased to address feedback and incorporate the new icon.

But there's a hiccup now in that floated images no longer respect the block maximum width. Will have to poke at this a while longer to see if there's another way to "escape" the container.

@jasmussen
Copy link
Contributor

I've noted down a few articles on how to escape the container, perhaps worth looking at: https://css-tricks.com/full-width-containers-limited-width-parents/

There was also this one, which I thought was particularly promising: https://css-tricks.com/hassle-free-full-bleed-not/

@aduth
Copy link
Member Author

aduth commented Apr 28, 2017

@jasmussen Thanks for the links. That first one was particularly great in breaking down considerations; for us, the "non-% Parent Width" case. Inevitably this includes the viewport width unit which, as you've mentioned, doesn't account for the presence of the sidebar. I still went down this path in a2d8372, using overflow: hidden; on the editor container to prevent the horizontal scroll. This also means there's likely ~25px of the image clipped when a scrollbar exists. Also, as can be seen in the CSS, managing offsets for varying sidebar collapsed / folded / hidden states is quite cumbersome. Ugly as it is, it should all be accounted for now.

To the other link: The issue is that if we move the burden of managing max-width and centering to the block itself, it becomes equally difficult to come up with a solution for the floated images to be aligned to the invisible left and right barriers of adjacent blocks.

@jasmussen
Copy link
Contributor

To the other link: The issue is that if we move the burden of managing max-width and centering to the block itself, it becomes equally difficult to come up with a solution for the floated images to be aligned to the invisible left and right barriers of adjacent blocks.

Yep, I learned of this in the example post with the left floated quote.

👍

@aduth
Copy link
Member Author

aduth commented May 1, 2017

@jasmussen How do you feel about the solution using vw units, since I know you tend to have opinions on its usage 😄

@mtias mtias modified the milestones: May Week 1, Prototype Parity May 1, 2017
@jasmussen
Copy link
Contributor

@jasmussen How do you feel about the solution using vw units, since I know you tend to have opinions on its usage 😄

Haha yes indeed.

I personally find the unit completely useless as it presumes there are no scrollbars, and especially for Windows users, there are. However I'm also pragmatic enough to swallow that pride when presented with something that works. If it works, and works well, ship it! (And just to be clear, "works" means that there are no horizontal scrollbars, when Mac has them set to always show.)

I'm assuming themes can still choose not to use vw units for the frontend rendering, correct?

@mkaz mkaz mentioned this pull request May 2, 2017
@aduth
Copy link
Member Author

aduth commented May 2, 2017

I'm assuming themes can still choose not to use vw units for the frontend rendering, correct?

Theme styling in general needs more thought, but it would be my assumption that this would be entirely up to the theme to implement based on the presence of the class, yes.

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 [Priority] High Used to indicate top priority items that need quick attention
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants