@php /* |---------------------------------------------------------------------------- | AVATAR COMPONENT (https://bladewindui.com/component/avatar |---------------------------------------------------------------------------- | | Display either a single avatar or a group of stacked avatars with the | option to display +xxx. Avatars can be displayed in different sizes and | have dot indicators that can be placed in two positions. | * */ @endphp @props([ 'image' => null, 'alt' => 'image', 'class' => 'ltr:mr-2 rtl:ml-2 mt-2', 'dot_position' => config('bladewind.avatar.dot_position', 'bottom'), 'dot_color' => config('bladewind.avatar.dot_color', 'primary'), 'dotted' => config('bladewind.avatar.dotted', false), 'label' => null, 'plus_action' => null, ]) @aware([ // these attributes could be passed from the x-bladewind::avatars component also 'dotted' => $dotted ?? false, 'size' => config('bladewind.avatar.size', 'regular'), 'stacked' => false, 'show_ring' => true, 'dot_position' => $dot_position ?? 'bottom', 'dot_color' => $dot_color ?? 'green', 'plus' => '', ]) @php $sizes = [ 'tiny' => [ 'size_css' => 'size-6', 'dot_css' => 'left-5', 'plus_text_size' => 'text-xs' ], 'small' => [ 'size_css' => 'size-8', 'dot_css' => 'left-6', 'plus_text_size' => 'text-sm' ], 'medium' => [ 'size_css' => 'size-10', 'dot_css' => 'left-8', 'plus_text_size' => 'text-base' ], 'regular' => [ 'size_css' => 'size-12', 'dot_css' => 'left-[31px] rtl:right-[31px]', 'plus_text_size' => 'text-lg' ], 'big' => [ 'size_css' => 'size-16', 'dot_css' => 'left-[46px] rtl:right-[46px]', 'plus_text_size' => 'text-xl tracking-tighter' ], 'huge' => [ 'size_css' => 'size-20', 'dot_css' => 'left-[58px] rtl:right-[58px]', 'plus_text_size' => 'text-2xl' ], 'omg' => [ 'size_css' => 'size-28', 'dot_css' => 'left-[79px] rtl:right-[79px]', 'plus_text_size' => 'text-3xl' ] ]; $dotted = filter_var($dotted, FILTER_VALIDATE_BOOLEAN); $stacked = filter_var($stacked, FILTER_VALIDATE_BOOLEAN); $show_ring = filter_var($show_ring, FILTER_VALIDATE_BOOLEAN); $dot_position = (in_array($dot_position, ['top','bottom'])) ? $dot_position : 'bottom'; $avatar = $image ?: asset('vendor/bladewind/images/avatar.png'); $show_plus = (substr($avatar, 0, 1) == '+'); $image_size = $sizes[$size]['size_css']; $plus_text_size = $sizes[$size]['plus_text_size']; $dot_position_css = $sizes[$size]['dot_css']; $stacked = (is_numeric($plus) && $plus > 0) ? true : $stacked; $stacked_css = ($stacked) ? 'mb-3 !-mr-3' : ''; $label = (!empty($label)) ? substr($label, 0, 2) : $label; if(! in_array($dot_color, ['primary','blue','red','yellow','green','orange','purple','cyan','pink', 'black', 'violet', 'indigo', 'fuchsia'])) { $dot_color = 'primary'; } if(!function_exists("urlExists")){ function urlExists($url): bool { $headers = @get_headers($url); if(!$headers || $headers[0] == 'HTTP/1.1 404 Not Found') { return false; } return true; } } $use_label = (!urlExists($avatar) && $label); if($use_label) $avatar = $label; @endphp
@if($show_plus || $use_label)
{{$avatar}}
@else {{$avatar}} @endif @if($dotted && !$show_plus) @endif