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

Cleanup product media grid spacing #1444

Merged
merged 4 commits into from
Mar 8, 2022
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions assets/base.css
Original file line number Diff line number Diff line change
Expand Up @@ -177,8 +177,8 @@
--shadow-opacity: var(--text-boxes-shadow-opacity);
}

.product__media-gallery .slider,
.product__media-item {
.contains-media,
.global-media-settings {
Copy link
Contributor

Choose a reason for hiding this comment

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

There's an opportunity to merge some of the theme level settings css with this approach. Possibly a refactor/cleanup to simplify the css that's currently duplicated in some places.

Copy link
Contributor

Choose a reason for hiding this comment

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

Question for you: Is the plan to use these variables lower down in the file on lines 2779 - 2797? I know you didn't add them in this PR, but I don't see them being used anywhere, so I just want to make sure I understand what the plan is moving forward.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes exactly, I'd like to consolidate most of the content-container:after and global-media-settings:after in base.css using the generic --border-width type styles. But I'm also going to heavily rely on them for all the grid collapse stuff. --border-radius will also probably be crucial when consolidating rounded pseudo element focus outlines around the theme. These were originally implement to access shadow offsets in sliders (and I preemptively added all the other ones for future use).

The example below shows what the border collapsing code might look like with and without these kind of cached vars.

/* Using generic vars */
.grid {
  margin-right: var(--border-width)
}
.grid .grid__item:nth-child(2n + 1) {
  margin-left: calc(var(--border-width) * -1)
}

/* NOT using generic vars  */
.grid.contains-media {
  margin-right: var(--media-border-width)
}
.grid.contains-content-container {
  margin-right: var(--text-boxes-border-width)
}
.grid.contains-card {
  margin-right: var(--card-border-width)
}
.grid.contains-media .grid__item:nth-child(2n + 1) {
  margin-left: calc(var(--media-border-width) * -1)
}
.grid.contains-content-container .grid__item:nth-child(2n + 1) {
  margin-left: calc(var(--text-boxes-border-width) * -1)
}
.grid.contains-card .grid__item:nth-child(2n + 1) {
  margin-left: calc(var(--card-border-width) * -1)
}

--border-radius: var(--media-radius);
--border-width: var(--media-border-width);
--border-opacity: var(--media-border-opacity);
Expand Down
17 changes: 10 additions & 7 deletions assets/section-main-product.css
Original file line number Diff line number Diff line change
Expand Up @@ -500,10 +500,6 @@ a.product__text {
padding-right: var(--media-shadow-horizontal-offset);
}

.product__media-item:first-child {
width: 100%;
}

.product--thumbnail .product__media-item:not(.is-active),
.product--thumbnail_slider .product__media-item:not(.is-active) {
display: none;
Expand Down Expand Up @@ -542,7 +538,6 @@ a.product__text {
}

.product__media-list .product__media-item {
padding: 0 0 0.5rem;
width: 100%;
}
}
Expand Down Expand Up @@ -590,6 +585,16 @@ a.product__text {
}

@media screen and (min-width: 990px) {
.product__media-list .product__media-item {
max-width: calc(50% - var(--grid-desktop-horizontal-spacing) / 2);
}

.product__media-list .product__media-item:first-child,
.product__media-list .product__media-item--full {
width: 100%;
max-width: 100%;
}

Copy link
Contributor

Choose a reason for hiding this comment

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

These styles are causing unintended changes on the slider on desktop. It seems to be using the same styles as when stacked - so full width images are full width (indented), but 50% images are staying 50% even in the slider.

Screen Shot 2022-03-08 at 9 52 45 AM

Screen Shot 2022-03-08 at 9 52 23 AM

Screen Shot 2022-03-08 at 9 53 18 AM

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.

Ah thanks, good find. I guess I never checked the second item in the other layouts.. I've now scoped the 50% style to the stacked layout since that's the only one it's relevant to. dff2925

.product__modal-opener .product__media-icon {
opacity: 0;
}
Expand Down Expand Up @@ -967,7 +972,6 @@ a.product__text {

.thumbnail-list {
display: grid;
margin-left: -1rem;
grid-template-columns: repeat(4, 1fr);
}
}
Expand All @@ -978,7 +982,6 @@ a.product__text {

@media screen and (min-width: 990px) {
.thumbnail-list {
margin-left: 0;
grid-template-columns: repeat(4, 1fr);
}

Expand Down
2 changes: 1 addition & 1 deletion sections/main-product.liquid
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
<a class="skip-to-content-link button visually-hidden" href="#ProductInfo-{{ section.id }}">
{{ "accessibility.skip_to_product_info" | t }}
</a>
<ul id="Slider-Gallery-{{ section.id }}" class="product__media-list grid grid--peek list-unstyled slider slider--mobile" role="list">
<ul id="Slider-Gallery-{{ section.id }}" class="product__media-list contains-media grid grid--peek list-unstyled slider slider--mobile" role="list">
{%- liquid
assign variant_images = product.images | where: 'attached_to_variant?', true | map: 'src'
assign media_count = product.media.size
Expand Down