transition.py 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. """A transition Component."""
  2. from typing import Union
  3. from pynecone.components.libs.chakra import ChakraComponent
  4. from pynecone.utils import imports
  5. from pynecone.vars import ImportVar, Var
  6. class Transition(ChakraComponent):
  7. """Base componemt of all transitions."""
  8. in_: Var[bool]
  9. unmount_on_exit: Var[bool] = False # type: ignore
  10. def _get_imports(self) -> imports.ImportDict:
  11. return imports.merge_imports(
  12. super()._get_imports(),
  13. {"@chakra-ui/react": {ImportVar(tag="useDisclosure")}},
  14. )
  15. class Fade(Transition):
  16. """Fade component cab be used show and hide content of your app."""
  17. tag = "Fade"
  18. class ScaleFade(Transition):
  19. """Fade component can be scaled and reverse your app."""
  20. tag = "ScaleFade"
  21. unmount_on_exit: Var[bool] = False # type: ignore
  22. initial_scale: Var[float] = 0.95 # type: ignore
  23. reverse: Var[bool] = True # type: ignore
  24. class Slide(Transition):
  25. """Side can be used show content below your app."""
  26. tag = "Slide"
  27. direction: Var[str] = "right" # type: ignore
  28. class SlideFade(Transition):
  29. """SlideFade component."""
  30. tag = "SlideFade"
  31. offsetX: Var[Union[str, int]] = 0 # type: ignore
  32. offsetY: Var[Union[str, int]] = 8 # type: ignore
  33. reverse: Var[bool] = True # type: ignore
  34. class Collapse(Transition):
  35. """Collapse component can collapse some content."""
  36. tag = "Collapse"
  37. animateOpacity: Var[bool] = True # type: ignore
  38. endingHeight: Var[str] = "auto" # type: ignore
  39. startingHeight: Var[Union[str, int]] = 0 # type: ignore