cmarteepants commented on code in PR #64232:
URL: https://github.com/apache/airflow/pull/64232#discussion_r2997408154


##########
airflow-core/src/airflow/api_fastapi/common/types.py:
##########
@@ -188,19 +188,35 @@ def serialize_model(self) -> str:
         return f"oklch({self.lightness} {self.chroma} {self.hue})"
 
 
+# Private type aliases for theme token shapes
+_ColorShade = dict[Literal["value"], OklchColor]
+_SHADE_LITERAL = Literal["50", "100", "200", "300", "400", "500", "600", 
"700", "800", "900", "950"]
+_ColorScale = dict[_SHADE_LITERAL, _ColorShade]
+
+
+class ThemeColors(BaseModel):
+    """Color tokens for the UI theme. All fields are optional; at least one 
must be provided."""
+
+    brand: _ColorScale | None = None
+    gray: _ColorScale | None = None
+    black: _ColorShade | None = None
+    white: _ColorShade | None = None
+
+    @model_validator(mode="after")
+    def check_at_least_one_color(self) -> ThemeColors:
+        if not any([self.brand, self.gray, self.black, self.white]):
+            raise ValueError("At least one color token must be provided: 
brand, gray, black, or white")
+        return self
+
+    @model_serializer(mode="wrap")
+    def serialize_model(self, handler: Any) -> dict:
+        return {k: v for k, v in handler(self).items() if v is not None}
+
+
 class Theme(BaseModel):
     """JSON to modify Chakra's theme."""
 
-    tokens: dict[
-        Literal["colors"],
-        dict[
-            Literal["brand"],
-            dict[
-                Literal["50", "100", "200", "300", "400", "500", "600", "700", 
"800", "900", "950"],
-                dict[Literal["value"], OklchColor],
-            ],
-        ],
-    ]
+    tokens: dict[Literal["colors"], ThemeColors]

Review Comment:
   Great idea 👍  I'll submit a new PR for it. 



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to