1
0

circularprogress.py 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. """Container to stack elements with spacing."""
  2. from typing import Optional, Union
  3. from reflex.components.chakra import ChakraComponent
  4. from reflex.components.component import Component
  5. from reflex.vars import Var
  6. class CircularProgress(ChakraComponent):
  7. """The CircularProgress component is used to indicate the progress for determinate and indeterminate processes."""
  8. tag = "CircularProgress"
  9. # If true, the cap of the progress indicator will be rounded.
  10. cap_is_round: Optional[Var[bool]] = None
  11. # If true, the progress will be indeterminate and the value prop will be ignored
  12. is_indeterminate: Optional[Var[bool]] = None
  13. # Maximum value defining 100% progress made (must be higher than 'min')
  14. max_: Optional[Var[int]] = None
  15. # Minimum value defining 'no progress' (must be lower than 'max')
  16. min_: Optional[Var[int]] = None
  17. # This defines the stroke width of the svg circle.
  18. thickness: Optional[Var[Union[str, int]]] = None
  19. # The color name of the progress track. Use a color key in the theme object
  20. track_color: Optional[Var[str]] = None
  21. # Current progress (must be between min/max).
  22. value: Optional[Var[int]] = None
  23. # The desired valueText to use in place of the value.
  24. value_text: Optional[Var[str]] = None
  25. # The color name of the progress bar
  26. color: Optional[Var[str]] = None
  27. # The size of the circular progress
  28. size: Optional[Var[str]] = None
  29. @classmethod
  30. def create(cls, *children, label=None, **props) -> Component:
  31. """Create a circular progress component.
  32. Args:
  33. *children: the children of the component.
  34. label: A label to add in the circular progress. Defaults to None.
  35. **props: the props of the component.
  36. Returns:
  37. The circular progress component.
  38. """
  39. if len(children) == 0:
  40. children = []
  41. if label is not None:
  42. children.append(CircularProgressLabel.create(label))
  43. return super().create(*children, **props)
  44. class CircularProgressLabel(ChakraComponent):
  45. """Label of CircularProcess."""
  46. tag = "CircularProgressLabel"