for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace Xetaravel\View\Components;
use Closure;
use Illuminate\Contracts\View\View;
use Illuminate\Support\Str;
use Illuminate\Support\Stringable;
use Illuminate\View\Component;
class Icon extends Component
{
public string $uuid;
public function __construct(
public string $name,
public ?string $label = null
) {
$this->uuid = md5(serialize($this));
}
public function icon(): string|Stringable
$name = Str::of($this->name);
return $name->contains('.') ? $name->replace('.', '-') : "heroicon-{$this->name}";
public function labelClasses(): ?string
// Remove `w-*` and `h-*` classes, because it applies only for icon
return Str::replaceMatches('/(w-\w*)|(h-\w*)/', '', $this->attributes->get('class') ?? '');
/**
* Get the view / contents that represent the component.
*/
public function render(): View|Closure|string
return view('components.icon');