29 lines
		
	
	
		
			735 B
		
	
	
	
		
			PHP
		
	
	
	
			
		
		
	
	
			29 lines
		
	
	
		
			735 B
		
	
	
	
		
			PHP
		
	
	
	
<?php
 | 
						|
 | 
						|
namespace App\View\Ui;
 | 
						|
 | 
						|
use Illuminate\Support\Facades\Cache;
 | 
						|
use Illuminate\View\Component;
 | 
						|
 | 
						|
class Sprite extends Component
 | 
						|
{
 | 
						|
 | 
						|
    public string $spritemapFile;
 | 
						|
 | 
						|
    public function __construct(
 | 
						|
        public string $src = '',
 | 
						|
    ) {
 | 
						|
        $this->spritemapFile = Cache::rememberForever('spritemap_file', function () {
 | 
						|
            $manifest = json_decode(file_get_contents(public_path('build/manifest.json')), true);
 | 
						|
            return asset('build/' . $manifest['spritemap.svg']['file']);
 | 
						|
        });
 | 
						|
    }
 | 
						|
 | 
						|
    public function render()
 | 
						|
    {
 | 
						|
        return <<<'HTML'
 | 
						|
            <svg {{ $attributes->merge(['class' => 'fill-current']) }}><use xlink:href="{{$spritemapFile}}#sprite-{{$src}}" /></svg>
 | 
						|
        HTML;
 | 
						|
    }
 | 
						|
}
 |