Skip to content

Commit 85b614f

Browse files
Merge pull request #70 from robsontenorio/iconsets
Icon: allow another iconset
2 parents 45d4bc0 + f475135 commit 85b614f

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

src/View/Components/Icon.php

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,34 +4,37 @@
44

55
use Closure;
66
use Illuminate\Contracts\View\View;
7+
use Illuminate\Support\Str;
78
use Illuminate\View\Component;
89

910
class Icon extends Component
1011
{
1112
public string $uuid;
1213

1314
public function __construct(
14-
public string $name,
15+
public string $name
1516
) {
1617
$this->uuid = md5(serialize($this));
1718
}
1819

1920
public function icon(): string
2021
{
21-
return "heroicon-{$this->name}";
22+
$name = Str::of($this->name);
23+
24+
return $name->contains('.') ? $name->replace('.', '-') : "heroicon-{$this->name}";
2225
}
2326

2427
public function render(): View|Closure|string
2528
{
2629
return <<<'HTML'
27-
<x-svg
28-
:name="$icon()"
29-
{{
30+
<x-svg
31+
:name="$icon()"
32+
{{
3033
$attributes->class([
3134
'inline',
3235
'w-5 h-5' => !Str::contains($attributes->get('class'), ['w-', 'h-'])
33-
])
34-
}}
36+
])
37+
}}
3538
/>
3639
HTML;
3740
}

0 commit comments

Comments
 (0)