circularprogress.py 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  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. @classmethod
  25. def create(cls, *children, label=None, **props) -> Component:
  26. """Create a circular progress component.
  27. Args:
  28. children: the children of the component.
  29. label: A label to add in the circular progress. Defaults to None.
  30. props: the props of the component.
  31. Returns:
  32. The circular progress component.
  33. """
  34. if len(children) == 0:
  35. children = []
  36. if label:
  37. children.append(CircularProgressLabel.create(label))
  38. return super().create(*children, **props)
  39. class CircularProgressLabel(ChakraComponent):
  40. """Label of CircularProcess."""
  41. tag = "CircularProgressLabel"