circularprogress.py 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. """Container to stack elements with spacing."""
  2. from typing import 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: Var[bool]
  11. # If true, the progress will be indeterminate and the value prop will be ignored
  12. is_indeterminate: Var[bool]
  13. # Maximum value defining 100% progress made (must be higher than 'min')
  14. max_: Var[int]
  15. # Minimum value defining 'no progress' (must be lower than 'max')
  16. min_: Var[int]
  17. # This defines the stroke width of the svg circle.
  18. thickness: Var[Union[str, int]]
  19. # The color name of the progress track. Use a color key in the theme object
  20. track_color: Var[str]
  21. # Current progress (must be between min/max).
  22. value: Var[int]
  23. # The desired valueText to use in place of the value.
  24. value_text: Var[str]
  25. # The color name of the progress bar
  26. color: Var[str]
  27. # The size of the circular progress
  28. size: Var[str]
  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"