Yassine Doghri a95de8bab0 feat(components): add custom view renderer with ComponentRenderer adapted from bonfire2
- update Component class structure and remove component helper function and ComponentLoader
- update residual activitypub naming to fediverse
2021-12-29 11:54:50 +00:00

29 lines
595 B
PHP

<?php
declare(strict_types=1);
namespace App\View\Components;
use Exception;
use ViewComponents\Component;
class Icon extends Component
{
public string $glyph = '';
public function render(): string
{
try {
$svgContents = file_get_contents('assets/icons/' . $this->glyph . '.svg');
} catch (Exception) {
return '□';
}
if ($this->attributes['class'] !== '') {
$svgContents = str_replace('<svg', '<svg class="' . $this->attributes['class'] . '"', $svgContents);
}
return $svgContents;
}
}