Skip to content

Commit

Permalink
Merge pull request #387 from lhhyung/master
Browse files Browse the repository at this point in the history
fix: fixed icon_color for enum fields of type 'state'
  • Loading branch information
ImMin5 authored Jul 30, 2024
2 parents ef62f11 + bb848ba commit a8fc257
Showing 1 changed file with 8 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -335,10 +335,11 @@ def _generate_state_field(self, field: dict, is_enum: bool = False) -> dict:
if "is_optional" in field:
field = self._add_options_field(field, "is_optional")

if not is_enum:
return StateField(**field).dict(exclude_none=True)
else:
if is_enum:
return EnumStateField(**field).dict(exclude_none=True)
else:
return StateField(**field).dict(exclude_none=True)


def _generate_badge_field(self, field: dict, is_enum: bool = False) -> dict:
if not is_enum:
Expand Down Expand Up @@ -438,6 +439,7 @@ def _generate_enum_field(self, field: dict) -> dict:
key for key in enum.keys() if key not in enable_enum_options
][0]


if enum["type"] == "badge":
enum["outline_color"] = enum[main_key]
del enum[main_key]
Expand All @@ -446,8 +448,9 @@ def _generate_enum_field(self, field: dict) -> dict:
)

elif enum["type"] == "state":
enum["icon_color"] = enum[main_key]
del enum[main_key]
if icon_color := enum[main_key]:
enum["icon_color"] = icon_color
del enum[main_key]
enums[main_key] = self._generate_state_field(
field=enum, is_enum=True
)
Expand Down

0 comments on commit a8fc257

Please sign in to comment.