Skip to content

Commit d1e2197

Browse files
committed
Fix Icons
- Use internavel `x-svg` - Move icon component after `input`/`select` elements
1 parent 7574600 commit d1e2197

File tree

4 files changed

+31
-23
lines changed

4 files changed

+31
-23
lines changed

src/MaryServiceProvider.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,9 @@ public function boot(): void
4848

4949
public function registerComponents()
5050
{
51+
// Just rename <x-icon> provided from BladeUI to <x-svg> to not collide with ours
52+
Blade::component('BladeUI\Icons\Components\Icon', 'svg');
53+
5154
Blade::component('alert', Alert::class);
5255
Blade::component('badge', Badge::class);
5356
Blade::component('button', Button::class);

src/View/Components/Icon.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,11 @@ public function __construct(
1919
$this->uuid = md5(serialize($this));
2020
}
2121

22+
public function icon(): string
23+
{
24+
return "heroicon-{$this->name}";
25+
}
26+
2227
public function classes(): string
2328
{
2429
if (Str::contains($this->class, ['w-', 'h-'])) {
@@ -31,7 +36,7 @@ public function classes(): string
3136
public function render(): View|Closure|string
3237
{
3338
return <<<'HTML'
34-
@svg("heroicon-{$name}", "$classes()")
39+
<x-svg :name="$icon()" :class="$classes()" />
3540
HTML;
3641
}
3742
}

src/View/Components/Input.php

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -55,17 +55,7 @@ public function render(): View|Closure|string
5555
</div>
5656
@endif
5757
58-
<div class="flex-1 relative">
59-
<!-- ICON -->
60-
@if($icon)
61-
<x-icon :name="$icon" class="absolute top-1/2 -translate-y-1/2 ml-3 text-gray-400 " />
62-
@endif
63-
64-
<!-- RIGHT ICON -->
65-
@if($iconRight)
66-
<x-icon :name="$iconRight" class="absolute top-1/2 right-3 -translate-y-1/2 text-gray-400 " />
67-
@endif
68-
58+
<div class="flex-1 relative">
6959
<!-- MONEY SETUP -->
7060
@if($money)
7161
<div x-data="{display: ''}" x-init="display = $wire.{{ $modelName() }}?.replace('.', '{{ $fractionSeparator }}')">
@@ -99,6 +89,16 @@ public function render(): View|Closure|string
9989
}}
10090
/>
10191
92+
<!-- ICON -->
93+
@if($icon)
94+
<x-icon :name="$icon" class="absolute top-1/2 -translate-y-1/2 left-3 text-gray-400 " />
95+
@endif
96+
97+
<!-- RIGHT ICON -->
98+
@if($iconRight)
99+
<x-icon :name="$iconRight" class="absolute top-1/2 right-3 -translate-y-1/2 text-gray-400 " />
100+
@endif
101+
102102
<!-- INLINE LABEL -->
103103
@if($label && $inline)
104104
<label for="{{ $uuid }}" class="absolute text-gray-400 duration-300 transform -translate-y-1 scale-75 top-2 z-10 origin-[0] bg-white rounded dark:bg-gray-900 px-2 peer-focus:px-2 peer-focus:text-blue-600 peer-focus:dark:text-blue-500 peer-placeholder-shown:scale-100 peer-placeholder-shown:-translate-y-1/2 peer-placeholder-shown:top-1/2 peer-focus:top-2 peer-focus:scale-75 peer-focus:-translate-y-1 @if($inline && $icon) left-9 @else left-3 @endif">

src/View/Components/Select.php

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -39,17 +39,7 @@ public function render(): View|Closure|string
3939
<label class="label label-text font-semibold">{{ $label }}</label>
4040
@endif
4141
42-
<div class="relative">
43-
<!-- ICON -->
44-
@if($icon)
45-
<x-icon :name="$icon" class="absolute top-1/2 -translate-y-1/2 ml-3 text-gray-400" />
46-
@endif
47-
48-
<!-- RIGHT ICON -->
49-
@if($iconRight)
50-
<x-icon :name="$iconRight" class="absolute top-1/2 right-8 -translate-y-1/2 text-gray-400 " />
51-
@endif
52-
42+
<div class="relative">
5343
<select
5444
{{ $attributes->whereDoesntStartWith('class') }}
5545
{{ $attributes->class([
@@ -71,6 +61,16 @@ public function render(): View|Closure|string
7161
@endforeach
7262
</select>
7363
64+
<!-- ICON -->
65+
@if($icon)
66+
<x-icon :name="$icon" class="absolute top-1/2 -translate-y-1/2 left-3 text-gray-400" />
67+
@endif
68+
69+
<!-- RIGHT ICON -->
70+
@if($iconRight)
71+
<x-icon :name="$iconRight" class="absolute top-1/2 right-8 -translate-y-1/2 text-gray-400 " />
72+
@endif
73+
7474
<!-- INLINE LABEL -->
7575
@if($label && $inline)
7676
<label class="absolute text-gray-500 duration-300 transform -translate-y-1 scale-75 top-2 z-10 origin-[0] bg-white rounded dark:bg-gray-900 px-2 peer-focus:px-2 peer-focus:text-blue-600 peer-focus:dark:text-blue-500 peer-placeholder-shown:scale-100 peer-placeholder-shown:-translate-y-1/2 peer-placeholder-shown:top-1/2 peer-focus:top-2 peer-focus:scale-75 peer-focus:-translate-y-1 @if($inline && $icon) left-9 @else left-3 @endif">

0 commit comments

Comments
 (0)