Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
85 changes: 85 additions & 0 deletions src/resources/views/crud/chips/general.blade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
@php
$defaultHeading = [
'content' => null, // text to show in the heading
'element' => 'a',
'class' => 'mb-1 d-inline-block',
];

$defaultImage = [
'content' => null, // image url
'element' => 'a',
'class' => 'avatar avatar-2 rounded',
];

// merge any passed parameters with the defaults
$heading = array_merge($defaultHeading, $heading ?? []); // the main heading showing in the chip
$image = array_merge($defaultImage, $image ?? []); // the image that shows up in the chip (if any)
$details = $details ?? []; // the details that show up on the second row (if any)

// ensure the details have the minimum info
foreach ($details as $key => $detail) {
$details[$key]['element'] = $detail['element'] ?? 'span';
$details[$key]['class'] = $detail['class'] ?? 'text-reset';
}

// if the heading has a href, target and tile, and the image does not
// then use those for the image as well
if ($image['content'] !== null && $heading['content'] !== null) {
$image['href'] = $image['href'] ?? $heading['href'] ?? null;
$image['title'] = $image['title'] ?? $heading['title'] ?? null;
$image['target'] = $image['target'] ?? $heading['target'] ?? null;
}
@endphp

<div class="row align-items-center bp-chip">
@if ($image['content'])
<div class="col-auto">
<div class="d-block">
@if ($image['content'])
<{{ $image['element'] }}
@foreach ($image as $attribute => $value)
@if ($attribute !== 'element' && $attribute !== 'content')
{{ $attribute }}="{{ $value }}"
@endif
@endforeach
>
<span class="avatar avatar-2 rounded" style="background-image: url({{ $image['content'] }})"> </span>
</{{ $image['element'] }}>
@endif
</div>
</div>
@endif
<div class="col text-truncate">
<div class="d-block">
@if ($heading['content'])
<{{ $heading['element'] }}
@foreach ($heading as $attribute => $value)
@if ($attribute !== 'element' && $attribute !== 'content')
{{ $attribute }}="{{ $value }}"
@endif
@endforeach
>
{{ $heading['content'] }}
</{{ $heading['element'] }}>
@endif
</div>
<div class="d-block text-secondary text-truncate mt-n1">
@foreach ($details as $key => $detail)
<small class="d-inline-block me-1">
@if (isset($detail['icon']))
<i class="{{ $detail['icon'] }}" title="{{ $detail['title'] ?? '' }}"></i>
@endif
<{{ $detail['element'] }}
@foreach ($detail as $attribute => $value)
@if ($attribute !== 'element' && $attribute !== 'icon' && $attribute !== 'content')
{{ $attribute }}="{{ $value }}"
@endif
@endforeach
>
{{ $detail['content'] }}
</{{ $detail['element'] }}>
</small>
@endforeach
</div>
</div>
</div>
17 changes: 17 additions & 0 deletions src/resources/views/crud/widgets/chip.blade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
@php
// preserve backwards compatibility with Widgets in Backpack 4.0
$widget['wrapper']['class'] = $widget['wrapper']['class'] ?? $widget['wrapperClass'] ?? 'col';
@endphp

@includeWhen(!empty($widget['wrapper']), backpack_view('widgets.inc.wrapper_start'))

@if(!empty($widget['title']))
<h4 class="mt-4 mb-2">{{ $widget['title'] }}</h4>
@endif

<div class="{{ $widget['class'] ?? 'card' }}">
<div class="card-body">
@include($widget['view'], ['entry' => $widget['entry']])
</div>
</div>
@includeWhen(!empty($widget['wrapper']), backpack_view('widgets.inc.wrapper_end'))