File tree Expand file tree Collapse file tree 1 file changed +10
-7
lines changed Expand file tree Collapse file tree 1 file changed +10
-7
lines changed Original file line number Diff line number Diff line change 4
4
5
5
use Closure ;
6
6
use Illuminate \Contracts \View \View ;
7
+ use Illuminate \Support \Str ;
7
8
use Illuminate \View \Component ;
8
9
9
10
class Icon extends Component
10
11
{
11
12
public string $ uuid ;
12
13
13
14
public function __construct (
14
- public string $ name,
15
+ public string $ name
15
16
) {
16
17
$ this ->uuid = md5 (serialize ($ this ));
17
18
}
18
19
19
20
public function icon (): string
20
21
{
21
- return "heroicon- {$ this ->name }" ;
22
+ $ name = Str::of ($ this ->name );
23
+
24
+ return $ name ->contains ('. ' ) ? $ name ->replace ('. ' , '- ' ) : "heroicon- {$ this ->name }" ;
22
25
}
23
26
24
27
public function render (): View |Closure |string
25
28
{
26
29
return <<<'HTML'
27
- <x-svg
28
- :name="$icon()"
29
- {{
30
+ <x-svg
31
+ :name="$icon()"
32
+ {{
30
33
$attributes->class([
31
34
'inline',
32
35
'w-5 h-5' => !Str::contains($attributes->get('class'), ['w-', 'h-'])
33
- ])
34
- }}
36
+ ])
37
+ }}
35
38
/>
36
39
HTML;
37
40
}
You can’t perform that action at this time.
0 commit comments