grid.py 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. """Container to stack elements with spacing."""
  2. from typing import List
  3. from reflex.components.chakra.layout.base import ChakraLayoutComponent
  4. from reflex.vars import Var
  5. class Grid(ChakraLayoutComponent):
  6. """A grid component."""
  7. tag = "Grid"
  8. # Shorthand prop for gridAutoColumns to provide automatic column sizing based on content.
  9. # Learn more _[here](https://developer.mozilla.org/en-US/docs/Web/CSS/grid-auto-columns)_
  10. auto_columns: Var[str]
  11. # Shorthand prop for gridAutoFlow to specify exactly how
  12. # auto-placed items get flowed into the grid.
  13. # Learn more _[here](https://developer.mozilla.org/en-US/docs/Web/CSS/grid-auto-flow)_
  14. auto_flow: Var[str]
  15. # Shorthand prop for gridAutoRows.
  16. # Learn more _[here](https://developer.mozilla.org/en-US/docs/Web/CSS/grid-auto-rows)_
  17. auto_rows: Var[str]
  18. # Shorthand prop for gridColumn.
  19. # Learn more _[here](https://developer.mozilla.org/en-US/docs/Web/CSS/grid-column)_
  20. column: Var[str]
  21. # Shorthand prop for gridRow.
  22. # Learn more _[here](https://developer.mozilla.org/en-US/docs/Web/CSS/grid-row)_
  23. row: Var[str]
  24. # Shorthand prop for gridTemplateColumns.
  25. # Learn more _[here](https://developer.mozilla.org/en-US/docs/Web/CSS/grid-template-columns)_
  26. template_columns: Var[str]
  27. # Shorthand prop for gridTemplateRows.
  28. # Learn more _[here](https://developer.mozilla.org/en-US/docs/Web/CSS/grid-template-rows)_
  29. template_rows: Var[str]
  30. class GridItem(ChakraLayoutComponent):
  31. """Used as a child of Grid to control the span, and start positions within the grid."""
  32. tag = "GridItem"
  33. # Shorthand prop for gridArea
  34. # Learn more _[here](https://developer.mozilla.org/en-US/docs/Web/CSS/grid-area)_
  35. area: Var[str]
  36. # Shorthand prop for gridColumnEnd
  37. # Learn more _[here](https://developer.mozilla.org/en-US/docs/Web/CSS/grid-column-end)_
  38. col_end: Var[str]
  39. # The column number the grid item should start.
  40. col_start: Var[int]
  41. # The number of columns the grid item should span.
  42. col_span: Var[int]
  43. # Shorthand prop for gridRowEnd
  44. # Learn more _[here](https://developer.mozilla.org/en-US/docs/Web/CSS/grid-row-end)_
  45. row_end: Var[str]
  46. # The row number the grid item should start.
  47. row_start: Var[int]
  48. # The number of rows the grid item should span.
  49. row_span: Var[int]
  50. class ResponsiveGrid(ChakraLayoutComponent):
  51. """A responsive grid component."""
  52. tag = "SimpleGrid"
  53. # Shorthand prop for gridAutoColumns to provide automatic column sizing based on content.
  54. # Learn more _[here](https://developer.mozilla.org/en-US/docs/Web/CSS/grid-auto-columns)_
  55. auto_columns: Var[str]
  56. # Shorthand prop for gridAutoFlow to specify exactly how
  57. # auto-placed items get flowed into the grid.
  58. # Learn more _[here](https://developer.mozilla.org/en-US/docs/Web/CSS/grid-auto-flow)_
  59. auto_flow: Var[str]
  60. # Shorthand prop for gridAutoRows.
  61. # Learn more _[here](https://developer.mozilla.org/en-US/docs/Web/CSS/grid-auto-rows)_
  62. auto_rows: Var[str]
  63. # Shorthand prop for gridColumn.
  64. # Learn more _[here](https://developer.mozilla.org/en-US/docs/Web/CSS/grid-column)_
  65. column: Var[str]
  66. # Shorthand prop for gridRow.
  67. # Learn more _[here](https://developer.mozilla.org/en-US/docs/Web/CSS/grid-row)_
  68. row: Var[str]
  69. # A list that defines the number of columns for each breakpoint.
  70. columns: Var[List[int]]
  71. # The width at which child elements will break into columns. Pass a number for pixel values or a string for any other valid CSS length.
  72. min_child_width: Var[str]
  73. # The gap between the grid items
  74. spacing: Var[str]
  75. # The column gap between the grid items
  76. spacing_x: Var[str]
  77. # The row gap between the grid items
  78. spacing_y: Var[str]
  79. # Shorthand prop for gridTemplateAreas
  80. # Learn more _[here](https://developer.mozilla.org/en-US/docs/Web/CSS/grid-template-areas)_
  81. template_areas: Var[str]
  82. # Shorthand prop for gridTemplateColumns.
  83. # Learn more _[here](https://developer.mozilla.org/en-US/docs/Web/CSS/grid-template-columns)_
  84. template_columns: Var[str]
  85. # Shorthand prop for gridTemplateRows.
  86. # Learn more _[here](https://developer.mozilla.org/en-US/docs/Web/CSS/grid-template-rows)_
  87. template_rows: Var[str]