@@ -61,6 +61,7 @@ protected function __construct(
61
61
protected IconType $ type ,
62
62
protected int $ width = 24 ,
63
63
protected int $ height = 24 ,
64
+ protected ?string $ color = null , // Nouvelle propriété pour la couleur
64
65
) {
65
66
}
66
67
@@ -88,6 +89,20 @@ public function height(int $height): static
88
89
return $ this ;
89
90
}
90
91
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
+
91
106
/**
92
107
* @internal
93
108
*/
@@ -97,14 +112,15 @@ public function toArray(): array
97
112
'type ' => $ this ->type ->value ,
98
113
'width ' => $ this ->width ,
99
114
'height ' => $ this ->height ,
115
+ 'color ' => $ this ->color , // Ajout de la couleur au tableau de sérialisation
100
116
];
101
117
}
102
118
103
119
/**
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
108
124
*
109
125
* @internal
110
126
*/
0 commit comments