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

fix(atomic): atomic-product layout in grid mode consistent on all screen sizes #4527

Open
wants to merge 11 commits into
base: master
Choose a base branch
from

Conversation

fpbrault
Copy link
Contributor

This PR fixes some layout issues for atomic-product that where present on small desktop screen sizes.

Before:
image

After:
image

https://coveord.atlassian.net/browse/KIT-3648

Copy link

github-actions bot commented Oct 10, 2024

Pull Request Report

PR Title

✅ Title follows the conventional commit spec.

Live demo links

Bundle Size

File Old (kb) New (kb) Change (%)
case-assist 236.6 236.6 0
commerce 339.3 339.3 0
search 412 412 0
insight 400 400 0
recommendation 248.8 248.8 0
ssr 405.7 405.7 0
ssr-commerce 351.6 351.6 0

SSR Progress

Use case SSR (#) CSR (#) Progress (%)
search 39 44 89
recommendation 0 4 0
case-assist 0 6 0
insight 0 27 0
commerce 0 15 0
Detailed logs search : buildInteractiveResult
search : buildInteractiveInstantResult
search : buildInteractiveRecentResult
search : buildInteractiveCitation
search : buildGeneratedAnswer
recommendation : missing SSR support
case-assist : missing SSR support
insight : missing SSR support
commerce : missing SSR support

@@ -18,7 +18,7 @@
&.image-large {
atomic-product-section-children .product-child {
@mixin aspect-ratio-h 1 / 1, auto;
width: 33%;
width: 16.65%;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

These two changes ensure that the size ratio between product variants images and the main image stays consistent on all imageSize options at all screen widths

@@ -0,0 +1,11 @@
.display-grid {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This makes the height of the product price always the same regardless of the presence of a promo price or not.

Comment on lines 217 to 218
@media (min-width: 1024px) {
grid-template-columns: repeat(3, 1fr);
}
@media (min-width: 1280px) {
grid-template-columns: repeat(4, 1fr);
}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This new breakpoint prevents the variant icons from being too small, and other issues due to lack of space.

Copy link
Contributor

Choose a reason for hiding this comment

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

Would it be better to try to fix this with a min width ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

What do you mean? Since we are in display: grid a min width would cause the right column to overflow I think..

Copy link
Contributor

Choose a reason for hiding this comment

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

I mean a min width for the icon specifically. The goal is for the icon to not get super small so in my head the easier solution is to add a min width to it.

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 see! We would still end up with the other issues, 4 columns is really a lot at that width because of the facet column.

Comment on lines +165 to +173
<Host>
{this.label.trim() !== '' && this.renderLabel()}
<div>{this.children.map((child) => this.renderChild(child))}</div>
</div>
<div class="children-container">
{this.children.map((child) => this.renderChild(child))}
<Button style="text-primary" class="product-child plus-button">
+{this.children.length - 5}
</Button>
</div>
</Host>
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Limiting the number of product children to a single row avoids this kind of issue:

Screen.Recording.2024-10-11.at.11.04.44.AM.mov

However this hardcodes the + button count to 6 per row. Not sure how we could have this update dynamically based on how many children are hidden...

Two alternatives:

  • Not having the product update on hover, only on click/touch.
  • Ensure all elements in the grid template have a fixed height between variants. This is the case except for the title which can be up to 2 lines tall

Copy link
Contributor

Choose a reason for hiding this comment

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

How did you manage to have duplicates row of the variants ? Are these different variants but with the same image ?

I also found another problem with the fix. Here I would assume the +1 to show me the other variants and not to redirect me.

Screen.Recording.2024-10-11.at.3.27.14.PM.mov

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@alexprudhomme I added the duplicates by temporarily modify the code. This was just to make it easier to demo the issue.

The behaviour with the + button opening the product page is extremely common on e-commerce sites. Clicking to see the other variants implies that the user is interested in the product, so it makes a lot of sense to bring them to the product page. A less common alternative is the + not being interactive at all.

Comment on lines +42 to 53
&.image-large {
atomic-product-section-children .product-child {
@mixin aspect-ratio-h 1 / 1, auto;
width: 16.65%;
}
}
&.image-small {
atomic-product-section-children .product-child {
@mixin aspect-ratio-h 1 / 1, auto;
width: 16.65%;
max-width: 4.75rem;
}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This prevents the product children images from getting too big relative to the main image on wide mobile screen sizes.

Before:
image

After:
image

Comment on lines +64 to +95

&.density-comfortable {
&.image-icon,
&.image-none,
&.image-small,
&.image-large {
& atomic-product-section-description {
margin-top: 1.25rem;
}
}
}
&.density-normal {
&.image-icon,
&.image-none,
&.image-small,
&.image-large {
& atomic-product-section-description {
margin-top: 0.75rem;
}
}
}

&.density-compact {
&.image-icon,
&.image-none,
&.image-small,
&.image-large {
& atomic-product-section-description {
margin-top: 0.25rem;
}
}
}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This helps keep the layout compact when a product does not have a promo price

'title'
'title-metadata'
'emphasized'
'excerpt'
'children'
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Moved this down to keep layout consistent on all screen sizes and display modes

Copy link
Contributor

@alexprudhomme alexprudhomme left a comment

Choose a reason for hiding this comment

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

Thanks for the detailed comments

Base automatically changed from KIT-3608 to master October 17, 2024 13:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants