circularprogress.py 1.9 KB

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