diff --git a/api-generator/components/avatar.js b/api-generator/components/avatar.js index 8181f37d15..d067789c90 100644 --- a/api-generator/components/avatar.js +++ b/api-generator/components/avatar.js @@ -31,10 +31,18 @@ const AvatarProps = [ } ]; +const AvatarEvents = [ + { + name: "error", + description: "Triggered when an error occurs while loading an image file." + } +]; + module.exports = { avatar: { name: "Avatar", description: "Avatar represents people using icons, labels and images.", - props: AvatarProps + props: AvatarProps, + events: AvatarEvents } }; diff --git a/src/components/avatar/Avatar.d.ts b/src/components/avatar/Avatar.d.ts index 812fbbc678..f900efec4c 100644 --- a/src/components/avatar/Avatar.d.ts +++ b/src/components/avatar/Avatar.d.ts @@ -40,6 +40,10 @@ export interface AvatarSlots { } export declare type AvatarEmits = { + /** + * Triggered when an error occurs while loading an image file. + */ + error: () => void; } declare class Avatar extends ClassComponent { } diff --git a/src/components/avatar/Avatar.vue b/src/components/avatar/Avatar.vue index db55d2fd3b..6e9b0d2a6c 100644 --- a/src/components/avatar/Avatar.vue +++ b/src/components/avatar/Avatar.vue @@ -3,7 +3,7 @@ {{label}} - + @@ -33,6 +33,11 @@ export default { default: "square" } }, + methods: { + onError() { + this.$emit('error'); + } + }, computed: { containerClass() { return ['p-avatar p-component', { diff --git a/src/views/avatar/AvatarDoc.vue b/src/views/avatar/AvatarDoc.vue index 0c2127be22..160cc05d98 100644 --- a/src/views/avatar/AvatarDoc.vue +++ b/src/views/avatar/AvatarDoc.vue @@ -40,6 +40,7 @@ import AvatarGroup from 'primevue/avatargroup'; <Avatar image="user.png" /> <Avatar label="+2" /> </AvatarGroup> +
Shape
@@ -60,7 +61,7 @@ import AvatarGroup from 'primevue/avatargroup';

Content can easily be customized with the default slot instead of using the built-in modes.


 <Avatar>
-   Content
+    Content
 </Avatar>
 
 
@@ -114,6 +115,26 @@ import AvatarGroup from 'primevue/avatargroup';
Properties of AvatarGroup

Any property as style and class are passed to the main container element. There are no additional properties.

+ +
Events
+
+ + + + + + + + + + + + + + + +
NameParametersDescription
error-Triggered when an error occurs while loading an image file.
+
Styling of Avatar

Following is the list of structural style classes, for theming classes visit theming page.

@@ -216,7 +237,7 @@ export default { - +
@@ -236,7 +257,7 @@ export default {
-
+
Icon - Badge
@@ -268,12 +289,12 @@ export default {
-
-
-
Image - Badge
- -
-
+
+
+
Image - Badge
+ +
+
@@ -313,7 +334,7 @@ export default {
- +
@@ -333,7 +354,7 @@ export default {
-
+
Icon - Badge
@@ -411,7 +432,7 @@ export default {
- +