Skip to content

Commit 2122344

Browse files
committed
✨ Show icon preview
1 parent 7a2e72d commit 2122344

3 files changed

Lines changed: 21 additions & 1 deletion

File tree

composer.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
"laravel/installer": "^5.17",
3030
"laravel/prompts": "^0.3",
3131
"nunomaduro/termwind": "^2.3",
32+
"sikessem/ui": "^0.9",
3233
"spatie/laravel-package-tools": "^1.92",
3334
"symfony/console": "^7.3"
3435
},

packages/core/composer.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
"filament/support": "^4.0",
2727
"illuminate/console": "^12.26",
2828
"illuminate/support": "^12.26",
29+
"sikessem/ui": "^0.9",
2930
"spatie/laravel-package-tools": "^1.92"
3031
},
3132
"autoload": {

packages/core/src/Components/Fields/IconField.php

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
use Filament\Forms\Components\Select;
88
use Filament\Support\Icons\Heroicon;
99
use Loom\Rules\IconRule;
10+
use Sikessem\UI\Facade as UI;
1011

1112
class IconField extends Field
1213
{
@@ -15,9 +16,26 @@ public static function make(?string $name = null): Select
1516
$name ??= loom()->config('components.icon.name', 'icon');
1617

1718
return Select::make($name)
18-
->options(array_column(Heroicon::cases(), 'value', 'value'))
19+
->options(function () {
20+
$icons = array_column(Heroicon::cases(), 'value', 'value');
21+
22+
foreach ($icons as $name => $icon) {
23+
$icon = str_starts_with($icon, 'o-')
24+
? "heroicon-{$icon}"
25+
: "heroicon-s-{$icon}";
26+
$icons[$name] = UI::render(<<<HTML
27+
<span class="inline-flex items-center justify-center gap-1">
28+
<x-filament::icon icon='{$icon}'/>
29+
{$name}
30+
</span>
31+
HTML);
32+
}
33+
34+
return $icons;
35+
})
1936
->rule(new IconRule)
2037
->searchable()
38+
->allowHtml()
2139
->label(loom()->trans('components.icon'));
2240
}
2341
}

0 commit comments

Comments
 (0)