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

Adjust borders on gallery to prevent overlap #27312

Merged
merged 8 commits into from
Jan 15, 2021

Conversation

karmatosed
Copy link
Member

@karmatosed karmatosed commented Nov 26, 2020

This iteration is hopefully a temporary workaround that having a better method for this block can solve in longer term. That said there is a current issue where the borders overlap on select.

Before:

image

In order to not touch the other elements that use this, I added to the block specific CSS. Props to @jasmussen for helping me learn more about this CSS and the potential iterations in future. It's my understanding whatever I am adding here will be changed later, so a workaround like this could be suitable.

After:

image

Feedback

I would love a code review as I admit, it got a little complex finding this specifically and I would love to know if there is a more elegant declaration. Similarly, whilst I took the method of treating borders to '-1px', perhaps alternatives could be done. I explored adding padding in the block, however that meant more visual impact.

@karmatosed karmatosed added the [Block] Gallery Affects the Gallery Block - used to display groups of images label Nov 26, 2020
@github-actions
Copy link

github-actions bot commented Nov 26, 2020

Size Change: -6.61 kB (0%)

Total Size: 1.19 MB

Filename Size Change
build/a11y/index.js 1.14 kB -2 B (0%)
build/blob/index.js 665 B +1 B
build/block-directory/index.js 8.72 kB -3 B (0%)
build/block-editor/index.js 128 kB -5.58 kB (4%)
build/block-editor/style-rtl.css 11.2 kB -128 B (1%)
build/block-editor/style.css 11.2 kB -129 B (1%)
build/block-library/editor-rtl.css 8.88 kB -71 B (0%)
build/block-library/editor.css 8.88 kB -75 B (0%)
build/block-library/index.js 148 kB -2 B (0%)
build/block-library/style-rtl.css 8.27 kB +3 B (0%)
build/block-library/style.css 8.27 kB +3 B (0%)
build/block-serialization-default-parser/index.js 1.88 kB +6 B (0%)
build/blocks/index.js 48.1 kB -7 B (0%)
build/components/index.js 172 kB +37 B (0%)
build/compose/index.js 9.95 kB -5 B (0%)
build/core-data/index.js 14.8 kB -1 B
build/data-controls/index.js 827 B -1 B
build/data/index.js 8.98 kB +174 B (1%)
build/date/index.js 11.2 kB -2 B (0%)
build/dom/index.js 4.95 kB +1 B
build/edit-navigation/index.js 11.1 kB +16 B (0%)
build/edit-post/index.js 306 kB -17 B (0%)
build/edit-site/index.js 24.1 kB +90 B (0%)
build/edit-site/style-rtl.css 4.06 kB +145 B (3%)
build/edit-site/style.css 4.06 kB +144 B (3%)
build/edit-widgets/index.js 26.3 kB -1 B
build/editor/index.js 43.3 kB -11 B (0%)
build/element/index.js 4.63 kB +4 B (0%)
build/format-library/index.js 6.86 kB -5 B (0%)
build/hooks/index.js 2.27 kB -1 B
build/i18n/index.js 3.56 kB -1 B
build/keyboard-shortcuts/index.js 2.54 kB -3 B (0%)
build/list-reusable-blocks/index.js 3.1 kB +1 B
build/media-utils/index.js 5.32 kB -2 B (0%)
build/notices/index.js 1.82 kB +2 B (0%)
build/nux/index.js 3.42 kB +2 B (0%)
build/plugins/index.js 2.56 kB +2 B (0%)
build/priority-queue/index.js 791 B +1 B
build/redux-routine/index.js 2.84 kB +1 B
build/reusable-blocks/index.js 2.92 kB +5 B (0%)
build/rich-text/index.js 13.4 kB +20 B (0%)
build/server-side-render/index.js 2.77 kB -3 B (0%)
build/shortcode/index.js 1.69 kB -2 B (0%)
build/token-list/index.js 1.27 kB +1 B
build/url/index.js 2.84 kB -1.22 kB (42%) 🎉
build/viewport/index.js 1.86 kB -1 B
ℹ️ View Unchanged
Filename Size Change
build/annotations/index.js 3.8 kB 0 B
build/api-fetch/index.js 3.42 kB 0 B
build/autop/index.js 2.84 kB 0 B
build/block-directory/style-rtl.css 943 B 0 B
build/block-directory/style.css 942 B 0 B
build/block-library/theme-rtl.css 789 B 0 B
build/block-library/theme.css 790 B 0 B
build/block-serialization-spec-parser/index.js 3.06 kB 0 B
build/components/style-rtl.css 15.3 kB 0 B
build/components/style.css 15.3 kB 0 B
build/deprecated/index.js 768 B 0 B
build/dom-ready/index.js 571 B 0 B
build/edit-navigation/style-rtl.css 881 B 0 B
build/edit-navigation/style.css 885 B 0 B
build/edit-post/style-rtl.css 6.42 kB 0 B
build/edit-post/style.css 6.4 kB 0 B
build/edit-widgets/style-rtl.css 3.13 kB 0 B
build/edit-widgets/style.css 3.13 kB 0 B
build/editor/editor-styles-rtl.css 476 B 0 B
build/editor/editor-styles.css 478 B 0 B
build/editor/style-rtl.css 3.85 kB 0 B
build/editor/style.css 3.85 kB 0 B
build/escape-html/index.js 735 B 0 B
build/format-library/style-rtl.css 547 B 0 B
build/format-library/style.css 548 B 0 B
build/html-entities/index.js 623 B 0 B
build/is-shallow-equal/index.js 698 B 0 B
build/keycodes/index.js 1.94 kB 0 B
build/list-reusable-blocks/style-rtl.css 476 B 0 B
build/list-reusable-blocks/style.css 476 B 0 B
build/nux/style-rtl.css 671 B 0 B
build/nux/style.css 668 B 0 B
build/primitives/index.js 1.43 kB 0 B
build/warning/index.js 1.14 kB 0 B
build/wordcount/index.js 1.22 kB 0 B

