Skip to content

Commit

Permalink
✨ Add icons root and type
Browse files Browse the repository at this point in the history
  • Loading branch information
siguici committed Sep 8, 2023
1 parent 9c2c787 commit 114a830
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 2 additions & 0 deletions config/ui.php
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,9 @@
'icon' => [
'attributes' => [
'tag' => 'svg',
'root' => sikessem_ui_path('res/icons'),
'size' => 24,
'type' => 'solid',
'width' => 24,
'height' => 24,
'fill' => 'currentColor',
Expand Down
5 changes: 4 additions & 1 deletion src/Components/Icon.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ class Icon extends Component

public function __construct(
string $name,
string $root = null,
int $size = 24,
string $type = 'solid',
string $tag = 'svg',
Expand All @@ -33,7 +34,9 @@ public function __construct(
$name = Str::squish($name);
$name = Str::kebab($name);

if (! file_exists($icon = sikessem_ui_path("res/icons/$size/$type/$name.svg"))) {
$root ??= sikessem_ui_path('res/icons');

if (! \is_file($icon = "$root/$size/$type/$name.svg")) {
throw new RuntimeException("No icon named $name was found for type $type of size $size.");
}

Expand Down

0 comments on commit 114a830

Please sign in to comment.