|
@@ -9,10 +9,10 @@ from reflex.vars.base import LiteralVar
|
|
|
class ColorState(rx.State):
|
|
|
"""Test color state."""
|
|
|
|
|
|
- color: str = "mint"
|
|
|
- color_part: str = "tom"
|
|
|
- shade: int = 4
|
|
|
- alpha: bool = False
|
|
|
+ color: rx.Field[str] = rx.field("mint")
|
|
|
+ color_part: rx.Field[str] = rx.field("tom")
|
|
|
+ shade: rx.Field[int] = rx.field(4)
|
|
|
+ alpha: rx.Field[bool] = rx.field(False)
|
|
|
|
|
|
|
|
|
color_state_name = ColorState.get_full_name().replace(".", "__")
|
|
@@ -22,6 +22,12 @@ def create_color_var(color):
|
|
|
return LiteralVar.create(color)
|
|
|
|
|
|
|
|
|
+color_with_fstring = rx.color(
|
|
|
+ f"{ColorState.color}", # pyright: ignore [reportArgumentType]
|
|
|
+ ColorState.shade,
|
|
|
+)
|
|
|
+
|
|
|
+
|
|
|
@pytest.mark.parametrize(
|
|
|
"color, expected, expected_type",
|
|
|
[
|
|
@@ -41,26 +47,27 @@ def create_color_var(color):
|
|
|
Color,
|
|
|
),
|
|
|
(
|
|
|
- create_color_var(rx.color(f"{ColorState.color}", f"{ColorState.shade}")),
|
|
|
- f'("var(--"+{color_state_name!s}.color+"-"+{color_state_name!s}.shade+")")',
|
|
|
+ create_color_var(color_with_fstring),
|
|
|
+ f'("var(--"+{color_state_name!s}.color+"-"+(((__to_string) => __to_string.toString())({color_state_name!s}.shade))+")")',
|
|
|
Color,
|
|
|
),
|
|
|
(
|
|
|
create_color_var(
|
|
|
- rx.color(f"{ColorState.color_part}ato", f"{ColorState.shade}")
|
|
|
+ rx.color(
|
|
|
+ f"{ColorState.color_part}ato", # pyright: ignore [reportArgumentType]
|
|
|
+ ColorState.shade,
|
|
|
+ )
|
|
|
),
|
|
|
- f'("var(--"+({color_state_name!s}.color_part+"ato")+"-"+{color_state_name!s}.shade+")")',
|
|
|
+ f'("var(--"+({color_state_name!s}.color_part+"ato")+"-"+(((__to_string) => __to_string.toString())({color_state_name!s}.shade))+")")',
|
|
|
Color,
|
|
|
),
|
|
|
(
|
|
|
- create_color_var(f"{rx.color(ColorState.color, f'{ColorState.shade}')}"),
|
|
|
+ create_color_var(f"{rx.color(ColorState.color, ColorState.shade)}"),
|
|
|
f'("var(--"+{color_state_name!s}.color+"-"+{color_state_name!s}.shade+")")',
|
|
|
str,
|
|
|
),
|
|
|
(
|
|
|
- create_color_var(
|
|
|
- f"{rx.color(f'{ColorState.color}', f'{ColorState.shade}')}"
|
|
|
- ),
|
|
|
+ create_color_var(f"{color_with_fstring}"),
|
|
|
f'("var(--"+{color_state_name!s}.color+"-"+{color_state_name!s}.shade+")")',
|
|
|
str,
|
|
|
),
|