improve code
This commit is contained in:
16
resources/views/components/icon.blade.php
Normal file
16
resources/views/components/icon.blade.php
Normal file
@@ -0,0 +1,16 @@
|
||||
@props(['name', 'class' => ''])
|
||||
|
||||
@php
|
||||
$path = public_path("icons/{$name}.svg");
|
||||
|
||||
if (! is_file($path)) {
|
||||
throw new InvalidArgumentException("Icon [{$name}] not found.");
|
||||
}
|
||||
|
||||
$svg = file_get_contents($path);
|
||||
$svg = preg_replace('/<svg\b/', '<svg class="w-full h-full"', $svg, 1);
|
||||
@endphp
|
||||
|
||||
<span {{ $attributes->merge(['class' => 'inline-flex shrink-0 '.$class]) }} aria-hidden="true">
|
||||
{!! $svg !!}
|
||||
</span>
|
||||
Reference in New Issue
Block a user