-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Image srcset documentation (#1066)
Co-authored-by: Vincent Smedinga <[email protected]>
- Loading branch information
1 parent
9e454af
commit 9db4a81
Showing
3 changed files
with
33 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,27 @@ | ||
import { Controls, Markdown, Meta, Primary } from "@storybook/blocks"; | ||
import { Canvas, Controls, Markdown, Meta, Primary } from "@storybook/blocks"; | ||
import * as ImageStories from "./Image.stories.tsx"; | ||
import README from "../../../../packages/css/src/components/image/README.md?raw"; | ||
|
||
<Meta of={ImageStories} /> | ||
|
||
<Markdown>{README}</Markdown> | ||
|
||
## Examples | ||
|
||
<Primary /> | ||
|
||
<Controls /> | ||
|
||
## Provide multiple sources | ||
|
||
Use the srcSet prop, which controls the corresponding HTML attribute (see [MDN](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/img#srcset)), to let the browser select the optimal source file for the image. | ||
A mobile device can often download a smaller file, saving the user’s bandwidth and time. | ||
|
||
<Canvas of={ImageStories.MultipleSources} /> | ||
|
||
## Prevent unnecessary loading | ||
|
||
Set the `loading` attribute (see [MDN](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/img#loading)) to `lazy` and the browser will wait to load the image until it is close to the viewport. | ||
Consider setting this for images below the top area of the page. | ||
|
||
<Canvas of={ImageStories.LazyLoading} /> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters