-
Notifications
You must be signed in to change notification settings - Fork 5
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
uniform product image size #941
Conversation
- update css for product-prominentimage-clickable and product-prominentimage cards to have fixed height of 300px that fill the whole width (maintain its aspect ratio, clipped to fit) J=SLAP-1553 TEST=manual - add product entities with different image sizes, launched test site and see that all images are properly sized.
width: 100%; | ||
flex-shrink: 0; | ||
} | ||
|
||
&-img | ||
{ | ||
width: 100%; | ||
height: auto; | ||
height: 300px; | ||
object-fit: cover; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
does this work on ie11? I had issues getting object-fit to work on it before
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you are right, it didn't work. I updated to use a div with background image instead of img tag, so we can use background-position and background-size similiar to object-position and object-fit. this should work in all browser
width: 100%; | ||
flex-shrink: 0; | ||
} | ||
|
||
&-img | ||
{ | ||
width: 100%; | ||
height: auto; | ||
height: 300px; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just checking that there's no drawbacks to having a fixed height that Rose might care about?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For uniform size, I think a fixed height have to be implemented. This was used in the HH link from the jira item as well. But it seems like Rose is reconsidering this change and leaving the images as what we have before.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if Rose doesn't double back this lgtm!
@@ -20,6 +20,10 @@ class product_prominentimageCardComponent extends BaseCard['product-prominentima | |||
} | |||
const linkTarget = AnswersExperience.runtimeConfig.get('linkTarget') || '_top'; | |||
|
|||
//polyfill styling for ie11 | |||
var someImages = document.querySelectorAll('.HitchhikerProductProminentImage-img'); | |||
HitchhikerJS.objectFitImages(someImages); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
would it be possible to do the global polyfill for this, and take this out of the specific card components? We probably don't want to run this every render, and this isn't really the responsibility of the card anyway. Maybe we could do it only the legacy bundle
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will try, does ie11 only use the legacy bundles?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yup!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So this can't be in entry-legacy.js because this script is invoked before the images on html page are loaded. The polyfill function require the src link populated in the img tag then convert to some inline css styling in the tag.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah ok got it, maybe we can shuffle this off to the base card component to hide some implementation? like maybe we can add a flag to the child card's constructor (or even have a list of cards in the base card component?)
taking it out of the child cards, in whatever way we decide, will also make it easier to tweak forked versions of these cards in the future.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this polyfill work in a way where it doesn't do anything if you run it on a browser that does support object-fit? If so I don't mind running this a few extra times on ie11, in order to improve our non ie-11 cases and keep the cards a little cleaner. If not, we could even have separate versions of this method in HitchhikerJS, depending on whether you are on the regular of legacy bundle.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the polyfill function would check if the element.style contains object-fit. If the browser tag supports it, it wouldn't do anything
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I moved the implementations into the base card component, which check the list of cards that would require this polyfill. Let me know if that's fine or need tweaking!
cards/card_component.js
Outdated
@@ -16,6 +16,12 @@ BaseCard["{{componentName}}"] = class extends ANSWERS.Component { | |||
* only if such a toggle is present in the DOM. | |||
*/ | |||
onMount() { | |||
//polyfill for image styling (object-fit) in ie11 | |||
if (['product-prominentimage', 'product-prominentimage-clickable'].includes('{{componentName}}')) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is this going to be an issue if somebody forks the card with a custom name? could we just run the polyfill on the entire card all the time?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you are right. updated!
cards/card_component.js
Outdated
@@ -16,6 +16,10 @@ BaseCard["{{componentName}}"] = class extends ANSWERS.Component { | |||
* only if such a toggle is present in the DOM. | |||
*/ | |||
onMount() { | |||
//polyfill for image styling (object-fit) in ie11 | |||
var images = document.querySelectorAll('.HitchhikerProductProminentImage-img'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I hate to be that guy but can we use const
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ah nah my bad, missed this one
@@ -16,6 +16,10 @@ BaseCard["{{componentName}}"] = class extends ANSWERS.Component { | |||
* only if such a toggle is present in the DOM. | |||
*/ | |||
onMount() { | |||
//polyfill for image styling (object-fit) in ie11 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was thinking it might be worth it to run it on the entire card instead of just this css class, on the off chance somebody renames their card css classes, but this is probably fine for now!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm after changing to const!
## Version 1.24.0 ### Features - A new formatter was added that prints the list of categories applied to an entity. (#946) - Added a new localized price range formatter. (#943) ### Enhancements - Google's text highlighting was added to the "View Details" link on the `document-search` Direct Answer card. Note that the highlighting is only applied when the user's browser is Chrome. (#945) - The Open Status translations are no longer hard-coded in `static` JS files. Instead, they are sourced from the Theme's .PO files. This means they can be overridden in custom .PO files. ### Bugfixes - Styling was added to the `prominent-image` and `prominent-video` cards to ensure that images and videos, respectively, are the same size. (#941, #950)
J=SLAP-1553
TEST=manual