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

[Product Cards] Add image masks #2302

Merged
merged 67 commits into from
Mar 24, 2023
Merged

[Product Cards] Add image masks #2302

merged 67 commits into from
Mar 24, 2023

Conversation

kjellr
Copy link
Contributor

@kjellr kjellr commented Feb 14, 2023

PR Summary:

Adds seven image masks to product cards (Arch, Blobs, Chevron Left, Chevron Right, Diamond Parallelogram, Diamond, Round).

Examples:

product-cards.mp4

Why are these changes introduced?

These shapes introduce more design possibilities to our merchants.

What approach did you take?

All of these are implemented using CSS clip-path(). The Arch style is created using an SVG mask, while the others are powered by simple polygon() and circle() CSS functions. Many shapes include simple, pure-css hover animations.

The most complicated of these implementations is the Blobs shape. There are six total blob shapes, and the PR uses nth-child() to approximate a random-ish pattern when they're arranged in a product grid. The blobs have been implemented using polygon() instead of using simpler SVG paths, because SVG paths cannot be animated natively with CSS. This approach works well — the main downfall is that polygon() supports points but not curves, and blobs are made of curves. To avoid the shapes looking pointy at large sizes, each blob has 120 points. This gets a little verbose. I've assigned each blob shape to a CSS variable to compensate and maintain code readability.

Other considerations

  • I'd love another developer perspective on the blobs implementation. If we want them to animate (which I think is the most fun part, personally), this seemed like the leanest approach to me.
  • As noted above, many of these shapes include some light hover effects. I did not include checkboxes to turn these off, but we can do that if folks feel strongly about it.
  • The hover effects all respect the visitor's prefers-reduced-motion preferences.
  • The border and shadow product card controls aren’t effective in these new shapes, because the existing implementations don’t work for clip-paths. We could build in alternatives, but that feels overcomplicated (and also not necessarily critical for a v1). For now, I’ve added a note next to the Style control that introduces this caveat. (FWIW, the border radius does partially function in some circumstances, and is kinda cool.).

Decision log

# Decision Alternatives Rationale Downsides
1 Implement product card shape settings on a section level. Implement one global setting that turns the shapes on for all product cards on the store. The shapes are relatively opinionated, so we expect merchants will want to use them sparingly rather than turn them on everywhere all at once. If a merchant does want to use the shapes globally, they'll need to track down all instances of product cards and change the shapes for those individual Sections.

Visual impact on existing themes

These shapes are off by default, and are optional. I don't expect any issues using them on other Dawn-based themes.

Testing steps/scenarios

  1. Visit the demo store.
  2. Add a Featured Collection section.
  3. In the Product Cards section of the settings panel, use the "Image Shape" dropdown to change the image shape.
  4. Try all 7 of the supplied image shapes.
  5. Change other Section settings, to ensure they don't interfere with the image shape.
  6. Scale the viewport from desktop down to mobile, ensuring that the shapes behave as intended with no clipping.
  7. Repeat steps 2-6 with the following additional sections: Product Grid, Search Results, and Related Products.
  8. Visit Theme Settings, and adjust settings for the product cards (Style, Padding, Color Scheme, etc.) and ensure that the cards don't appear broken.

Checklist

@kjellr kjellr self-assigned this Feb 14, 2023
@stufreen stufreen self-requested a review February 15, 2023 16:07
Copy link
Contributor

@stufreen stufreen left a comment

Choose a reason for hiding this comment

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

Feature and approach look good to me! A few misc comments and questions.

@melissaperreault
Copy link
Contributor

melissaperreault commented Feb 15, 2023

I hope we could bring this to these other sections next:

  • Multicolumn
  • Multirow
  • Collapsible content
  • Collection banner
  • Collection list
  • Blog posts
  • Featured product

@kjellr
Copy link
Contributor Author

kjellr commented Mar 17, 2023

We've had a number of followup discussions about this PR following the thread here. The primary sticking point now just seems to be the way that the shapes interact with existing global settings. I pushed a new approach to getting shadows working as expected, and here's an overview of the way the PR stands today:

  • When the Card style is active, all section + global settings behave as usual. (🎉)
  • When the Standard style is active:
    • All section settings behave as usual. (🎉)
    • The global "Color Scheme" setting changes the color behind transparent images. As such, changes to the color are visible when there's a transparent image, but invisible otherwise. This matches the default behavior. (Example)
    • By default, when the global "Padding" setting is active, but the background color shows up as a kind of stroke. This does not happen when image shapes are present, but the padding is still active. Because padding is still applied and has a visible effect, this seems like generally reasonable behavior to me. (Example)
    • The global "Border" settings have no effect when an image shape is active. We haven't found a great way to manage the border technically, and I think that's fine. The section-level controls now carry a warning about this limitation.
    • The global "Corner Radius" control does work, but its effect is only visible when the shape nears the edges of its container. (Example)
    • The global "Image Shadow" settings are applied to the shape as usual. They also apply to badges if they float outside the shape. (Example)

In general, I think this behavior is alright. The only setting that's thrown out entirely is the border, but we're adding a warning about that. Otherwise, things look pretty good in most reasonable use cases.

Please give this PR another test, and let me know if you agree (or if you don't!). I appreciate everyone sticking with this. 🙌

kmeleta
kmeleta previously approved these changes Mar 17, 2023
Copy link
Contributor

@kmeleta kmeleta left a comment

Choose a reason for hiding this comment

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

Sweet, glad we don't need to ignore as many global settings now. But I guess we reversed our decision to move the shape setting into the card settings? Otherwise gtg 👍

@kjellr
Copy link
Contributor Author

kjellr commented Mar 20, 2023

But I guess we reversed our decision to move the shape setting into the card settings? Otherwise gtg

Yeah, the main benefit of making this global would've been to allow merchants to "clean up" the appearance if it looked broken. But with the last couple commits, I think it's less likely to look broken. 😄

Copy link
Contributor

@stufreen stufreen left a comment

Choose a reason for hiding this comment

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

LGTM 🚀

I'm ok with the compromise with product card global settings if y'all are agreed on this approach. It feels right to me - as a merchant if I was setting an image shape I would not want a border or background if card style is standard.

Copy link
Contributor

@LucasLacerdaUX LucasLacerdaUX left a comment

Choose a reason for hiding this comment

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

LGTM!

Below are the test scenarios I went through. Everything seems to be working as expected and the inclusion of the label to highlight that the border gets overridden by the Image Mask sounds clear enough to me.

  • Mask types
    • Arch
    • Blob
    • Chevron left
    • Chevron right
    • Diamond
    • Parallelogram
    • Round
  • Global Settings
    • Corner Radius
    • Border (Card or No Mask only)
    • Shadows
    • Card Type: Standard
    • Card Type: Card
  • Sections
    • Featured Collection
    • Collection -> Product Grid
    • Search Results
    • Related Products

Copy link
Contributor

@kmeleta kmeleta left a comment

Choose a reason for hiding this comment

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

Still lgtm :shipit:

Copy link
Contributor

@kmeleta kmeleta left a comment

Choose a reason for hiding this comment

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

Actually.. sorry @kjellr, one more thing 😬 Were section onboarding states discussed at all? Noticed that these don't receive any shapes currently. It's probably fine if you wanted to handle this in a fast follow PR, but I do think we should address it.

@LucasLacerdaUX
Copy link
Contributor

☝️ This is also how any product card for products with no images looks like. I assumed it was intentional, as there is no image in these cards for a shape to be applied to.

We can revisit whether or not the onboarding states should include a demo image, but just like Image ratio setting the Image shape one shouldn't apply to this type of card.

image

@kjellr
Copy link
Contributor Author

kjellr commented Mar 23, 2023

Thanks for the heads up! That's right, the lack of shape in text cards was intentional. The feature is framed as an "image mask", so if there's no image, no shape is applied.

It's a little unfortunate that the control won't have an effect when the start state for the section is applied — I can open a followup issue after merge to look at it.

@kmeleta
Copy link
Contributor

kmeleta commented Mar 23, 2023

It's definitely unfortunate if a theme using shapes intentionally as part of its art direction might not show the shapes in its initial state, butwould accurately portray other card styles. I know they're technically text cards in this state, but we certainly intend to inform how the cards will actually display with the onboarding states. I feel like (and hope) products without images are super rare irl.

I'm good to proceed for now 👍 but we'll probably want to circle back with Meli and get her thoughts on it if we're inclined to keep things this way.

@kjellr
Copy link
Contributor Author

kjellr commented Mar 23, 2023

Yeah — even setting this specific issue aside, I feel like having an image preview in there by default would be a nicer experience. Most merchants have product images, so it'd feel more appropriate in general. We'll sort out something that works.

@kjellr
Copy link
Contributor Author

kjellr commented Mar 24, 2023

I've opened #2466 for us to continue discussing the placeholder state, and we'll continue working through the other iterations of this feature in #2380. Thanks for sticking with this one through its lengthy review process! 🙌

@kjellr kjellr merged commit b19972d into main Mar 24, 2023
@kjellr kjellr deleted the try-image-shapes branch March 24, 2023 11:46
pangloss added a commit to pangloss/dawn that referenced this pull request Mar 26, 2023
* shopify/main:
  Snippetize header menu components (Shopify#2401)
  Release bump shadow fix (Shopify#2469)
  Update 1 translation file (Shopify#2459)
  [Product Cards] Add image masks (Shopify#2302)
  [Feature] reveal on scroll animations (Shopify#2367)
phapsidesGT pushed a commit to Gravytrain-UK/gt-shopify-dawn-theme that referenced this pull request Sep 3, 2024
* Initial commit

* Add more transforms, improve blob shape.

* Add lots of blob shapes.

* Fix filtering.

* Remove image filters.

* Remove filter code.

* Fix circle shape.

* Animate circle hovers.

* Add additional hovers.

* Animate all the blobs.

* Fix standalone image with text blob.

* Stop applying scale hover for cards when blobby.

* Cleanup, add arch style.

* Animate the arch.

* Move svg renders out of theme.liquid.

* Use all masks in all places. Tidy up.

* Ensure svg is hidden from view.

* Fix name of circle shape.

* Add warning about shadow and border.

* Fine-tune the blob shapes.

* Tidy up the shapes used.

* Respect prefers-reduced-motion

* Fix typo.

* Match circle animation to the image zoom.

* Alphabetize options.

* Remove border clipping for image banner shapes.

* Round blob coordinates down to three decimal places..

* Remove Image with Text hovers.

* Rewrite the helper text to be more positive.

Co-authored-by: melissaperreault <melissa.perreault@shopify.com>

* Add settings for Search & Product Collection

* Add settings for related products.

* Remove label about border and shadow.

* Remove unused settings schema entry.

* Blobs > Blob

* Remove borders from shapes.

* Remove unnecessary specificity from card shape rules.

* Use consistent card hover selectors.

* Remove unnecessary rules.

* Use a shared class approach for applying shapes.

* Remove unnecessary rule.

These styles aren't currently applied to the collage section at all.

* Remove extra space.

* Use a generic image_shape schema to avoid duplication.

* Reinstate the grow-on-hover for blob product cards.

* Fix background color for text-only cards.

* Use "Round" instead of "Oval" and "Circle"

* Fix Image with Text labels.

* Try fixing the circle clipping.

* Try fixing interactions with global container settings.

* Refector last commit, fix tiny bugs.

* Cleanup

* Remove image with text effects from this PR.

* Move mask-blobs into a CSS file.

* Fix card--shape class conditional.

* Fix the image_shape description.

Co-authored-by: Lucas Lacerda <37168033+LucasLacerdaUX@users.noreply.github.com>

* Use a unique id naming convention for the Arch shape svg.

* Update 20 translation files

* Get shape shadows working.

* Add warning about borders not working.

* Update 17 translation files

* Update 3 translation files

---------

Co-authored-by: melissaperreault <melissa.perreault@shopify.com>
Co-authored-by: Lucas Lacerda <37168033+LucasLacerdaUX@users.noreply.github.com>
Co-authored-by: translation-platform[bot] <34770790+translation-platform[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Category: Enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants