-
Notifications
You must be signed in to change notification settings - Fork 1.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
[GTM-345]Define component props in class for doc discoverability #4183
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i dont think we can take this as is, because some of these create
kwargs that are replaced by props are not valid as Var
@@ -411,6 +411,12 @@ class CodeBlock(Component): | |||
# Props passed down to the code tag. | |||
code_tag_props: Var[Dict[str, str]] | |||
|
|||
# Whether a copy button should appear. | |||
can_copy: Var[Optional[bool]] = Var.create(False) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The other problem here is now these are annotated and treated as Var
... but in many cases, the code in the create
is using python if
statements and potential other operations that are not valid on Var
types.
I'd be more okay defining these as regular model fields (i.e. without the Var
), but then i don't think they'd be automatically picked up by the pyi generator and the doc generation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The regular model fields get picked up by the pyi generator and reflex-web. Some kwargs (that were moved) accept literals or vars. Maybe in this case it might be worth specifying the typing of these model fields to accept both literals and vars
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Example rx.list
where items
can be an iterable or a var containing an iterable so an appropriate typing here might be
items: Optional[Union[Iterable, Var[Iterable]]] = None
use regular model fields where necessary
Co-authored-by: Masen Furer <m_github@0x26.net>
Defines/Moves
create
method args where possible in components as props so reflex-web can discover them