Skip to content

Commit cb4d471

Browse files
authored
Fixes to Media Link and Hype Group dimension issues (#2171)
* Fix Media Link width issue * Fix Hype Group image size issue
1 parent 06bf935 commit cb4d471

File tree

6 files changed

+39
-6
lines changed

6 files changed

+39
-6
lines changed

.changeset/cyan-terms-sip.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@cloudfour/patterns': patch
3+
---
4+
5+
Prevent Media Links from breaking out of Grid or Flex containers
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@cloudfour/patterns': patch
3+
---
4+
5+
Hype Group object images with smaller dimensions than their container will no longer appear awkwardly cropped

src/components/media-link/media-link.scss

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@
1111
/// 2. This allows the link to position a pseudo element relative to this
1212
/// container for the largest possible click area.
1313
.c-media-link {
14-
inline-size: max-content; // 1
15-
max-inline-size: 100%; // 1
14+
inline-size: 100%; // 1
15+
max-inline-size: max-content; // 1
1616
position: relative; // 2
1717
}
1818

src/objects/hype-group/demo/single.twig

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,26 @@
88
} only %}
99
{% endblock %}
1010
{% block object %}
11-
<img src="{{example_object_img_src}}" alt="Example object image" width="960" height="960">
11+
<img src="{{example_object_img_src}}"
12+
alt="Example object image"
13+
width="{{example_object_img_size}}"
14+
height="{{example_object_img_size}}">
1215
{% endblock %}
1316
{% block content %}
1417
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Fusce nulla nulla, vestibulum vel pharetra ut, suscipit sit amet orci. Aliquam interdum tristique tincidunt.</p>
15-
{% if example_paragraphs > 1 %}
18+
{% if example_paragraphs > 2 %}
1619
<p>Nunc pellentesque eu purus vel aliquet. Vestibulum sed nulla tellus. Sed sed ante varius, facilisis dui in, lacinia dui. Sed convallis aliquam dolor, sit amet pretium nibh dignissim quis.</p>
1720
{% endif %}
18-
{% if example_paragraphs > 2 %}
19-
<p>Donec sit amet odio eget eros cursus pellentesque et in justo. Aliquam vel tristique diam. Donec vehicula dolor vitae turpis condimentum fermentum sit amet et est.</p>
21+
{% if example_paragraphs > 1 %}
22+
{% include '@cloudfour/components/media-link/media-link.twig' with {
23+
"href": "https://cloudfour.com/thinks/performance-is-an-issue-of-equity/",
24+
"label": "Cloud Four partner Megan Notarte explains why performance is an issue of equity",
25+
"action_class": "u-text-small",
26+
"avatar": "/media/megan.png",
27+
"avatar_width": 88,
28+
"avatar_height": 88,
29+
"icon": "arrow-right"
30+
} only %}
2031
{% endif %}
2132
{% endblock %}
2233
{% endembed %}

src/objects/hype-group/hype-group.scss

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,17 @@
213213
position: absolute;
214214
}
215215

216+
/// Make sure child elements fill the container (even if they're smaller)
217+
218+
> *,
219+
> picture > img {
220+
block-size: 100%;
221+
inline-size: 100%;
222+
}
223+
216224
/// Prevents non-square images from stretching to fit the square container.
225+
/// This is limited to `img` because `object-fit` can have some weird effects
226+
/// on `video` or `iframe` elements.
217227

218228
> img,
219229
> picture > img {

src/objects/hype-group/hype-group.stories.mdx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ const defaultArgs = {
3838
object_shape: 'circle',
3939
example_paragraphs: 2,
4040
example_object_img_src: '/media/feature-ozzie-wide.jpg',
41+
example_object_img_size: 480,
4142
};
4243

4344
<Meta
@@ -54,6 +55,7 @@ const defaultArgs = {
5455
intro_class: { type: 'string' },
5556
content_class: { type: 'string' },
5657
example_object_img_src: { type: 'string' },
58+
example_object_img_size: { type: 'number' },
5759
example_paragraphs: {
5860
type: 'number',
5961
control: {

0 commit comments

Comments
 (0)