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

Add cover option to image container component #5199

Merged
merged 1 commit into from
Jun 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions releases.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@
url: /docs/patterns/links#anchor-link
status: New
notes: We've introduced a new class <code>.p-link--anchor-heading</code> to style anchor links in headings.
- component: Image container / Cover
url: /docs/patterns/images#cover-image
status: New
notes: We've added a new cover variant to the image container component via <code>is-cover</code> class to support having images cover the container with predefined aspect ratio.
- version: 4.13.0
features:
- component: Image container
Expand Down
8 changes: 8 additions & 0 deletions scss/_patterns_image.scss
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,14 @@
max-height: 100%;
object-fit: contain;
}

&.is-cover {
.p-image-container__image {
height: 100%;
object-fit: cover;
width: 100%;
}
}
}

.p-image-container--16-9 {
Expand Down
1 change: 1 addition & 0 deletions templates/docs/examples/patterns/image/combined.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
<section>{% include 'docs/examples/patterns/image/shadowed.html' %}</section>
<section>{% include 'docs/examples/patterns/image/spacing.html' %}</section>
<section>{% include 'docs/examples/patterns/image/container/highlighted.html' %}</section>
<section>{% include 'docs/examples/patterns/image/container/cover.html' %}</section>
<section>{% include 'docs/examples/patterns/image/container/aspect-ratio/all.html' %}</section>
{% endwith %}
{% endblock %}
10 changes: 10 additions & 0 deletions templates/docs/examples/patterns/image/container/cover.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{% extends "_layouts/examples.html" %}
{% block title %}Image Container / Cover{% endblock %}

{% block standalone_css %}patterns_image{% endblock %}

{% block content %}
<div class="p-image-container--16-9 is-cover">
<img class="p-image-container__image" src="https://assets.ubuntu.com/v1/44095efb-photo-1580536793208-117fdb20ffc1%20(1).jpeg" alt="" width="1000">
</div>
{% endblock %}
8 changes: 8 additions & 0 deletions templates/docs/patterns/images.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,14 @@ See the [class references section](#class-reference) for more information on the
View example of image container with 16/9 aspect ratio
</a></div>

## Cover image

Cover images are used to fill the entire container, cropping the image if necessary. This can be combined with the aspect ratio modifier to crop the image to a specific aspect ratio.

<div class="embedded-example"><a href="/docs/examples/patterns/image/container/cover" class="js-example">
View example of cover image
</a></div>

## Image with border

<div class="p-notification--caution">
Expand Down
Loading