From d0fd3bd9f2fb9e7646bc9244df4e8a02f2da1f5a Mon Sep 17 00:00:00 2001 From: Elijah Date: Wed, 16 Oct 2024 13:43:50 +0000 Subject: [PATCH] Define component props in class for doc discoverability --- reflex/components/datadisplay/code.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/reflex/components/datadisplay/code.py b/reflex/components/datadisplay/code.py index c18e44885..854726b26 100644 --- a/reflex/components/datadisplay/code.py +++ b/reflex/components/datadisplay/code.py @@ -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]] = False + + # A custom copy button to override the default one. + copy_button: Var[Optional[Union[bool, Component]]] = None + def add_imports(self) -> ImportDict: """Add imports for the CodeBlock component. @@ -448,16 +454,12 @@ class CodeBlock(Component): def create( cls, *children, - can_copy: Optional[bool] = False, - copy_button: Optional[Union[bool, Component]] = None, **props, ): """Create a text component. Args: *children: The children of the component. - can_copy: Whether a copy button should appears. - copy_button: A custom copy button to override the default one. **props: The props to pass to the component. Returns: @@ -465,6 +467,8 @@ class CodeBlock(Component): """ # This component handles style in a special prop. custom_style = props.pop("custom_style", {}) + can_copy = props.pop("can_copy", False) + copy_button = props.pop("copy_button", None) if "theme" not in props: # Default color scheme responds to global color mode.