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

Implement zero grid spacing and border collapsing #1464

Open
wants to merge 15 commits into
base: main
Choose a base branch
from
Open
30 changes: 30 additions & 0 deletions assets/base.css
Original file line number Diff line number Diff line change
Expand Up @@ -2826,6 +2826,36 @@ details-disclosure > details {
border-right: none;
}

.grid--collapsed-x.contains-content-container,
.grid--collapsed-x.contains-media {
padding-right: var(--collapsed-offset-x);
}

.grid--collapsed-y.contains-content-container,
.grid--collapsed-y.contains-media {
padding-bottom: var(--collapsed-offset-y);
}

.grid--collapsed-x.contains-content-container .content-container,
.grid--collapsed-x.contains-media .global-media-settings {
margin-right: var(--collapsed-offset-x);
}

.grid--collapsed-y.contains-content-container .content-container,
.grid--collapsed-y.contains-media .global-media-settings {
margin-bottom: var(--collapsed-offset-y);
}

.grid--collapsed-x.contains-content-container .content-container:after,
.grid--collapsed-x.contains-media .global-media-settings:after {
margin-left: var(--collapsed-shadow-offset-x);
}

.grid--collapsed-y.contains-content-container .content-container:after,
.grid--collapsed-y.contains-media .global-media-settings:after {
margin-top: var(--collapsed-shadow-offset-y);
}
Comment on lines +2839 to +2857
Copy link
Contributor

Choose a reason for hiding this comment

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

Do you need to include the contains-xyz here for specificity?

.grid--collapsed-y .content-container:after,
.grid--collapsed-y .global-media-settings:after {
  margin-top: var(--collapsed-shadow-offset-y);
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We discussed this a bit already but will respond with my thoughts here for ref. Including the contains classes here was a little bit of premature optimization to protect against future possible cases like content-container grid items that also have children using .global-media-settings. We wouldn't want any collapsed grid styles to apply to the deeper children. Maybe this won't ever occur, but I'm not certain.

This does unnecessarily create slightly higher specifically right now, but I see the collapsed grid as something that's hard to test at scale and likely to have regressions go unnoticed. For these reasons I like the idea of a little additional futureproof-ness. I don't necessarily think the collapsed grid styles being more difficult to override is a totally bad thing in some cases.

I think for now we can include the removal of this a follow up enhancement to consider. I'm sure there are other things that will also fit into this category.


/* check for flexbox gap in older Safari versions */
@supports not (inset: 10px) {
.grid {
Expand Down
84 changes: 74 additions & 10 deletions assets/collage.css
Original file line number Diff line number Diff line change
Expand Up @@ -21,23 +21,23 @@
grid-template-columns: repeat(2, minmax(0, 1fr));
}

.collage--mobile .collage__item--left:nth-child(3n - 2) {
.collage--mobile .collage__item--left:first-child {
grid-column: span 2;
}

.collage--mobile .collage__item--left:nth-child(3n - 2):nth-last-child(2) {
.collage--mobile .collage__item--left:first-child:nth-last-child(2) {
grid-column: span 1;
}

.collage--mobile .collage__item--left:nth-child(3n) {
grid-column-start: 2;
}

.collage--mobile .collage__item--right:nth-child(3n - 2) {
.collage--mobile .collage__item--right:first-child {
grid-column-start: 1;
}

.collage--mobile .collage__item--right:nth-child(3n - 2):last-child {
.collage--mobile .collage__item--right:first-child:last-child {
grid-column: span 2;
}

Expand All @@ -58,12 +58,12 @@
grid-template-columns: repeat(3, minmax(0, 1fr));
}

.collage__item--left:nth-child(3n - 2) {
.collage__item--left:first-child {
grid-column: 1 / span 2;
grid-row: span 2;
}

.collage__item--left:nth-child(3n - 2):last-child {
.collage__item--left:first-child:last-child {
Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks for updating this. I find this very readable now. 🙏🏻

grid-column: 1 / span 3;
}

Expand All @@ -76,12 +76,12 @@
grid-row: span 2;
}

.collage__item--right:nth-child(3n - 2) {
.collage__item--right:first-child {
grid-column: 1 / span 1;
grid-row: span 1;
}

.collage__item--right:nth-child(3n - 2):last-child {
.collage__item--right:first-child:last-child {
grid-column: 1 / span 3;
}

Expand Down Expand Up @@ -120,9 +120,9 @@
box-shadow: var(--card-shadow-horizontal-offset) var(--card-shadow-vertical-offset) var(--card-shadow-blur-radius) rgba(var(--color-shadow), var(--card-shadow-opacity));
content: '';
position: absolute;
width: calc(var(--card-border-width) * 2 + 100%);
height: calc(var(--card-border-width) * 2 + 100%);
top: calc(var(--card-border-width) * -1);
right: calc(var(--card-border-width) * -1);
bottom: calc(var(--card-border-width) * -1);
left: calc(var(--card-border-width) * -1);
z-index: -1;
}
Expand Down Expand Up @@ -183,3 +183,67 @@
.collage .collage-card-spacing img {
object-fit: contain;
}

.collage--collapsed-y .collage__item .card--card,
.collage--collapsed-y .collage__item--collection .card--text,
.collage--collapsed-y .collage-card {
height: calc(100% + var(--card-border-width));
}

.collage--collapsed-x .collage-card {
width: calc(100% + var(--card-border-width));
}
Comment on lines +193 to +195
Copy link
Contributor

Choose a reason for hiding this comment

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

It's not clear to me why we won't need to apply this style to .card-wrapper, like we do for height. Can you explain it? Thanks 🙏🏻

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good question. I think this is here to override the .collage-item > * style { width: 100% } at the top of collage.css. It's possible I could be reseting to width: auto instead, but this probably seemed a little more explicit at the time. The difference I'm sure has to do with where the actual border styles are being applied relative to the where any width/height dimensions are being applied. The height: 100% calc stuff is needed for both because we want cards to stretch to fill the row height (while still using border-box sizing).


/* offset collage for border collapsing */
.collage--collapsed-x {
padding-right: var(--card-border-width);
}
.collage--collapsed-y {
padding-bottom: var(--card-border-width);
}

/* offset collage cards for border collapsing */
.collage--collapsed-x :where(.card, .collage-card) {
margin-right: calc(var(--card-border-width) * -1);
}
.collage--collapsed-y :where(.card--card, .text--only, .collage-card) {
margin-bottom: calc(var(--card-border-width) * -1);
}

@media screen and (min-width: 750px) {
/* offset collage card shadows to prevent overlap */
.collage--collapsed-x .collage__item--left:first-child :where(.card--card, .collage-card):after,
.collage--collapsed-x .collage__item--left:first-child .card--standard .card__inner:after {
margin-right: var(--card-border-width);
}
.collage--collapsed-x .collage__item--right:last-child :where(.card--card, .collage-card):after,
.collage--collapsed-x .collage__item--right:last-child .card--standard .card__inner:after {
margin-left: var(--card-border-width);
}
.collage--collapsed-y .collage__item--left:nth-child(3) :where(.card--card, .collage-card):after {
margin-top: var(--card-border-width);
}
.collage--collapsed-y .collage__item--right:first-child :where(.card--card, .collage-card):after {
margin-bottom: var(--card-border-width);
}
}

@media screen and (max-width: 749px) {
/* offset collage card shadows to prevent overlap */
.collage--collapsed-y:not(.collage--mobile) .collage__item:not(:first-child) :where(.card--card, .collage-card):after,
.collage--collapsed-y.collage--mobile .collage__item--right:nth-child(3) :where(.card--card, .collage-card):after,
.collage--collapsed-y.collage--mobile .collage__item--right:nth-child(3) .card--standard .card__inner:after {
margin-top: var(--card-border-width);
}
.collage--mobile.collage--collapsed-y .collage__item--left:first-child :where(.card--card, .collage-card):after {
margin-bottom: var(--card-border-width);
}
.collage--mobile.collage--collapsed-x .collage__item--left:nth-child(3) :where(.card--card, .collage-card):after,
.collage--mobile.collage--collapsed-x .collage__item--left:nth-child(3) .card--standard .card__inner:after {
margin-left: var(--card-border-width);
}
.collage--mobile.collage--collapsed-x .collage__item--right:first-child :where(.card--card, .collage-card):after,
.collage--mobile.collage--collapsed-x .collage__item--right:first-child .card--standard .card__inner:after {
margin-right: var(--card-border-width);
}
}
60 changes: 50 additions & 10 deletions assets/component-card.css
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@
.card--standard .card__inner:after {
content: '';
position: absolute;
width: calc(var(--card-border-width) * 2 + 100%);
height: calc(var(--card-border-width) * 2 + 100%);
top: calc(var(--card-border-width) * -1);
right: calc(var(--card-border-width) * -1);
bottom: calc(var(--card-border-width) * -1);
left: calc(var(--card-border-width) * -1);
z-index: -1;
border-radius: var(--card-corner-radius);
Expand All @@ -53,6 +53,42 @@
border-bottom-left-radius: 0;
}

.grid--collapsed-y.contains-card .card:where(.card--card, .card--text) {
height: calc(100% - var(--collapsed-offset-y));
}

/* offset card grids for border collapsing
* note: also allows blog/collection grid to vertically collapse
*/
.grid--collapsed-x.contains-card {
padding-right: var(--collapsed-offset-x);
}
.grid--collapsed-y.contains-card:not(.contains-card--standard),
.grid--collapsed-y.contains-card--standard:not(.product-grid) {
padding-bottom: var(--collapsed-offset-y);
}

/* offset cards for border collapsing
* note: also allows standard style text-only article/collection cards to vertically collapse
*/
.grid--collapsed-x.contains-card .card {
margin-right: var(--collapsed-offset-x);
}
.grid--collapsed-y.contains-card .card--card,
.grid--collapsed-y.contains-card:not(.product-grid) .card--standard.card--text {
margin-bottom: var(--collapsed-offset-y);
}

/* offset card shadows */
.grid--collapsed-x.contains-card .card--card:after,
.grid--collapsed-x.contains-card .card--standard .card__inner:after {
margin-left: var(--collapsed-shadow-offset-x);
}
/* vertically offset shadows for card style cards only */
.grid--collapsed-y.contains-card .card--card:after {
margin-top: var(--collapsed-shadow-offset-y);
}

.card--standard.card--text {
background-color: transparent;
}
Expand Down Expand Up @@ -161,14 +197,6 @@
margin-top: calc(0rem - var(--card-image-padding));
}

.card--standard.card--text a::after,
.card--card .card__heading a::after {
bottom: calc(var(--card-border-width) * -1);
left: calc(var(--card-border-width) * -1);
right: calc(var(--card-border-width) * -1);
top: calc(var(--card-border-width) * -1);
}

.card__heading a::after {
bottom: 0;
content: "";
Expand All @@ -179,6 +207,18 @@
z-index: 1;
}

.card--standard.card--text a::after,
.card--card .card__heading a::after {
bottom: calc(var(--card-border-width) * -1);
left: calc(var(--card-border-width) * -1);
right: calc(var(--card-border-width) * -1);
top: calc(var(--card-border-width) * -1);
}

.grid--collapsed-x .card--standard a::after {
right: calc(var(--card-border-width) * -1);
}

.card__heading a:after {
outline-offset: 0.3rem;
}
Expand Down
35 changes: 35 additions & 0 deletions assets/component-slider.css
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,16 @@ slider-component.slider-component-full-width {
.slider.slider--mobile.contains-content-container .slider__slide {
--focus-outline-padding: 0rem;
}

.slider.slider--mobile.grid--collapsed .slider__slide {
--collapsed-offset-y: 0px;
--collapsed-shadow-offset-y: 0px;
--collapsed-shadow-offset-x: var(--border-width);
}

.slider.slider--mobile.grid--collapsed .slider__slide:first-child {
--collapsed-shadow-offset-x: 0px;
}
}

@media screen and (min-width: 750px) {
Expand Down Expand Up @@ -103,6 +113,17 @@ slider-component.slider-component-full-width {
.slider.slider--tablet.contains-content-container .slider__slide {
--focus-outline-padding: 0rem;
}

.slider.slider--tablet.grid--collapsed .slider__slide {
--collapsed-offset-y: 0px;
--collapsed-shadow-offset-y: 0px;
--collapsed-shadow-offset-x: var(--border-width);
}

.slider.slider--tablet.grid--collapsed .slider__slide:first-child {
--collapsed-shadow-offset-x: 0px;
}
Comment on lines +118 to +125
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 this needs to be applied to the desktop slider as well:

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added the slider overrides to desktop grid which should resolve this.

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's just that the calculation is based on the horizontal space value and when it's set to 0 then it means no extra space for the grid peek. Should be easy to fix in another PR (I can create the issue) by adding - 2rem to the calculation of the grid item width.

Copy link
Contributor

Choose a reason for hiding this comment

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

Just a question around css variable assignment.
Do you need to apply it to the slider_slide?

I would have thought that applying it to slider.slider--tablet.grid--collapsed would mean that the slide would inherit the correct value. And then you could use slider_slide:first-child to overwrite it in certain situations.

  .slider--tablet.grid--collapsed {
    --collapsed-offset-y: 0px;
    --collapsed-shadow-offset-y: 0px;
    --collapsed-shadow-offset-x: var(--border-width);
  }
  
  .slider--tablet.grid--collapsed .slider__slide:first-child {
    --collapsed-shadow-offset-x: 0px;
  }

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 applying it to a slider__slide just because the selectors these are attempting to override is applied to slider__slide (grid__item).

Basically, the first rule is overriding the values (from grid-collapsed.css) on all the slides purposefully. For example.. If a slider grid has .grid--2-col-tablet-down then every other item would have 0px shadow offset. Since an active slider wouldn't be in a 2 column format, we want all items to have the same x offset, except for the first.

This is the type of selector sliders need to override from grid-collapsed.css..

/* reset shadow origin along first row/col so its flush with grid edge */
  .grid--1-col-tablet-down.grid--collapsed-x .grid__item,
  .grid--2-col-tablet-down.grid--collapsed-x .grid__item:nth-child(2n + 1) {
    --collapsed-shadow-offset-x: 0px;
  }

Also in the corner commit it looks like I had to add even more specificity here and that prompted me to include a comment /* certain specificity needed for all rules below, modify with care */.


}

.slider--everywhere {
Copy link
Contributor

Choose a reason for hiding this comment

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

We will also need to change/edit the width of the slides for .slider--desktop.grid--4-col-desktop .grid__item. As the slider on desktop isn't showing the peek anymore. But could be a quick follow up issue. same screenshot as above

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Could you open a ticket for this with notes on what you think needs to be done for this? I'm not familiar with the new desktop slider. It's odd that the other grid width calculations adjust just fine as is.

Copy link
Contributor

Choose a reason for hiding this comment

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

Expand Down Expand Up @@ -191,6 +212,20 @@ slider-component.slider-component-full-width {
.slider.slider--desktop.contains-content-container .slider__slide {
--focus-outline-padding: 0rem;
}

.slider.slider--desktop.contains-content-container .slider__slide {
--focus-outline-padding: 0rem;
}
/* specificity here matters */
.slider.slider--desktop.grid--collapsed .slider__slide.grid__item {
--collapsed-offset-y: 0px;
--collapsed-shadow-offset-y: 0px;
--collapsed-shadow-offset-x: var(--border-width);
}

.slider.slider--desktop.grid--collapsed .slider__slide:first-child {
--collapsed-shadow-offset-x: 0px;
}
}

@media (prefers-reduced-motion) {
Expand Down
51 changes: 51 additions & 0 deletions assets/grid-collapsed.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
/*
Copy link
Contributor Author

@kmeleta kmeleta Mar 8, 2022

Choose a reason for hiding this comment

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

This file will eventually be.. a lot. I figure it might be worthwhile to at least define some of the vars and things in comments, but I'm happy to remove them if they're not helpful.

--collapsed-offset-x/y: the distance to offset an item's border onto the siblings below and to the right
--collapsed-shadow-offset-x/y: the distance to offset the overlapping shadows caused by offsetting grid items
*/
.grid--collapsed-x {
--collapsed-offset-x: var(--border-width);
}
.grid--collapsed-y {
--collapsed-offset-y: var(--border-width);
}

.grid--collapsed-x .grid__item {
--collapsed-offset-x: calc(var(--border-width) * -1);
--collapsed-shadow-offset-x: var(--border-width);
}
.grid--collapsed-y .grid__item {
--collapsed-offset-y: calc(var(--border-width) * -1);
--collapsed-shadow-offset-y: var(--border-width);
}

@media screen and (max-width: 989px) {
/* reset shadow origin along first row/col so its flush with grid edge */
.grid--1-col-tablet-down.grid--collapsed-x .grid__item,
.grid--2-col-tablet-down.grid--collapsed-x .grid__item:nth-child(2n + 1) {
--collapsed-shadow-offset-x: 0px;
}
.grid--1-col-tablet-down.grid--collapsed-y .grid__item:first-child,
.grid--2-col-tablet-down.grid--collapsed-y .grid__item:nth-child(-n + 2) {
--collapsed-shadow-offset-y: 0px;
}
}

@media screen and (min-width: 990px) {
/* reset shadow origin along first row/col so its flush with grid edge */
.grid--1-col-desktop.grid--collapsed-x .grid__item,
.grid--2-col-desktop.grid--collapsed-x .grid__item:nth-child(2n + 1),
.grid--3-col-desktop.grid--collapsed-x .grid__item:nth-child(3n + 1),
.grid--4-col-desktop.grid--collapsed-x .grid__item:nth-child(4n + 1),
.grid--5-col-desktop.grid--collapsed-x .grid__item:nth-child(5n + 1),
.grid--6-col-desktop.grid--collapsed-x .grid__item:nth-child(6n + 1) {
--collapsed-shadow-offset-x: 0px;
}
.grid--1-col-desktop.grid--collapsed-y .grid__item:nth-child(1),
.grid--2-col-desktop.grid--collapsed-y .grid__item:nth-child(-n + 2),
.grid--3-col-desktop.grid--collapsed-y .grid__item:nth-child(-n + 3),
.grid--4-col-desktop.grid--collapsed-y .grid__item:nth-child(-n + 4),
.grid--5-col-desktop.grid--collapsed-y .grid__item:nth-child(-n + 5),
.grid--6-col-desktop.grid--collapsed-y .grid__item:nth-child(-n + 6) {
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 that the Featured Collection section and Collection template have a 5 column product grid setting. Is there a template or section that has a 6 column option?

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'd love to cut out one those cases out of the collapsed code, but I believe multicolumn allows 6.

--collapsed-shadow-offset-y: 0px;
}
}
12 changes: 1 addition & 11 deletions assets/section-collection-list.css
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,10 @@
}

@media screen and (max-width: 749px) {
.collection-list:not(.slider) {
.collection-list--slider.page-width {
padding-left: 0;
padding-right: 0;
}

.section-collection-list .page-width {
padding-left: 0;
padding-right: 0;
}

.section-collection-list .collection-list:not(.slider) {
padding-left: 1.5rem;
padding-right: 1.5rem;
}
}

.collection-list__item:only-child {
Expand Down
Loading