-
Notifications
You must be signed in to change notification settings - Fork 444
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
Default type for polymorphic slots #2174
Comments
I like the idea of a default polymorphic slot, since we do now have default slots aswell, I don't like the idea of using All that said, if anyone wants to pick this up it would be great, unless, @joelhawksley, @camertron, @BlakeWilliams, @boardfish have any other ideas or reservations about this |
I would avoid |
Yeah, I suppose I would also consider how this overlaps with We could probably avoid having to think about that by changing the interface to slots, but that's a lot of potential upheaval and I'm not sure how many problems it'd solve relative to those it'd create. It occurred to me just now we could do something like: renders_one :visual, IconComponent,
with_variants: ->(component) do
component.or_variant(:avatar, AvatarComponent)
# you could call or_variant with all the same arguments as renders_one
end To have variants as they exist now (ie no "default" variant), you'd just drop the second argument ( |
Feature request
I would like to use polymorphic slots in the following way:
Motivation
Currently, We have to call it in the following way:
I would prefer being able to call the default slot type simply as
component.with_visual
Additionally, it might depend on how components are structured, but I often use inheritance in my components.
In this case, having a default slot would make it simpler to write:
The text was updated successfully, but these errors were encountered: