Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IconComponent issue with 14.22.0 #2830

Closed
c-gross opened this issue May 3, 2024 · 3 comments
Closed

IconComponent issue with 14.22.0 #2830

c-gross opened this issue May 3, 2024 · 3 comments
Assignees
Labels

Comments

@c-gross
Copy link

c-gross commented May 3, 2024

Describe the bug
I'm using the IconComponent() component to render icon in table headers. That was working fine in orchid 14.21.0.
Yesterday I tested orchid 14.22.0 and it's throwing an error now.
I'm not able to update Laravel to v11 because of some dependencies so I can't test orchid 14.23.0 yet. But I guess the issue will also apply in 14.23.0 when I check the files changes.

To Reproduce
TD::make('foo', (new IconComponent('bs.file-earmark-medical', '', null, '1.3em', '1.3em'))->render()())

Orchid\Icons\IconComponent::__construct(): Argument #1 ($finder) must be of type Orchid\Icons\IconFinder, string given, called in /Users/...../app/Orchid/Layouts/Order/OrderViewOrderItemLayout.php on line 144

Server (please complete the following information):

  • Platfrom Version: 14.22.0
  • Laravel Version: 10.43.0
  • PHP Version: 8.3
  • Database: MySQL
  • Database Version: 8.3.0
@c-gross
Copy link
Author

c-gross commented May 3, 2024

Just saw that a new param IconFinder is required to pass and reason for my error. How can I get the IconFinder within a layout table?

@tabuna
Copy link
Member

tabuna commented May 12, 2024

Hello! I'm sorry you've encountered this issue. It's because some components were reworked to avoid generating temporary compiled Blade files, which was impacting performance. Unfortunately, I didn't explicitly document this change and didn't anticipate its consequences.

Currently, icon rendering relies entirely on blade, so it's challenging to invoke it as you wish. Here are approximate steps:

app(IconComponent::class, [
     'path'   => 'bs.file-earmark-medical',
     'width'  => '1.3em', 
     'height' => '1.3em'
])->render()(['attributes' => []]); //  View object

Instead, it's recommended to use the rendering via Blade:

use Illuminate\Support\Facades\Blade;

Blade::render('<x-orchid-icon path="bs.file-earmark-medical"/>');

@c-gross
Copy link
Author

c-gross commented May 13, 2024

Thank you, that did help alot.
To use it for the table heading I only had to add ->__toString() at the end to avoid the "must be string" error and it's working.

Still hope for the icon feature for tables #2732 ;)

@c-gross c-gross closed this as completed May 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

No branches or pull requests

2 participants