-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
Support Closures in the registration of Filament Panel Colors #9556
Conversation
- Modified the FilamentColor::register() signature to accept an array of closures - Modified the HasColors::colors() signature to accept an array of closures - Modified ColorManager::processColor() to accept a closure and evaluate it to a color
- Added documentation under Filament Panels -> Themes - Added documentation under Core Concepts -> Colors
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's only accept a closure as the top-level argument, instead of per color. Offers the same flexibility and should be more performant.
That was my initial consideration.My only worry was: Will this still allow plugins to override only a single color without necessarily setting all the six colors at once especially via |
…at the top level. - Made changes to the panels -> themes documentation - Made changes to the support -> colors documentation
Please run Pint |
Done. |
This PR adds support for using closures in each of the colors passed as an array to the
FilamentColor::register()
method. This makes it possible to evaluate theme colors during the application's runtime, which is currently only possible using a custom Middleware. A good use case for this is in a multi-tenant app where tenants should be able to set their own theme colors as part of the tenant configuration.With this change, the following color registration will be possible from any service provider's boot method:
Additionally, it will also be possible to use closures in the
$panel->colors()
method as follows: