From 3c81e740bf1ed39ec8c708c964fc967129110fc9 Mon Sep 17 00:00:00 2001 From: Sebastian Thulin Date: Mon, 30 Sep 2024 14:12:02 +0200 Subject: [PATCH] feat: implement image in avatar --- source/php/Component/Avatar/avatar.blade.php | 20 +++++++++++++++++++- source/php/Component/Avatar/avatar.json | 6 +++--- 2 files changed, 22 insertions(+), 4 deletions(-) diff --git a/source/php/Component/Avatar/avatar.blade.php b/source/php/Component/Avatar/avatar.blade.php index 855762b7..c0f67b26 100644 --- a/source/php/Component/Avatar/avatar.blade.php +++ b/source/php/Component/Avatar/avatar.blade.php @@ -1,10 +1,25 @@ @if($displayAvatar) +
+ + {{-- If the avatar has an image --}} @if($image) - {{ $label }} + @image( + [ + 'src' => $image, + 'classList' => [$baseClass.'__image'], + 'alt' => $label, + 'attributeList' => [ + 'aria-label' => $label + ], + 'cover' => true + ] + ) + @endimage @endif + {{-- If the avatar has an icon --}} @if($icon) @icon( @@ -17,10 +32,13 @@ @endif + {{-- If the avatar has initials --}} @if($initials) {{$initials}} @endif +
+ @endif \ No newline at end of file diff --git a/source/php/Component/Avatar/avatar.json b/source/php/Component/Avatar/avatar.json index 33ad7515..239cc4fb 100644 --- a/source/php/Component/Avatar/avatar.json +++ b/source/php/Component/Avatar/avatar.json @@ -1,19 +1,19 @@ { "slug": "avatar", "default": { - "image": "", + "image": false, "icon": [], "name": "", "size": "md" }, "description": { - "image": "A url to a profile image.", + "image": "A url to a profile image or an ImageInterface.", "icon": "Attributes for @icon component (separate reference).", "name": "Persons full name", "size": "sm,md,lg,full" }, "types": { - "image": "string", + "image": "string|ImageInterface|boolean", "icon": "array", "name": "string", "size": "string"