compressed-size-action

@jasmussen
Copy link
Contributor

Nice PR!

I think you need to touch the borders on each individual gallery item instead of the gallery itself, becasue the outsetting of the border makes the placeholder differ from other placeholders. Before:

Screenshot 2020-11-27 at 10 07 20

After:

Screenshot 2020-11-27 at 10 02 53

If you adjust the box shadow on .blocks-gallery-item figure.is-selected to be inset, you can probably make it work.

@karmatosed karmatosed changed the title Adjusts borders on gallery to prevent overlap Adjust borders on gallery to prevent overlap Nov 27, 2020
@karmatosed
Copy link
Member Author

karmatosed commented Nov 27, 2020

Great feedback, thank you @jasmussen. I'm going to dig a bit more here as seems the images might hold the way forward for borders. There are some inconsistencies which as noted when more nuanced handling for child/parent blocks should help. For example I wonder if you should be able to see the outer and inner borders at the same time. I would suggest you shouldn't.

Clicking on individual item to me should result in just this:

image

Whereas clicking on the container would show:

outline

This feels beyond scope here potentially, but it certainly is something I'll follow through with other tickets, for example #27075. If there is a consistent way then styling these would be easier.

@karmatosed
Copy link
Member Author

I just updated this with a fix that focuses on the inner elements. Props to @ItsJonQ for some CSS guidance.

After:

2020-11-27 17 30 53

@@ -38,13 +38,25 @@ figure.wp-block-gallery {
}

