-
-
Notifications
You must be signed in to change notification settings - Fork 3.2k
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
add HeroIcon class feature #10984
add HeroIcon class feature #10984
Conversation
Changing the type of the navigation icon property is a breaking change. |
I've been thinking about #10281, and I think that we don't need an Icon class or Enum. I think just including a Heroicon class with a constant for each icon string is good enough, as it provides autocomplete while also not making any breaking type changes. @ArielMejiaDev please remove all type changes, and put all possible Heroicon combinations as constants in a Heroicon class. Then we can just get people to use those without any breaking changes:
|
Makes sense, @danharrin. |
Since these are class constants instead of enum cases, we should probably go with UPPER_SNAKE. Can't remember why colors are that way but I think they're ok. |
@danharrin thanks I am going to add the changes |
@danharrin The HeroIcon class now has all icon variants as constants, at this point, it should not break anything for V3, for V4 I would be glad to help if there are plans for an icon more complex implementation. In any way this constants are going to be pretty helpful |
Thanks! Do you think it would be confusing that the docs / stubs / Filament core code still use the old strings instead of the constants? Should they be updated? |
@danharrin I could make a PR to update the docs to use the class constants For stubs, you can choose between keep it or replace it, for navigation icons it would require to override a method instead of the property, but both works without any breaking change. I could imagine my workflow with the class constants and I think most of developers would prefer it, avoid typos, magic number issues, etc, let me know your thoughts, I would be glad to help in any case |
Can't the constants be used on icon property initialization, @ArielMejiaDev? Also, benefit of enums is that one can list all available icons easily using |
As far as I know, there is no issue using constants for property initialisation. |
For sure, so if you are fine with this I can add the change in the stubs and in the docs |
Yes please |
And anywhere we reference Heroicon names in Filament internal code |
Description
The Issue
Filament is a super productive tool, and reducing the necessity of checking in the Heroicons page for icon names would be a great addition to the workflow.
Goal
Increase developer experience by removing the necessity to set icons as strings.
Additions
It adds the ability to handle Heroicons with autocompletion using a new class with a static constructor, constants for every icon available.
Variants
By default the icon variants are outline, but it adds the ability to chain method
solid
to set an icon as solidThis new feature would be ready to use with:
Usage
Resource Stub
The resource stub file has been updated to replace the
$navigationIcon
property, which still works, with this new method to resolve the icon fluently.Testing
All resource tests in
tests/src/Panels/Resources
directory are updated to work with this featureDemo
https://www.loom.com/share/614ce4b4b5ae40dba8f5ac0b07f96472?sid=ad0e224e-4547-4839-b115-55f51adcd03b
Documentation
If this feature could be considered to be approved, I could gladly add a PR in docs too.