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

DS-767 Remove usage of image component from card #2520

Merged
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
image: {
src: '/images/placeholders/landscape-16x9-mountains.jpg',
alt: 'Image description',
lazyload: false,
loading: 'lazy',
Copy link
Collaborator

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,
}

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

updated

},
},
body: {
Expand All @@ -25,7 +25,7 @@
image: {
src: '/images/placeholders/landscape-16x9-mountains.jpg',
alt: 'Image description',
lazyload: false,
loading: 'lazy',
},
},
body: {
Expand All @@ -45,7 +45,7 @@
image: {
src: '/images/placeholders/landscape-16x9-mountains.jpg',
alt: 'Image description',
lazyload: false,
loading: 'lazy',
},
},
body: {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,19 @@
{% set usage %}
{% verbatim %}
// Standard card-replacement
{% include '@bolt-components-card-replacement/card-replacement.twig' with {
media: {
image: {
{% set image %}
{% include '@bolt-elements-image/image.twig' with {
attributes: {
alt: 'alt text',
src: '/images/placeholders/landscape-16x9-mountains.jpg',
alt: 'Image alt.',
loading: 'lazy',

},
} only %}
{% endset %}
{% include '@bolt-components-card-replacement/card-replacement.twig' with {
media: {
image: image,
},
body: {
eyebrow: 'This is an eyebrow',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
{% include '@bolt-components-card-replacement/card-replacement.twig' with {
media: {
image: {
{% set image %}
{% include '@bolt-elements-image/image.twig' with {
attributes: {
alt: 'Image alt text',
src: '/images/placeholders/landscape-16x9-mountains.jpg',
alt: 'Image alt.',
},
} only %}
{% endset %}
{% include '@bolt-components-card-replacement/card-replacement.twig' with {
media: {
image: image,
},
body: {
eyebrow: 'This is an eyebrow',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,24 +13,59 @@
}{% endverbatim %}
{% endset %}

{% set image_element_usage %}{% verbatim %}
{% set image %}
{% include '@bolt-elements-image/image.twig' with {
background: true,
attributes: {
alt: 'Image alt text',
src: 'path/image.jpg',
},
} only %}
{% endset %}
{% include '@bolt-components-card-replacement/card-replacement.twig' with {
horizontal: true,
height: 'auto',
media: {
image: image,
},
...
} only %}
{% endverbatim %}
{% endset %}

{% set customBodyDemo %}{% verbatim %}body: {
content: customContentWithGrid,
}{% endverbatim %}
{% endset %}

{% set image %}
{% include '@bolt-elements-image/image.twig' with {
background: true,
attributes: {
alt: 'Image alt text',
src: '/images/placeholders/landscape-16x9-mountains.jpg',
},
} only %}
{% endset %}

{% set card %}
<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.
Copy link
Collaborator

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 to true, the image you pass for card media should also have its background prop set to true 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.

Copy link
Collaborator Author

@MarcinMr MarcinMr Aug 23, 2022

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.

</bolt-text>
{% include '@bolt-components-code-snippet/code-snippet.twig' with {
content: image_element_usage,
lang: 'twig',
mode: 'dark',
} only %}
{% include '@bolt-components-card-replacement/card-replacement.twig' with {
horizontal: true,
height: 'auto',
media: {
image: {
src: '/images/placeholders/landscape-16x9-mountains.jpg',
alt: 'Image alt.',
placeholder_color: '#afcde6',
},
image: image
},
body: {
eyebrow: 'This is an eyebrow',
Expand Down Expand Up @@ -78,11 +113,7 @@
horizontal: true,
height: 'auto',
media: {
image: {
src: '/images/placeholders/landscape-16x9-mountains.jpg',
alt: 'Image alt.',
placeholder_color: '#afcde6',
},
image: image,
attributes: {
style: 'min-width:' ~ width,
}
Expand Down Expand Up @@ -196,4 +227,4 @@
} only %}
</bolt-grid-item>
{% endfor %}
</bolt-grid>>
</bolt-grid>
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
{% set image %}
{% include '@bolt-elements-image/image.twig' with {
attributes: {
alt: 'Image alt text',
src: '/images/placeholders/landscape-16x9-mountains.jpg',
},
} only %}
{% endset %}

{% set card_1 %}
{% include '@bolt-components-card-replacement/card-replacement.twig' with {
media: {
image: {
src: '/images/placeholders/landscape-16x9-mountains.jpg',
alt: 'Image alt.',
},
image: image,
},
body: {
eyebrow: 'This is an eyebrow',
Expand All @@ -23,10 +29,7 @@
{% set card_2 %}
{% include '@bolt-components-card-replacement/card-replacement.twig' with {
media: {
image: {
src: '/images/placeholders/landscape-16x9-mountains.jpg',
alt: 'Image alt.',
},
image: image,
},
body: {
eyebrow: 'This is an eyebrow',
Expand All @@ -46,10 +49,7 @@
{% set card_3 %}
{% include '@bolt-components-card-replacement/card-replacement.twig' with {
media: {
image: {
src: '/images/placeholders/landscape-16x9-mountains.jpg',
alt: 'Image alt.',
},
image: image,
},
body: {
eyebrow: 'This is an eyebrow',
Expand All @@ -69,10 +69,7 @@
{% set card_4 %}
{% include '@bolt-components-card-replacement/card-replacement.twig' with {
media: {
image: {
src: '/images/placeholders/landscape-16x9-mountains.jpg',
alt: 'Image alt.',
},
image: image,
},
body: {
eyebrow: 'This is an eyebrow',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
{% set image %}
{% include '@bolt-elements-image/image.twig' with {
attributes: {
alt: 'Image alt text',
src: '/images/placeholders/landscape-16x9-mountains.jpg',
},
} only %}
{% endset %}

{% set card %}
{% include '@bolt-components-card-replacement/card-replacement.twig' with {
media: {
image: {
src: '/images/placeholders/landscape-16x9-mountains.jpg',
alt: 'Image alt.',
},
image: image,
},
body: {
eyebrow: 'This is an eyebrow',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
{% set schema = bolt.data.components['@bolt-components-card-replacement'].schema %}

{% set image %}
{% include '@bolt-elements-image/image.twig' with {
attributes: {
alt: 'Image alt text',
src: '/images/placeholders/landscape-16x9-mountains.jpg',
},
} only %}
{% endset %}
<bolt-grid gutter="medium" row-gutter="medium">
{% for height in schema.properties.height.enum %}
{% if height == 'full' %}
Expand All @@ -11,10 +18,7 @@
{% include '@bolt-components-card-replacement/card-replacement.twig' with {
height: height,
media: {
image: {
src: '/images/placeholders/landscape-16x9-mountains.jpg',
alt: 'Image alt.',
},
image: image,
},
body: {
headline: 'This card has ' ~ height ~ ' height. ' ~ more_text,
Expand All @@ -41,10 +45,7 @@
{% include '@bolt-components-card-replacement/card-replacement.twig' with {
height: 'full',
media: {
image: {
src: '/images/placeholders/landscape-16x9-mountains.jpg',
alt: 'Image alt.',
},
image: image,
},
body: {
headline: 'This card also has full height.',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,18 @@
href: 'https://yahoo.com'
}
} only %}{% endspaceless %}{% endset %}

{% set image %}
{% include '@bolt-elements-image/image.twig' with {
attributes: {
alt: 'Image alt text',
src: '/images/placeholders/landscape-16x9-mountains.jpg',
},
} only %}
{% endset %}
{% set card_1 %}
{% include '@bolt-components-card-replacement/card-replacement.twig' with {
media: {
image: {
src: '/images/placeholders/landscape-16x9-mountains.jpg',
alt: 'Image alt.',
},
image: image,
},
body: {
headline: 'No link',
Expand All @@ -33,10 +37,7 @@
text: 'Go to google.com'
},
media: {
image: {
src: '/images/placeholders/landscape-16x9-mountains.jpg',
alt: 'Image alt.',
},
image: image,
},
body: {
headline: 'With link',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,12 +126,17 @@
]
}
} only %}
{% include '@bolt-components-card-replacement/_card-replacement-media.twig' with {
media: {
image: {
{% set image %}
{% include '@bolt-elements-image/image.twig' with {
attributes: {
alt: 'Image alt text',
src: '/images/placeholders/landscape-16x9-mountains.jpg',
alt: 'Image alt.',
},
} only %}
{% endset %}
{% include '@bolt-components-card-replacement/_card-replacement-media.twig' with {
media: {
image: image,
}
} %}
{% endset %}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,14 +71,18 @@
content: block_list,
} only %}
{% endset %}

{% set image %}
{% include '@bolt-elements-image/image.twig' with {
attributes: {
alt: 'Image alt text',
src: '/images/placeholders/landscape-16x9-mountains.jpg',
},
} only %}
{% endset %}
{% set card_2 %}
{% include '@bolt-components-card-replacement/card-replacement.twig' with {
media: {
image: {
src: '/images/placeholders/landscape-16x9-mountains.jpg',
alt: 'Image alt.',
},
image: image,
},
height: 'auto',
body: {
Expand Down