figure.is-selected {
box-shadow: 0 0 0 $border-width $white, 0 0 0 3px var(--wp-admin-theme-color);

border-radius: $radius-block-ui;
Copy link

Choose a reason for hiding this comment

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

🎉 ! I noticed this during our 🍐 'ing session @karmatosed . The corners of the image seem to be peaking out from the focus ring. I think that would be resolved if we add this back in

Copy link
Member Author

@karmatosed karmatosed Nov 30, 2020

Choose a reason for hiding this comment

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

Unfortunately when I add that back in the overlap returns. There is the option of doing 'box-shadow: 0 0 0 $border-width $white;' but it then gives a slightly weird white outline. I'm very open to any ideas here as would love to get this smooth visually.

@karmatosed
Copy link
Member Author

karmatosed commented Nov 30, 2020

I just updated some iterations that take away the border-radius as it's not having an effect on this component. @jasmussen looping you in to check that this still keeps the component's visual consistency. With it in there was an artifact appearing as noted by @ItsJonQ.

image

It's my feeling that this is a good middle ground point to get for now around the overlap, as previously said longer term would be the iterations to this block planned.

Copy link
Contributor

@jasmussen jasmussen left a comment

Choose a reason for hiding this comment

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

Left some small comments, but this seems good.

Before:

before

After:

gallery

Although the focus style isn't perfect, it's better than before where it broke out of the boundary of the parent container.

Thank you!

img {
border-radius: $radius-block-ui;
&::before {
bottom: 0;
Copy link
Contributor

Choose a reason for hiding this comment

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

I know I'm being extremely nitpicky here, but I trust you'll forgive me.

I like to group related CSS together, so for example:

position: absolute;
top: 0;
right: 0;
bottom: 0;
left: 0;

— That is, the position is first, and then the directions shown one by one, clockwise, top right bottom left.

box-shadow: 0 0 0 $border-width $white inset, 0 0 0 3px var(--wp-admin-theme-color) inset;
content: "";
left: 0;
outline: 2px solid transparent;
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe add after this line, // Shown in Windows 10 high contrast mode. as a comment

@karmatosed
Copy link
Member Author

@jasmussen thanks for that feedback, it was great and always keen to refine. I've made those changes and if you agree will then move this to merge. Thanks.

@karmatosed
Copy link
Member Author

I am just catching up on some old PRs sat. This seems like it can be merged without any issues still, so I am going to do just that right now.

@karmatosed karmatosed merged commit c386782 into master Jan 15, 2021
@karmatosed karmatosed deleted the try/gallery-border-iterations branch January 15, 2021 18:33
@github-actions github-actions bot added this to the Gutenberg 9.9 milestone Jan 15, 2021
ockham pushed a commit that referenced this pull request Feb 15, 2021
…bsolute positioned border. (#28992)

#27312 introduced some absolute positioning to the gallery image border to fix some layout issues, but because this had a z-index specified it was sitting over the top of the caption which could no longer be selected.

This PR just adds a z-index to caption also so it sits over the border.

Co-authored-by: Glen Davies <glen.davies@a8c.com>
ockham pushed a commit that referenced this pull request Feb 15, 2021
…bsolute positioned border. (#28992)

#27312 introduced some absolute positioning to the gallery image border to fix some layout issues, but because this had a z-index specified it was sitting over the top of the caption which could no longer be selected.

This PR just adds a z-index to caption also so it sits over the border.

Co-authored-by: Glen Davies <glen.davies@a8c.com>
ockham pushed a commit that referenced this pull request Feb 15, 2021
…bsolute positioned border. (#28992)

#27312 introduced some absolute positioning to the gallery image border to fix some layout issues, but because this had a z-index specified it was sitting over the top of the caption which could no longer be selected.

This PR just adds a z-index to caption also so it sits over the border.

Co-authored-by: Glen Davies <glen.davies@a8c.com>
noisysocks pushed a commit that referenced this pull request Mar 5, 2021
…bsolute positioned border. (#28992)

#27312 introduced some absolute positioning to the gallery image border to fix some layout issues, but because this had a z-index specified it was sitting over the top of the caption which could no longer be selected.

This PR just adds a z-index to caption also so it sits over the border.

Co-authored-by: Glen Davies <glen.davies@a8c.com>
noisysocks pushed a commit that referenced this pull request Mar 5, 2021
…bsolute positioned border. (#28992)

#27312 introduced some absolute positioning to the gallery image border to fix some layout issues, but because this had a z-index specified it was sitting over the top of the caption which could no longer be selected.

This PR just adds a z-index to caption also so it sits over the border.

Co-authored-by: Glen Davies <glen.davies@a8c.com>
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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants