-
Notifications
You must be signed in to change notification settings - Fork 46
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
DS-767 Remove usage of image component from card #2520
DS-767 Remove usage of image component from card #2520
Conversation
…bolt-image component
…hema props instead of the deprecated image component
@MarcinMr disregard the previous comment, for some reason when i pulled the branch it was out of date. Everything is looking correct 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.
This isn't quite what I was thinking. Apologies for not giving clearer direction on this in the ticket!
In general, we want to avoid coupling components together. I've added some docs to the wiki on the how and why: https://github.com/boltdesignsystem/bolt/wiki/Decoupling-Bolt-components
What that means in practice is that instead of duplicating what's already there (a hard-coded include of another component), I was thinking we could update the media template to look like this:
<bolt-card-replacement-media {{ attributes }}>
<ssr-keep for="bolt-card-replacement-media" class="c-bolt-card_replacement__media">
{{ image }}
</ssr-keep>
</bolt-card-replacement-media>
What that actually would look like is something more like this, keeping support for all the deprecated/wrong ways of doing it.
<bolt-card-replacement-media {{ attributes }}>
<ssr-keep for="bolt-card-replacement-media" class="c-bolt-card_replacement__media">
{% if _card_replacement_image %}
{# DEPRECATED. Pass a renderable image for media.image instead of structured data. #}
{% if _card_replacement_image is iterable and _card_replacement_image.src %}
{% include '@bolt-components-image/image.twig' with _card_replacement_image only %}
{% else %}
{{ _card_replacement_image }}
{% endif %}
{% elseif block('media') is defined %}
{# DEPRECATED. Pass a renderable image for media.image instead of using a twig block. #}
{{ block('media') }}
{% endif %}
</ssr-keep>
</bolt-card-replacement-media>
…o feature/DS-767-Remove-usage-of-image-component-from-card
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.
Looking good @MarcinMr, I left a couple minor inline questions (though maybe you were still working on these).
Re: updating the ratio
and cover
props when horizontal
is true
, there is no way to do it automatically, and that's by design (or at least part of the decoupling principle). Instead, you just want to set those additional properties manually in the image that gets passed any time horizontal
is true
. We should also update the docs to tell users that those image props are necessary for horizontal cards.
@@ -5,7 +5,7 @@ | |||
image: { | |||
src: '/images/placeholders/landscape-16x9-mountains.jpg', | |||
alt: 'Image description', | |||
lazyload: false, | |||
loading: 'lazy', |
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.
Any reason you didn't replace the image structured data array here with a rendered image, such that this looks like the following?
media: {
image: image,
}
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.
updated
@@ -644,7 +644,6 @@ | |||
media: { | |||
image: { | |||
src: '/images/content/promos/promo-16x9-anthem.jpg', | |||
placeholder_color: '#8d9598' |
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.
These shouldn't be structured arrays either, right?
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.
updated
@remydenton thanks for explaining. I updated the docs and the pattern lab, so right now there shouldn't be more examples like this:
|
@@ -32,6 +53,14 @@ | |||
<bolt-text headline> | |||
Default horizontal card | |||
</bolt-text> | |||
<bolt-text> | |||
When using background element set <code>background: true</code>. This will crop the image in the horizontal card. |
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.
Helper text here is just what we need, but I'm not sure I understand from the sentence how it's supposed to work. There isn't a background element here 🤔 . Isn't it essentially just the following?
When creating a horizontal card by setting the
horizontal
prop totrue
, the image you pass for card media should also have itsbackground
prop set totrue
in order to allow the image to be cropped and display properly.
Feel free to tweak the wording, but I think the really important thing to get across is that users need to set background: true
on the image element whenever the card has horizontal: true
.
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.
Today when I read this sentence, I didn't understand it either 😁 I updated the docs with your more specific description, only added one more detail that the horizontal card also must have the prop height
set to auto
. Without this images are broken.
Looking really good, just one final comment/question on the wording in the docs. |
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.
Looks great, thanks for the work on this @MarcinMr .
Jira
https://pegadigitalit.atlassian.net/browse/DS-767
Summary
Support for image element was added.
Details
Image Element
is added,Image Component
Card
schema was updated to point to theImage Element
instead of theImage Component
,Image Component
props were replaced withImage Element
props in the pattern labHow to test
Pull the branch. Check if by passing
image element
in the Card component to the media: { image: imagerenders the image element instead of the
<bolt-image/>
componentRelease notes
When adding an image to the media inside Bolt Card component, please use a renderable image element for
media.image
instead of structured data.