-
Notifications
You must be signed in to change notification settings - Fork 131
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
Type safe way to pass kwargs to sub-components #203
Comments
Yes i like it. I think something distinguishing the vuetify component from the solara component would helpful, which is something using Should they still be called import solara
solara.SliderInt(..., slider=solara.v.Slider(tick_labels=[....]))
solara.Card(...., card_text=solara.v.CardText(....), card=solara.v.Card(...)) now the kwargs more directly describe which view part of the component they reference to. Perhaps this API could also be repurposed in the future to pass non-vuetify views/widgets to components? import solara
solara.SliderInt(..., slider=solara.material.Slider()) By the way, the |
Its an interesting solution, i tried something similar with my own Card component with a 'card_text_style' kwarg, although I didn't actually use it in the end. The conceptual question is, are the solara components convenience wrappers around Vuetify components, or are they "solara's own" components that just happen to be implemented with vuetify elements? If they are solara 'internal' components then maybe they should better have their own api not related to vuetify. On the other hand if they are mainly convenience wrappers this makes sense, i guess for advanced cases you'd want to use the vuetify components directly. |
It is this. I think a user should be able to use the solara components for most of the work without having to know about (ipy)vuetify. But, for advanced users we do not have to hide that they are built using vuetify, and we can provide an escape hatch when you do need this specific-almost-never-used-vuetify-prop. I don't think we should expose the whole surface of vuetify, though, since it's just overwhelming.
This does imply that also the behaviour/implementation will be overridden, while originally it was only meant as a way to pass extra props/kwargs to underlying components. Maybe there is a good reason to do this, if not, maybe every vuetify component should have a TypedDict (also generated from the same reacton code generator) that can be used for typing the kwargs, e.g.: @solara.component
def Card(...., card_text_kwargs:solara.v.CardTextDict = {}, ...)
...
======
class CardTextDict(TypedDict):
# 100 vuetify props |
See #194, #50, #154, #182
If a solara component does not expose an argument/kwarg/prop that the underlying vuetify library supports, a user is stuck.
However, if we simply add
**kwargs
support, we lose type safety/strict argument checking. However, if we use something likeWe can provide a type safe way of passing kwargs to subcomponents.
In the case of #194, with the card component, we wrap multiple components, which cannot use a single
**kwargs
argument. Using our solution above, we can support it using:Would be good to get feedback on this idea from @mangecoeur @Jhsmit @mariobuikhuizen or others.
The text was updated successfully, but these errors were encountered: