-
-
Notifications
You must be signed in to change notification settings - Fork 407
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
Pre-RFC: Splat Areas #517
Comments
Side note: can you amend your snippet with "root" attributes, that would apply to Edit: I can't read. L3 ( |
I hit the same limitation as well... A currently possible solution (for many cases) is to yield the sub-components: <UserCard
@user={{@user}}
{{on 'click' this.openProfile}}
as |uc|
>
<uc.Avatar
class='avatar-sm'
@size='small'
{{on 'click' this.openAvatarModal}}
/>
{{! more stuff here }}
</UserCard> <div ...attributes class='container'>
{{yield (hash
Avatar=(component 'avatar' img=@user.avatar.url classNames='avatar')
)}}
</div> I do not think that this ⬆️ is a good solution.
|
Have you considered merging this with yieldable blocks somehow? |
@buschtoens I have thought about a possible way, but nothing stands out. <UserCard
@user={{@user}}
{{on 'click' this.openProfile}}
[:avatar
class='avatar-sm'
@size='small'
{{on 'click' this.openAvatarModal}}
]
/> and <div ...attributes class='container'>
<Avatar @img={{@user.avatar.url}} {{yield to='avatar}} class='avatar' />
{{! more stuff here }}
</div> But that seems to diverge a bit from |
While I know the use cases you have in mind are real and I have encountered them too, I have always eventually come to regret making a component that's big enough to have multiple internal elements that users want to customize the markup of. Also, I suspect named blocks can do the same things as this proposal. |
I would love for named blocks to support this, but afaict they cannot be used as modifiers. The easiest examples of components that really need this pattern are form fields that combine input and label. |
@knownasilya thanks so much for raising this topic. It’s great that you’re exploring this space. I have a little nitpick with your example: having the It may seem like splitting hairs, but I raise this because I think the relatively restrictive nature of |
Agree on the issue, but seems like we have that today. <label ...attributes>
<input ...attributes>
<label> <Field {{on "click" this.open}}/> Not sure if there could be a way to exclude fields or error if the same event is nested. |
Haha, I didn’t even realise you could use |
As a sidenote, this is one reason I don't really think it's a good idea to use For instance, in these examples, if Fundamentally, |
One thing this calls out (which I've been talking about with folks as we look at how to design components around these kinds of APIs going forward) is that add-ons should document the expectations of |
Agreed @pzuraq and @chriskrycho. Maybe the solution is something like <label ...attributes>
<input ...{{attributes @inputAttributes}}>
<label> <Field @inputAttributes={{hash
name="inputname"
}}/> where modifiers are not allowed. |
Here's a great case for Splat Areas, which, I believe, has been a source of frustration for many Ember developers: cibernox/ember-power-select#1203 |
@knownasilya I really like the updated proposal. Especially since it doesn't introduce some new syntax characters |
I'm leaving the open for now since it is referenced in @NullVoxPopuli's meta issue. |
With the addition of
...attributes
, element modifiers and having multiple top elements in a glimmer component, it has become obvious that...attributes
is too limited (I'm sure the API was mean't to be simple while patterns emerge). Think of a component that wraps an input and a label into a nice package. Currently you'd need to either have the user yield out subcomponents and recreate the same structure or provide custom arguments for each element/component.What if we could expose elements/components for customization by name, for example:
And the user card would apply it like so:
The text was updated successfully, but these errors were encountered: