Skip to content
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
5 changes: 5 additions & 0 deletions .changeset/stale-items-pull.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@cloudfour/patterns': minor
---

Add responsive fallback image
63 changes: 63 additions & 0 deletions src/assets/illustrations/responsive-fallback.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
12 changes: 12 additions & 0 deletions src/design/demo/responsive-image-deck.twig
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{% embed '@cloudfour/objects/deck/deck.twig' with {
class: 'o-deck--3-column@l'
} %}
{% block content %}
{% for ratio in ratios %}
<figure>
<img src="{{source}}" alt="" style="aspect-ratio: {{ratio}}; max-height: 15em;">
<figcaption>{{ratio}}</figcaption>
</figure>
{% endfor %}
{% endblock %}
{% endembed %}
17 changes: 17 additions & 0 deletions src/design/illustrations.stories.mdx
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { Story, Meta } from '@storybook/addon-docs/blocks';
import { extname, basename } from 'path';
import imageDeck from './demo/image-deck.twig';
import responsiveImageDeck from './demo/responsive-image-deck.twig';
import responsiveImage from '../assets/illustrations/responsive-fallback.svg';
import avatarDefaultSrc from '../assets/illustrations/avatar-default.svg';
const featureImageDir = require.context(
'../assets/illustrations/feature',
Expand Down Expand Up @@ -31,6 +33,21 @@ Images may represent more than one topic. For example, the `paintbrush` illustra
{() => imageDeck({ images: featureImageData })}
</Story>

## Responsive fallback image

An SVG that's used as a fallback image when an image request fails for whatever reason.

What's unique about this image is its responsiveness. Depending on the size of the broken image, portions of the image repeat or fix to the side to fit the aspect ratio of the image rather than squashing or stretching.

<Story name="Responsive fallback image" height="200px">
{() =>
responsiveImageDeck({
ratios: ['1 / 1', '16 / 9', '9 / 16'],
Copy link
Member

Choose a reason for hiding this comment

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

Quick question, @AriannaChau! 🙂

In Safari, the aspect ratios all look the same in the documentation page. Does that matter? Is this expected? 🤔

Screen Shot 2021-09-09 at 2 33 25 PM

Copy link
Contributor Author

Choose a reason for hiding this comment

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

AGH! No, thank you for bringing that to my attention!

Copy link
Member

Choose a reason for hiding this comment

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

Oh, is it because aspect-ratio isn't supported in Safari?

https://caniuse.com/mdn-css_properties_aspect-ratio

Copy link
Contributor

Choose a reason for hiding this comment

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

It looks like Safari doesn't support aspect-ratio (though it does in the Technology Preview so it should be rolling out soon)

I think that's fine for our pattern documentation site (though I'd be hesitant to use it on our actual site). I'm curious what others think though

Copy link
Member

Choose a reason for hiding this comment

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

Cool, I'm fine leaving it as-is for the documentation site. 😉

source: responsiveImage,
})
}
</Story>

## Default avatar

This asset may be used in place of a specific user avatar. To differentiate multiple fallback avatars, consider swapping its fill colors for [others in our palette](/docs/design-colors--page).
Expand Down