Skip to content

Commit 0a9c459

Browse files
committed
Fix Icon
1 parent d1e2197 commit 0a9c459

File tree

1 file changed

+9
-13
lines changed

1 file changed

+9
-13
lines changed

src/View/Components/Icon.php

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
use Closure;
66
use Illuminate\Contracts\View\View;
7-
use Illuminate\Support\Str;
87
use Illuminate\View\Component;
98

109
class Icon extends Component
@@ -13,8 +12,6 @@ class Icon extends Component
1312

1413
public function __construct(
1514
public string $name,
16-
public ?string $class = null,
17-
private string $defaultClasses = 'w-5 h-5 inline'
1815
) {
1916
$this->uuid = md5(serialize($this));
2017
}
@@ -24,19 +21,18 @@ public function icon(): string
2421
return "heroicon-{$this->name}";
2522
}
2623

27-
public function classes(): string
28-
{
29-
if (Str::contains($this->class, ['w-', 'h-'])) {
30-
return "inline {$this->class}";
31-
}
32-
33-
return "{$this->defaultClasses} {$this->class}";
34-
}
35-
3624
public function render(): View|Closure|string
3725
{
3826
return <<<'HTML'
39-
<x-svg :name="$icon()" :class="$classes()" />
27+
<x-svg
28+
:name="$icon()"
29+
{{
30+
$attributes->class([
31+
'inline',
32+
'w-5 h-5' => !Str::contains($attributes->get('class'), ['w-', 'h-'])
33+
])
34+
}}
35+
/>
4036
HTML;
4137
}
4238
}

0 commit comments

Comments
 (0)