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

Remove Gallery Block Alignment Class when Editing #15095

Closed
bbertucc opened this issue Apr 22, 2019 · 9 comments
Closed

Remove Gallery Block Alignment Class when Editing #15095

bbertucc opened this issue Apr 22, 2019 · 9 comments
Labels
[Block] Gallery Affects the Gallery Block - used to display groups of images [Feature] Blocks Overall functionality of blocks [Type] Enhancement A suggestion for improvement.

Comments

@bbertucc
Copy link

Is your feature request related to a problem? Please describe.
I’m applying a custom stylesheet with style for an alignwide class. My alignment style doesn’t affect any other blocks, except for the gallery block. Is there a reason the gallery block adds the alignwide class when using the editor? Other blocks just use a data-attribute to set alignment

Describe the solution you'd like
Ideally, the gallery block alignment would only be set with a data-attribute

Describe alternatives you've considered
I stopped including the alignment style in my editor style.

@jorgefilipecosta jorgefilipecosta added the Needs Technical Feedback Needs testing from a developer perspective. label Apr 22, 2019
@jorgefilipecosta
Copy link
Member

Hi @bbertucc, thank you for reporting this issue. It seems adding the class is something we should do even for other blocks. Adding the class makes the styles between editor and frontend closer and promotes the reusability between the styles.
Hi @jasmussen are you aware of the reason why these classes were not added to the edit method of other blocks?

@jorgefilipecosta jorgefilipecosta added the Needs Design Feedback Needs general design feedback. label Apr 22, 2019
@jasmussen
Copy link
Contributor

Hi @jasmussen are you aware of the reason why these classes were not added to the edit method of other blocks?

No, I've actually wondered the same. I'm not sure I have the full context, but as a principle, the more we can make the editor markup match the frontend, the better, notably for editor style simplicity.

To the issue here in question: if all blocks that had alignments had the relevant "align" classes present, could you not accomplish the same as you could by targeting only the data attributes? Targeting the classes would potentially let you have editor styles that were closer to the theme styles.

@bbertucc
Copy link
Author

Thanks @jasmussen and @jorgefilipecosta!

Using classes instead of data-attributes would solve my problem. In issue #6430, the reply from @mtias explains why they're using data-alignments in the editor. That doesn't explain why classes are used in the gallery block.

I'm finding lots of inconsitencies with class names, while I build my block-ready starter theme.

Does the Gutenberg team want to seamlessly integrate theme and editor styles? If so, I would definitely suggest better consistency.

@jasmussen
Copy link
Contributor

Thank you for referencing that response. Matías has a good point with that, actually.

Followup question for you: what if blocks in the editor featured both the data-align attributes, and the corresponding alignment classes ... would this make your life easier or harder?

@bbertucc
Copy link
Author

Using both would be fine, as long as class styles could easily override data attribute styles. If a parent <div> had the data attribute and a child element had the class, we would still have to add editor-specific hacks to affect the alignment.

@jasmussen
Copy link
Contributor

If a parent <div> had the data attribute and a child element had the class, we would still have to add editor-specific hacks to affect the alignment.

This will likely always be the case. The markup for the block in the editor has additional elements to make it editable, such as the toolbar, the mover, and other things. The markup that is actually output on the front-end will always be a child element of this.

In light of that it sounds like you'd prefer the removal of the alignment classes in favor of only the data attributes in the editor?

@bbertucc
Copy link
Author

bbertucc commented Apr 24, 2019 via email

@jasmussen
Copy link
Contributor

That seems like the next step to explore. I know that @youknowriad can do some magic rewriting of editor styles, so there are options to explore for future improvements.

@gziolo gziolo added [Feature] Blocks Overall functionality of blocks [Type] Enhancement A suggestion for improvement. [Block] Gallery Affects the Gallery Block - used to display groups of images and removed Needs Design Feedback Needs general design feedback. Needs Technical Feedback Needs testing from a developer perspective. labels May 24, 2019
@youknowriad
Copy link
Contributor

Follow-up to this issue with a consistent proposal across blocks here #20650

Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Block] Gallery Affects the Gallery Block - used to display groups of images [Feature] Blocks Overall functionality of blocks [Type] Enhancement A suggestion for improvement.
Projects
None yet
Development

No branches or pull requests

5 participants