فهرست منبع

Radix themes: replace `color_scheme` with `color` in get_fields (#2486)

Masen Furer 1 سال پیش
والد
کامیت
8ecfd07668
2فایلهای تغییر یافته به همراه17 افزوده شده و 0 حذف شده
  1. 15 0
      reflex/components/radix/themes/base.py
  2. 2 0
      reflex/components/radix/themes/base.pyi

+ 15 - 0
reflex/components/radix/themes/base.py

@@ -114,6 +114,21 @@ class RadixThemesComponent(Component):
         )
         return component
 
+    @classmethod
+    def get_fields(cls) -> dict[str, Any]:
+        """Get the pydantic fields for the component.
+
+        Returns:
+            Mapping of field name to ModelField instance.
+        """
+        fields = super().get_fields()
+        if "color_scheme" in fields:
+            # Treat "color" as a direct prop, so the translation of reflex "color_scheme"
+            # to "color" does not put the "color_scheme" value into the "style" prop.
+            fields["color"] = fields.pop("color_scheme")
+            fields["color"].required = False
+        return fields
+
     @staticmethod
     def _get_app_wrap_components() -> dict[tuple[int, str], Component]:
         return {

+ 2 - 0
reflex/components/radix/themes/base.pyi

@@ -322,6 +322,8 @@ class RadixThemesComponent(Component):
             A new component instance.
         """
         ...
+    @classmethod
+    def get_fields(cls) -> dict[str, Any]: ...
 
 class Theme(RadixThemesComponent):
     @overload