Skip to content

Commit 855a20f

Browse files
[GTM-648]Add Missing Table props (#4322)
* Add Missing Table props * add more props
1 parent 227d09a commit 855a20f

File tree

6 files changed

+566
-94
lines changed

6 files changed

+566
-94
lines changed

reflex/components/radix/themes/base.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
from typing import Any, Dict, Literal
66

77
from reflex.components import Component
8+
from reflex.components.core.breakpoints import Responsive
89
from reflex.components.tags import Tag
910
from reflex.config import get_config
1011
from reflex.utils.imports import ImportDict, ImportVar
@@ -74,6 +75,31 @@ class CommonMarginProps(Component):
7475
ml: Var[LiteralSpacing]
7576

7677

78+
class CommonPaddingProps(Component):
79+
"""Many radix-themes elements accept shorthand padding props."""
80+
81+
# Padding: "0" - "9"
82+
p: Var[Responsive[LiteralSpacing]]
83+
84+
# Padding horizontal: "0" - "9"
85+
px: Var[Responsive[LiteralSpacing]]
86+
87+
# Padding vertical: "0" - "9"
88+
py: Var[Responsive[LiteralSpacing]]
89+
90+
# Padding top: "0" - "9"
91+
pt: Var[Responsive[LiteralSpacing]]
92+
93+
# Padding right: "0" - "9"
94+
pr: Var[Responsive[LiteralSpacing]]
95+
96+
# Padding bottom: "0" - "9"
97+
pb: Var[Responsive[LiteralSpacing]]
98+
99+
# Padding left: "0" - "9"
100+
pl: Var[Responsive[LiteralSpacing]]
101+
102+
77103
class RadixLoadingProp(Component):
78104
"""Base class for components that can be in a loading state."""
79105

reflex/components/radix/themes/base.pyi

Lines changed: 173 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
from typing import Any, Dict, Literal, Optional, Union, overload
77

88
from reflex.components import Component
9+
from reflex.components.core.breakpoints import Breakpoints
910
from reflex.event import BASE_STATE, EventType
1011
from reflex.style import Style
1112
from reflex.utils.imports import ImportDict
@@ -144,6 +145,178 @@ class CommonMarginProps(Component):
144145
"""
145146
...
146147

148+
class CommonPaddingProps(Component):
149+
@overload
150+
@classmethod
151+
def create( # type: ignore
152+
cls,
153+
*children,
154+
p: Optional[
155+
Union[
156+
Breakpoints[
157+
str, Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"]
158+
],
159+
Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"],
160+
Var[
161+
Union[
162+
Breakpoints[
163+
str,
164+
Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"],
165+
],
166+
Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"],
167+
]
168+
],
169+
]
170+
] = None,
171+
px: Optional[
172+
Union[
173+
Breakpoints[
174+
str, Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"]
175+
],
176+
Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"],
177+
Var[
178+
Union[
179+
Breakpoints[
180+
str,
181+
Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"],
182+
],
183+
Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"],
184+
]
185+
],
186+
]
187+
] = None,
188+
py: Optional[
189+
Union[
190+
Breakpoints[
191+
str, Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"]
192+
],
193+
Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"],
194+
Var[
195+
Union[
196+
Breakpoints[
197+
str,
198+
Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"],
199+
],
200+
Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"],
201+
]
202+
],
203+
]
204+
] = None,
205+
pt: Optional[
206+
Union[
207+
Breakpoints[
208+
str, Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"]
209+
],
210+
Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"],
211+
Var[
212+
Union[
213+
Breakpoints[
214+
str,
215+
Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"],
216+
],
217+
Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"],
218+
]
219+
],
220+
]
221+
] = None,
222+
pr: Optional[
223+
Union[
224+
Breakpoints[
225+
str, Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"]
226+
],
227+
Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"],
228+
Var[
229+
Union[
230+
Breakpoints[
231+
str,
232+
Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"],
233+
],
234+
Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"],
235+
]
236+
],
237+
]
238+
] = None,
239+
pb: Optional[
240+
Union[
241+
Breakpoints[
242+
str, Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"]
243+
],
244+
Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"],
245+
Var[
246+
Union[
247+
Breakpoints[
248+
str,
249+
Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"],
250+
],
251+
Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"],
252+
]
253+
],
254+
]
255+
] = None,
256+
pl: Optional[
257+
Union[
258+
Breakpoints[
259+
str, Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"]
260+
],
261+
Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"],
262+
Var[
263+
Union[
264+
Breakpoints[
265+
str,
266+
Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"],
267+
],
268+
Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"],
269+
]
270+
],
271+
]
272+
] = None,
273+
style: Optional[Style] = None,
274+
key: Optional[Any] = None,
275+
id: Optional[Any] = None,
276+
class_name: Optional[Any] = None,
277+
autofocus: Optional[bool] = None,
278+
custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
279+
on_blur: Optional[EventType[[], BASE_STATE]] = None,
280+
on_click: Optional[EventType[[], BASE_STATE]] = None,
281+
on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
282+
on_double_click: Optional[EventType[[], BASE_STATE]] = None,
283+
on_focus: Optional[EventType[[], BASE_STATE]] = None,
284+
on_mount: Optional[EventType[[], BASE_STATE]] = None,
285+
on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
286+
on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
287+
on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
288+
on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
289+
on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
290+
on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
291+
on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
292+
on_scroll: Optional[EventType[[], BASE_STATE]] = None,
293+
on_unmount: Optional[EventType[[], BASE_STATE]] = None,
294+
**props,
295+
) -> "CommonPaddingProps":
296+
"""Create the component.
297+
298+
Args:
299+
*children: The children of the component.
300+
p: Padding: "0" - "9"
301+
px: Padding horizontal: "0" - "9"
302+
py: Padding vertical: "0" - "9"
303+
pt: Padding top: "0" - "9"
304+
pr: Padding right: "0" - "9"
305+
pb: Padding bottom: "0" - "9"
306+
pl: Padding left: "0" - "9"
307+
style: The style of the component.
308+
key: A unique key for the component.
309+
id: The id for the component.
310+
class_name: The class name for the component.
311+
autofocus: Whether the component should take the focus once the page is loaded
312+
custom_attrs: custom attribute
313+
**props: The props of the component.
314+
315+
Returns:
316+
The component.
317+
"""
318+
...
319+
147320
class RadixLoadingProp(Component):
148321
@overload
149322
@classmethod

reflex/components/radix/themes/components/table.py

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
from reflex.components.el import elements
88
from reflex.vars.base import Var
99

10-
from ..base import RadixThemesComponent
10+
from ..base import CommonPaddingProps, RadixThemesComponent
1111

1212

1313
class TableRoot(elements.Table, RadixThemesComponent):
@@ -51,6 +51,12 @@ class TableColumnHeaderCell(elements.Th, RadixThemesComponent):
5151
# The justification of the column
5252
justify: Var[Literal["start", "center", "end"]]
5353

54+
# The minimum width of the cell
55+
min_width: Var[Responsive[str]]
56+
57+
# The maximum width of the cell
58+
max_width: Var[Responsive[str]]
59+
5460
_invalid_children: List[str] = [
5561
"TableBody",
5662
"TableHeader",
@@ -76,14 +82,20 @@ class TableBody(elements.Tbody, RadixThemesComponent):
7682
_valid_parents: List[str] = ["TableRoot"]
7783

7884

79-
class TableCell(elements.Td, RadixThemesComponent):
85+
class TableCell(elements.Td, CommonPaddingProps, RadixThemesComponent):
8086
"""A cell containing data."""
8187

8288
tag = "Table.Cell"
8389

8490
# The justification of the column
8591
justify: Var[Literal["start", "center", "end"]]
8692

93+
# The minimum width of the cell
94+
min_width: Var[Responsive[str]]
95+
96+
# The maximum width of the cell
97+
max_width: Var[Responsive[str]]
98+
8799
_invalid_children: List[str] = [
88100
"TableBody",
89101
"TableHeader",
@@ -93,14 +105,20 @@ class TableCell(elements.Td, RadixThemesComponent):
93105
]
94106

95107

96-
class TableRowHeaderCell(elements.Th, RadixThemesComponent):
108+
class TableRowHeaderCell(elements.Th, CommonPaddingProps, RadixThemesComponent):
97109
"""A table cell that is semantically treated as a row header."""
98110

99111
tag = "Table.RowHeaderCell"
100112

101113
# The justification of the column
102114
justify: Var[Literal["start", "center", "end"]]
103115

116+
# The minimum width of the cell
117+
min_width: Var[Responsive[str]]
118+
119+
# The maximum width of the cell
120+
max_width: Var[Responsive[str]]
121+
104122
_invalid_children: List[str] = [
105123
"TableBody",
106124
"TableHeader",

0 commit comments

Comments
 (0)