-
Notifications
You must be signed in to change notification settings - Fork 64
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
Feature: default for component collections #47
Comments
Absolutely agree. You're raising 2 important topics: one is auto-populate and another one is dynamic Auto PopulateAuto-population is very much needed and I think we could make it even in a more future-proof way. Right now you can pick your template picker with // Legacy API
{
type: "component-collection",
prop: "data",
label: "List Items",
picker: "large" // or "large-3" | "compact"
}
// New API
{
type: "component-collection",
prop: "data",
label: "List Items",
picker: {
id: "@easyblocks/large", // id could be optional and default to @easyblocks/large as it is now
autoPopulate: true,
numberOfCardsInARow: 2, // could be also 3 potentially
}
}
// New API for custom pickers
{
type: "component-collection",
prop: "data",
label: "List Items",
picker: {
id: "MyCustomPicker",
param1: "a",
param2: "b"
}
}
// and then for EasyblocksEditor component
<EasyblocksEditor components={{...}} widgtets={{...}} pickers={{ MyCustomPicker: component }} /> Such API is much more powerful, it allows for example for dynamic template fetching in a custom picker, custom UI etc. Each picker could decide whether it allows for What do you think? Dynamic
|
The motivation for dynamic accepts is you might only allow certain components to be added to the collection based on a choice in the parent component. This could be where you want the items in the collection to always be the same type - so after he first one is chosen you restrict the others so they are the same. I think with dynamic accepts it's more like allowed selection. The accepts can have multiple items but based on a condition - only A out of A, B and C components can be picked based on the condition. |
Got it. Question: What if, based on condition in parent, only component A is allowed. User adds A,A,A. Then the condition changes and only B is allowed. What happens to A,A,A? What do you think the resolution strategy here should be? |
I think it's about what component can be added next, not what components already exist. For example, you might use it to say "you've already added A, now you can only add B". So it's down to the developer to decide how it works |
Actually it's not how we think about it. We think of If you only want to constraint the templates user sees when template picker is displayed then my suggestion with opening up picker API is much simpler, easier and more practical. Which is good news :) |
Motivation: In some cases you want to repeat the same item in a component collection over and over. It seems redundant to ask the user each time which component they want - especially when there is only one item in the component collection to choose from
The text was updated successfully, but these errors were encountered: