diff --git a/reflex/vars/sequence.py b/reflex/vars/sequence.py index 65b8235dd..e31f7ef61 100644 --- a/reflex/vars/sequence.py +++ b/reflex/vars/sequence.py @@ -1699,7 +1699,7 @@ class LiteralColorVar(CachedVarOperation, LiteralVar, ColorVar): ternary_operation( alpha, LiteralStringVar.create("a"), - LiteralStringVar.create("False"), + LiteralStringVar.create(""), ) if isinstance(alpha, Var) else LiteralStringVar.create("a" if alpha else "") diff --git a/tests/units/components/core/test_colors.py b/tests/units/components/core/test_colors.py index 7aa5bbca9..e5c6d250b 100644 --- a/tests/units/components/core/test_colors.py +++ b/tests/units/components/core/test_colors.py @@ -14,6 +14,7 @@ class ColorState(rx.State): color: str = "mint" color_part: str = "tom" shade: int = 4 + alpha: bool = False color_state_name = ColorState.get_full_name().replace(".", "__") @@ -34,6 +35,13 @@ def create_color_var(color): f'("var(--"+{str(color_state_name)}.color+"-"+(((__to_string) => __to_string.toString())({str(color_state_name)}.shade))+")")', Color, ), + ( + create_color_var( + rx.color(ColorState.color, ColorState.shade, ColorState.alpha) + ), # type: ignore + f'("var(--"+{str(color_state_name)}.color+"-"+({str(color_state_name)}.alpha ? "a" : "")+(((__to_string) => __to_string.toString())({str(color_state_name)}.shade))+")")', + Color, + ), ( create_color_var(rx.color(f"{ColorState.color}", f"{ColorState.shade}")), # type: ignore f'("var(--"+{str(color_state_name)}.color+"-"+{str(color_state_name)}.shade+")")',