From 6386ffa015a5dfd87114537ddd970bb4b3cbf29f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tu=C4=9F=C3=A7e=20K=C3=BC=C3=A7=C3=BCko=C4=9Flu?= Date: Tue, 14 Jun 2022 17:13:53 +0300 Subject: [PATCH] Fixed #2670 - Avatar | New error event --- api-generator/components/avatar.js | 10 ++++++- src/components/avatar/Avatar.d.ts | 4 +++ src/components/avatar/Avatar.vue | 7 ++++- src/views/avatar/AvatarDoc.vue | 45 ++++++++++++++++++++++-------- 4 files changed, 52 insertions(+), 14 deletions(-) diff --git a/api-generator/components/avatar.js b/api-generator/components/avatar.js index 8181f37d1..d067789c9 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 812fbbc67..f900efec4 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 db55d2fd3..6e9b0d2a6 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 0c2127be2..160cc05d9 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 {
- +