Skip to content

Commit

Permalink
Merge pull request #70 from robsontenorio/iconsets
Browse files Browse the repository at this point in the history
Icon: allow another iconset
  • Loading branch information
robsontenorio authored Oct 12, 2023
2 parents 45d4bc0 + f475135 commit 85b614f
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions src/View/Components/Icon.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,34 +4,37 @@

use Closure;
use Illuminate\Contracts\View\View;
use Illuminate\Support\Str;
use Illuminate\View\Component;

class Icon extends Component
{
public string $uuid;

public function __construct(
public string $name,
public string $name
) {
$this->uuid = md5(serialize($this));
}

public function icon(): string
{
return "heroicon-{$this->name}";
$name = Str::of($this->name);

return $name->contains('.') ? $name->replace('.', '-') : "heroicon-{$this->name}";
}

public function render(): View|Closure|string
{
return <<<'HTML'
<x-svg
:name="$icon()"
{{
<x-svg
:name="$icon()"
{{
$attributes->class([
'inline',
'w-5 h-5' => !Str::contains($attributes->get('class'), ['w-', 'h-'])
])
}}
])
}}
/>
HTML;
}
Expand Down

0 comments on commit 85b614f

Please sign in to comment.