Skip to content

Commit

Permalink
[5.x] Slight adjustments to the search index table (#11171)
Browse files Browse the repository at this point in the history
Co-authored-by: Jason Varga <jason@pixelfear.com>
  • Loading branch information
daun and jasonvarga authored Nov 26, 2024
1 parent a29ea36 commit 79f00e6
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 14 deletions.
1 change: 1 addition & 0 deletions resources/svg/search-drivers/loupe.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
24 changes: 14 additions & 10 deletions resources/views/utilities/search.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,31 +40,35 @@
</thead>
<tbody>
@foreach (\Statamic\Facades\Search::indexes() as $index)
<tr>
<td class="flex items-center">
@cp_svg('search-drivers/' . $index->config()['driver'], 'w-6 h-6 rtl:ml-2 ltr:mr-2')
<div class="text-gray-800 dark:text-dark-150 leading-none">{{ $index->title() }}</div>
<tr class="align-top">
<td>
<div class="flex items-start">
@cp_svg('search-drivers/' . $index->config()['driver'], 'flex w-6 h-6 rtl:ml-2 ltr:mr-2 -mt-0.5 shrink-0', 'search-drivers/local')
<span class="text-gray-800 dark:text-dark-150">{{ $index->title() }}</span>
</div>
</td>
<td>
{{ ucwords($index->config()['driver']) }}
</td>
<td>
@if (is_string($index->config()['searchables']))
<span class="badge-pill-sm">{{ $index->config()['searchables'] }}</span>
@else
<div class="text-sm text-gray flex flex-wrap">
<span class="badge-pill-sm">{{ $index->config()['searchables'] }}</span>
</div>
@else
<div class="text-sm text-gray flex flex-wrap gap-1">
@foreach($index->config()['searchables'] as $searchable)
<div class="rtl:ml-2 ltr:mr-2 badge-pill-sm">
<div class="badge-pill-sm">
{{ $searchable }}
</div>
@endforeach
</div>
@endif
</td>
<td>
<div class="text-sm text-gray flex flex-wrap">
<div class="text-sm text-gray flex flex-wrap gap-1">
@foreach($index->config()['fields'] as $field)
<div class="rtl:ml-2 ltr:mr-2 badge-pill-sm">
<div class="badge-pill-sm">
{{ $field }}
</div>
@endforeach
Expand All @@ -74,7 +78,7 @@
<form method="POST" action="{{ cp_route('utilities.search') }}">
@csrf
<input type="hidden" name="indexes[]" value="{{ $index->name() }}::{{ $index->locale() }}">
<button type="submit" class="btn btn-xs">{{ __('Update') }}</button>
<button type="submit" class="btn btn-xs -my-1">{{ __('Update') }}</button>
</form>
</td>
</tr>
Expand Down
11 changes: 7 additions & 4 deletions src/Statamic.php
Original file line number Diff line number Diff line change
Expand Up @@ -242,15 +242,18 @@ public static function provideToScript(array $variables)
return new static;
}

public static function svg($name, $attrs = null)
public static function svg($name, $attrs = null, $fallback = null)
{
if ($attrs) {
$attrs = " class=\"{$attrs}\"";
}

$svg = StaticStringy::collapseWhitespace(
File::get(statamic_path("resources/svg/{$name}.svg"))
);
$path = statamic_path("resources/svg/{$name}.svg");
if ($fallback && ! File::exists($path)) {
$path = statamic_path("resources/svg/{$fallback}.svg");
}

$svg = StaticStringy::collapseWhitespace(File::get($path));

return str_replace('<svg', sprintf('<svg%s', $attrs), $svg);
}
Expand Down

0 comments on commit 79f00e6

Please sign in to comment.