Skip to content

Commit

Permalink
icon_button: Icon size should be specified as int pixels, not str (#3247
Browse files Browse the repository at this point in the history
)
  • Loading branch information
masenf authored May 8, 2024
1 parent ea0f490 commit 6b8a6f3
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions reflex/components/radix/themes/components/icon_button.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,16 +70,19 @@ def create(cls, *children, **props) -> Component:
"IconButton requires a child icon. Pass a string as the first child or a rx.icon."
)
if "size" in props:
RADIX_TO_LUCIDE_SIZE = {"1": "12px", "2": "24px", "3": "36px", "4": "48px"}
RADIX_TO_LUCIDE_SIZE = {"1": 12, "2": 24, "3": 36, "4": 48}

if isinstance(props["size"], str):
children[0].size = RADIX_TO_LUCIDE_SIZE[props["size"]]
else:
children[0].size = Match.create(
size_map_var = Match.create(
props["size"],
*[(size, px) for size, px in RADIX_TO_LUCIDE_SIZE.items()],
"12px",
12,
)
if not isinstance(size_map_var, Var):
raise ValueError(f"Match did not return a Var: {size_map_var}")
children[0].size = size_map_var
return super().create(*children, **props)

def add_style(self):
Expand Down

0 comments on commit 6b8a6f3

Please sign in to comment.