-
Notifications
You must be signed in to change notification settings - Fork 3
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
Chore: Styles Gutenberg core image block #802
Conversation
🦋 Changeset is good to goLatest commit: 361cae5 We got this. Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
After I opened this PR up for review, I realized that this PR did not include the changes I intended to add to the core/image documentation about how I plan to update that before merging. |
`u-pull-inline-{amount}` class names from our [negative | ||
margin](/?path=/docs/utilities-spacing--negative-margin) utility classes can | ||
be added to the additional css section of the image block to extend the left and | ||
right edges of images beyond their parent prose container. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've updated this section of documentation and re-requesting review.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it possible for us to add opinionated defaults for the breakout alignment options I see in the Gutenberg demo
I will update this PR to account for the "wide width" and "full width" settings.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@tylersticka I know you had a busy day, so no need to respond to this right away.
Part of my confusion was that my image block editor options looked different than your screenshot above from your Gutenberg demo. In my local development environment, I'm using the version of Gutenberg that ships with WordPress and my 'alignment' options only included: left, center and right options.
As far as I can tell, this option needs to be enabled via add_theme_support
https://gogutenberg.com/blocks/image/
Which appears to work...
Unless I'm missing something, my plan is to submit a PR to the WP repo to allow for these "advanced alignment" options as well.
…de image alignment
…atterns into chore/gutenberg-core-image-block
Excellent idea! A few notes:
The way the story was configured prior looked like this: <Preview>
<Story name="core/image">
{`<figure class="wp-block-image size-large is-style-default">
<img
src="/media/MtBlanc1.jpg"
alt="Mont Blanc"
class="wp-image-130"
srcset="
/media/MtBlanc1.jpg 500w,
/media/MtBlanc1-300x225.jpg 300w
"
sizes="(max-width: 500px) 100vw, 500px"
/>
<figcaption>Mont Blanc appears—still, snowy, and serene.</figcaption>
</figure>`}
</Story>
</Preview> I wasn't sure how to add knobs to this format, so I followed some examples I observed elsewhere and reformatted the story like this: <Preview>
<Story name="core/image">
{blockImageDemo({
class: select('alignment class', alignmentClasses, null),
})}
</Story>
</Preview> I am curious about the legitimacy of this approach and possibly learning better/alternate ways to configure this.
const alignmentClasses = {
None: null,
Left: 'alignleft',
Center: 'aligncenter',
Right: 'alignright',
Full: 'alignfull',
Wide: 'alignwide',
}; I wonder if their is a more efficient way to accomplish this.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Works well, some comments inline
src/vendor/wordpress/_wordpress.scss
Outdated
position: relative; | ||
|
||
/** | ||
* 1. Setting a width of `100%` prevents resized and centered images from |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: Comment numbering isn't necessary when there is only one line in the block.
src/vendor/wordpress/_wordpress.scss
Outdated
left: calc(12vw / -2); /* 1 */ | ||
margin-left: auto; | ||
margin-right: auto; | ||
width: calc(100% + 12vw); /* 1 */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would this accomplish the same thing?
left: calc(12vw / -2); /* 1 */ | |
margin-left: auto; | |
margin-right: auto; | |
width: calc(100% + 12vw); /* 1 */ | |
margin-left: -6vw; /* 1 */ | |
margin-right: -6vw; /* 1 */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It does! I like it, much simpler. I am introducing these changes manually.
<Meta title="Vendor/WordPress/Gutenberg" /> | ||
import blockImageDemo from './demo/image.twig'; | ||
const alignmentClasses = { | ||
None: null, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Storybook select values are converted to strings no matter what they are, so (annoyingly) null
is the same as passing in a string called 'null'
. You can pass in an empty string, though, (''
), which should have the desired effect.
(It's times like these I wish knobs were better documented... but they've been replaced by a more elegant solution in the latest Storybook release, so that's nice!)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you, that was extremely helpful. I had originally started with an empty string, but ended up mimicking what I saw in the documentation I was reading, which used null
. 🙃
<figcaption>Mont Blanc appears—still, snowy, and serene.</figcaption> | ||
</figure>`} | ||
{blockImageDemo({ | ||
class: select('alignment class', alignmentClasses, null), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would either shorten this to "alignment," or show the full class names (alignright
instead of Right
). As is, it says "alignment class" but it's not actually showing the class.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point! Excellent feedback.
src/vendor/wordpress/demo/image.twig
Outdated
@@ -0,0 +1,30 @@ | |||
<div | |||
class="demo-container" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider using the Rhythm object pattern for this, especially since your styles account for it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Working well, but two issues still to resolve:
- I notice if I change from the "None" alignment option to "Center," the amount of whitespace below the example increases but nothing else does.
- Because this PR adds a feature, you need to make sure the addition is part of our changelog. Instructions are in the contribution guide: https://github.com/cloudfour/cloudfour.com-patterns/blob/v-next/CONTRIBUTING.md#changelog-entries
…ment options (none/center).
Hi @tylersticka,
I want to make sure I understand expectations here correctly. 1. Whitespace questionI can't determine if you are suggesting that the amount of whitespace should change or not. I had originally assumed you were suggesting that it should not, so I pushed one possible "solution" (3ed4aae) to "remedy" that. However, now I'm not so sure! Example of update introducing no change in whitespace If I compare behavior of c4staging.wpengine.com/ master branch I notice the white space does change when switching between these two alignment options: Note the classic editor will apply a class of 2. Alignment questionI also want to make sure I understand the second part of your comment:
I interpret this as, "when 'None' is selected and the image size is reduced it should not maintain centered alignment". It appears that "None" and "Center" currently behave similarly when reducing the image size due to some styles defined in our base CSS.
/*
* ...
* 2. Center content
* ...
*/
figure {
...
& > * {
margin-left: auto; /* 2 */
margin-right: auto; /* 2 */
}
... If my interpretation is correct, is it more desirable to override the existing An alternate approach might require rethinking how the base Thanks! |
I couldn't see a reason why one would have whitespace and the other would not. The issue is the (seemingly unintentional) inconsistency, not the presence of or lack of whitespace. Was the whitespace intentional, or an oversight? If it was not intentional, and there isn't a design justification for it, then we should remove it. If it was intentional but was omitted from the default, then we should add it. Does that make sense?
This isn't a second part, I just meant that only If you intended for |
To summarize:
|
Based on my observations on cloudfour.com I had thought the additional whitespace was intentional. So my only "intent" at the time was to mimic what I thought was expected, due to the
No, I don't think so. I think the additional whitespace throws off the vertical rhythm applied by our Rhythm object pattern. Happy to discuss further. |
Hi @tylersticka, I added a changeset (69c1af7) and it dismissed your approval. |
Overview
This pull request adds a few small style adjustments to Gutenberg image blocks to improve layout and alignment for WP image blocks.
Additionally, This PR now adds CSS support for Gutenberg wide and full images.
Screenshots
Before alignment fix
After alignment fix
Testing
See #710