You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardexpand all lines: libs/design/image/README.md
+43-7
Original file line number
Diff line number
Diff line change
@@ -1,11 +1,54 @@
1
1
# Image
2
2
Image utilizes the native HTML `<img>` element to display responsive images on a page and prevent content jumping while images are loading. `<daff-image>` is an opinionated version that encourages friendly end-user usage.
The `src`, `width`, `height`, and `alt` attributes must be defined. An error will be thrown any of these attributes are missing.
6
8
7
9
`width` and `height` are required to calculate the aspect ratio of an image, used for the [aspect ratio padding trick](https://css-tricks.com/aspect-ratio-boxes/) that helps to prevent content jumping while images are loading. The `width` and `height` values are rendered as pixels.
8
10
11
+
## Usage
12
+
13
+
### Within a standalone component
14
+
To use image in a standalone component, import it directly into your custom component:
15
+
16
+
```ts
17
+
@Component({
18
+
selector: 'custom-component',
19
+
templateUrl: './custom-component.component.html',
20
+
standalone: true,
21
+
imports: [
22
+
DAFF_IMAGE_COMPONENTS,
23
+
],
24
+
})
25
+
exportclassCustomComponent {}
26
+
```
27
+
28
+
### Within a module (deprecated)
29
+
To use image in a module, import `DaffImageModule` into your custom module:
> This method is deprecated. It's recommended to update all custom components to standalone.
51
+
9
52
## Errors
10
53
11
54
**DaffImageComponent must have a defined src attribute.**
@@ -22,10 +65,3 @@ This error appears when `<daff-image>` is missing a `height` attribute. The heig
22
65
23
66
## Accessbility
24
67
Images should be given a meaningful description using the native `alt` attribute to ensure an accessible experience by default. An error will be thrown if the `alt` attribute is missing.
Copy file name to clipboardexpand all lines: libs/design/media-gallery/examples/src/mismatched-sizes-media-gallery/mismatched-sizes-media-gallery.component.ts
0 commit comments