Define component props in class for doc discoverability
This commit is contained in:
parent
2018be8e08
commit
d0fd3bd9f2
@ -411,6 +411,12 @@ class CodeBlock(Component):
|
|||||||
# Props passed down to the code tag.
|
# Props passed down to the code tag.
|
||||||
code_tag_props: Var[Dict[str, str]]
|
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:
|
def add_imports(self) -> ImportDict:
|
||||||
"""Add imports for the CodeBlock component.
|
"""Add imports for the CodeBlock component.
|
||||||
|
|
||||||
@ -448,16 +454,12 @@ class CodeBlock(Component):
|
|||||||
def create(
|
def create(
|
||||||
cls,
|
cls,
|
||||||
*children,
|
*children,
|
||||||
can_copy: Optional[bool] = False,
|
|
||||||
copy_button: Optional[Union[bool, Component]] = None,
|
|
||||||
**props,
|
**props,
|
||||||
):
|
):
|
||||||
"""Create a text component.
|
"""Create a text component.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
*children: The children of the component.
|
*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.
|
**props: The props to pass to the component.
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
@ -465,6 +467,8 @@ class CodeBlock(Component):
|
|||||||
"""
|
"""
|
||||||
# This component handles style in a special prop.
|
# This component handles style in a special prop.
|
||||||
custom_style = props.pop("custom_style", {})
|
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:
|
if "theme" not in props:
|
||||||
# Default color scheme responds to global color mode.
|
# Default color scheme responds to global color mode.
|
||||||
|
Loading…
Reference in New Issue
Block a user