@@ -61,6 +61,7 @@ protected function __construct(
6161 protected IconType $ type ,
6262 protected int $ width = 24 ,
6363 protected int $ height = 24 ,
64+ protected ?string $ color = null , // Nouvelle propriété pour la couleur
6465 ) {
6566 }
6667
@@ -88,6 +89,20 @@ public function height(int $height): static
8889 return $ this ;
8990 }
9091
92+ /**
93+ * Sets the color of the icon.
94+ * Note: This only has an effect on SvgIcon and UxIcon types when rendered client-side by the JavaScript controller.
95+ * The color should be a valid CSS color string (e.g., 'red', '#FF0000', 'rgb(255,0,0)').
96+ *
97+ * @param non-empty-string $color
98+ */
99+ public function color (string $ color ): static
100+ {
101+ $ this ->color = $ color ;
102+
103+ return $ this ;
104+ }
105+
91106 /**
92107 * @internal
93108 */
@@ -97,14 +112,15 @@ public function toArray(): array
97112 'type ' => $ this ->type ->value ,
98113 'width ' => $ this ->width ,
99114 'height ' => $ this ->height ,
115+ 'color ' => $ this ->color , // Ajout de la couleur au tableau de sérialisation
100116 ];
101117 }
102118
103119 /**
104- * @param array{ type: value-of<IconType>, width: positive-int, height: positive-int }
105- * &(array{ url: non-empty-string }
106- * |array{ html: non-empty-string }
107- * |array{ name: non-empty-string }) $data
120+ * @param array{ type: value-of<IconType>, width: positive-int, height: positive-int, color?: string }
121+ * &(array{ url: non-empty-string }
122+ * |array{ html: non-empty-string }
123+ * |array{ name: non-empty-string }) $data
108124 *
109125 * @internal
110126 */
0 commit comments