diff --git a/packages/support/src/Colors/Color.php b/packages/support/src/Colors/Color.php index 457637e928..44aa14a4a6 100644 --- a/packages/support/src/Colors/Color.php +++ b/packages/support/src/Colors/Color.php @@ -16,29 +16,6 @@ class Color 800 => 'oklch(0.279 0.041 260.031)', 900 => 'oklch(0.208 0.042 265.755)', 950 => 'oklch(0.129 0.042 264.695)', - '50-text' => 950, - '100-text' => 950, - '200-text' => 950, - '300-text' => 950, - '400-text' => 950, - '500-text' => 50, - '600-text' => 50, - '700-text' => 50, - '800-text' => 50, - '900-text' => 50, - '950-text' => 50, - 'white-text' => 500, - 'gray-50-text' => 500, - 'gray-100-text' => 600, - 'gray-200-text' => 600, - 'gray-300-text' => 600, - 'gray-400-text' => 800, - 'gray-500-text' => 50, - 'gray-600-text' => 300, - 'gray-700-text' => 300, - 'gray-800-text' => 400, - 'gray-900-text' => 400, - 'gray-950-text' => 400, ]; public const Gray = [ @@ -53,29 +30,6 @@ class Color 800 => 'oklch(0.278 0.033 256.848)', 900 => 'oklch(0.21 0.034 264.665)', 950 => 'oklch(0.13 0.028 261.692)', - '50-text' => 950, - '100-text' => 950, - '200-text' => 950, - '300-text' => 950, - '400-text' => 950, - '500-text' => 50, - '600-text' => 50, - '700-text' => 50, - '800-text' => 50, - '900-text' => 50, - '950-text' => 50, - 'white-text' => 500, - 'gray-50-text' => 500, - 'gray-100-text' => 600, - 'gray-200-text' => 600, - 'gray-300-text' => 600, - 'gray-400-text' => 800, - 'gray-500-text' => 50, - 'gray-600-text' => 300, - 'gray-700-text' => 300, - 'gray-800-text' => 400, - 'gray-900-text' => 400, - 'gray-950-text' => 400, ]; public const Zinc = [ @@ -90,29 +44,6 @@ class Color 800 => 'oklch(0.274 0.006 286.033)', 900 => 'oklch(0.21 0.006 285.885)', 950 => 'oklch(0.141 0.005 285.823)', - '50-text' => 950, - '100-text' => 950, - '200-text' => 950, - '300-text' => 950, - '400-text' => 950, - '500-text' => 50, - '600-text' => 50, - '700-text' => 50, - '800-text' => 50, - '900-text' => 50, - '950-text' => 50, - 'white-text' => 500, - 'gray-50-text' => 500, - 'gray-100-text' => 600, - 'gray-200-text' => 600, - 'gray-300-text' => 600, - 'gray-400-text' => 800, - 'gray-500-text' => 50, - 'gray-600-text' => 300, - 'gray-700-text' => 300, - 'gray-800-text' => 400, - 'gray-900-text' => 400, - 'gray-950-text' => 400, ]; public const Neutral = [ @@ -127,29 +58,6 @@ class Color 800 => 'oklch(0.269 0 0)', 900 => 'oklch(0.205 0 0)', 950 => 'oklch(0.145 0 0)', - '50-text' => 950, - '100-text' => 950, - '200-text' => 950, - '300-text' => 950, - '400-text' => 950, - '500-text' => 50, - '600-text' => 50, - '700-text' => 50, - '800-text' => 50, - '900-text' => 50, - '950-text' => 50, - 'white-text' => 500, - 'gray-50-text' => 500, - 'gray-100-text' => 600, - 'gray-200-text' => 600, - 'gray-300-text' => 600, - 'gray-400-text' => 800, - 'gray-500-text' => 50, - 'gray-600-text' => 300, - 'gray-700-text' => 300, - 'gray-800-text' => 400, - 'gray-900-text' => 400, - 'gray-950-text' => 400, ]; public const Stone = [ @@ -164,29 +72,6 @@ class Color 800 => 'oklch(0.268 0.007 34.298)', 900 => 'oklch(0.216 0.006 56.043)', 950 => 'oklch(0.147 0.004 49.25)', - '50-text' => 950, - '100-text' => 950, - '200-text' => 950, - '300-text' => 950, - '400-text' => 950, - '500-text' => 50, - '600-text' => 50, - '700-text' => 50, - '800-text' => 50, - '900-text' => 50, - '950-text' => 50, - 'white-text' => 500, - 'gray-50-text' => 500, - 'gray-100-text' => 600, - 'gray-200-text' => 600, - 'gray-300-text' => 600, - 'gray-400-text' => 800, - 'gray-500-text' => 50, - 'gray-600-text' => 300, - 'gray-700-text' => 300, - 'gray-800-text' => 400, - 'gray-900-text' => 400, - 'gray-950-text' => 400, ]; public const Red = [ @@ -201,29 +86,6 @@ class Color 800 => 'oklch(0.444 0.177 26.899)', 900 => 'oklch(0.396 0.141 25.723)', 950 => 'oklch(0.258 0.092 26.042)', - '50-text' => 950, - '100-text' => 950, - '200-text' => 950, - '300-text' => 950, - '400-text' => 950, - '500-text' => 0, - '600-text' => 0, - '700-text' => 0, - '800-text' => 0, - '900-text' => 0, - '950-text' => 0, - 'white-text' => 600, - 'gray-50-text' => 600, - 'gray-100-text' => 700, - 'gray-200-text' => 700, - 'gray-300-text' => 800, - 'gray-400-text' => 950, - 'gray-500-text' => 0, - 'gray-600-text' => 200, - 'gray-700-text' => 300, - 'gray-800-text' => 400, - 'gray-900-text' => 500, - 'gray-950-text' => 500, ]; public const Orange = [ @@ -238,29 +100,6 @@ class Color 800 => 'oklch(0.47 0.157 37.304)', 900 => 'oklch(0.408 0.123 38.172)', 950 => 'oklch(0.266 0.079 36.259)', - '50-text' => 950, - '100-text' => 950, - '200-text' => 950, - '300-text' => 950, - '400-text' => 950, - '500-text' => 950, - '600-text' => 950, - '700-text' => 50, - '800-text' => 50, - '900-text' => 50, - '950-text' => 50, - 'white-text' => 700, - 'gray-50-text' => 700, - 'gray-100-text' => 700, - 'gray-200-text' => 800, - 'gray-300-text' => 800, - 'gray-400-text' => 950, - 'gray-500-text' => 50, - 'gray-600-text' => 300, - 'gray-700-text' => 400, - 'gray-800-text' => 500, - 'gray-900-text' => 600, - 'gray-950-text' => 600, ]; public const Amber = [ @@ -275,29 +114,6 @@ class Color 800 => 'oklch(0.473 0.137 46.201)', 900 => 'oklch(0.414 0.112 45.904)', 950 => 'oklch(0.279 0.077 45.635)', - '50-text' => 950, - '100-text' => 950, - '200-text' => 950, - '300-text' => 950, - '400-text' => 950, - '500-text' => 950, - '600-text' => 950, - '700-text' => 50, - '800-text' => 50, - '900-text' => 50, - '950-text' => 50, - 'white-text' => 700, - 'gray-50-text' => 700, - 'gray-100-text' => 700, - 'gray-200-text' => 800, - 'gray-300-text' => 800, - 'gray-400-text' => 950, - 'gray-500-text' => 50, - 'gray-600-text' => 300, - 'gray-700-text' => 500, - 'gray-800-text' => 600, - 'gray-900-text' => 600, - 'gray-950-text' => 600, ]; public const Yellow = [ @@ -312,29 +128,6 @@ class Color 800 => 'oklch(0.476 0.114 61.907)', 900 => 'oklch(0.421 0.095 57.708)', 950 => 'oklch(0.286 0.066 53.813)', - '50-text' => 950, - '100-text' => 950, - '200-text' => 950, - '300-text' => 950, - '400-text' => 950, - '500-text' => 950, - '600-text' => 950, - '700-text' => 50, - '800-text' => 50, - '900-text' => 50, - '950-text' => 50, - 'white-text' => 700, - 'gray-50-text' => 700, - 'gray-100-text' => 800, - 'gray-200-text' => 800, - 'gray-300-text' => 800, - 'gray-400-text' => 950, - 'gray-500-text' => 50, - 'gray-600-text' => 400, - 'gray-700-text' => 500, - 'gray-800-text' => 600, - 'gray-900-text' => 600, - 'gray-950-text' => 600, ]; public const Lime = [ @@ -349,29 +142,6 @@ class Color 800 => 'oklch(0.453 0.124 130.933)', 900 => 'oklch(0.405 0.101 131.063)', 950 => 'oklch(0.274 0.072 132.109)', - '50-text' => 950, - '100-text' => 950, - '200-text' => 950, - '300-text' => 950, - '400-text' => 950, - '500-text' => 950, - '600-text' => 950, - '700-text' => 50, - '800-text' => 50, - '900-text' => 50, - '950-text' => 50, - 'white-text' => 700, - 'gray-50-text' => 700, - 'gray-100-text' => 700, - 'gray-200-text' => 800, - 'gray-300-text' => 800, - 'gray-400-text' => 950, - 'gray-500-text' => 50, - 'gray-600-text' => 400, - 'gray-700-text' => 500, - 'gray-800-text' => 600, - 'gray-900-text' => 600, - 'gray-950-text' => 600, ]; public const Green = [ @@ -386,29 +156,6 @@ class Color 800 => 'oklch(0.448 0.119 151.328)', 900 => 'oklch(0.393 0.095 152.535)', 950 => 'oklch(0.266 0.065 152.934)', - '50-text' => 950, - '100-text' => 950, - '200-text' => 950, - '300-text' => 950, - '400-text' => 950, - '500-text' => 950, - '600-text' => 950, - '700-text' => 50, - '800-text' => 50, - '900-text' => 50, - '950-text' => 50, - 'white-text' => 700, - 'gray-50-text' => 700, - 'gray-100-text' => 800, - 'gray-200-text' => 800, - 'gray-300-text' => 800, - 'gray-400-text' => 950, - 'gray-500-text' => 50, - 'gray-600-text' => 300, - 'gray-700-text' => 500, - 'gray-800-text' => 600, - 'gray-900-text' => 600, - 'gray-950-text' => 600, ]; public const Emerald = [ @@ -423,29 +170,6 @@ class Color 800 => 'oklch(0.432 0.095 166.913)', 900 => 'oklch(0.378 0.077 168.94)', 950 => 'oklch(0.262 0.051 172.552)', - '50-text' => 950, - '100-text' => 950, - '200-text' => 950, - '300-text' => 950, - '400-text' => 950, - '500-text' => 950, - '600-text' => 0, - '700-text' => 0, - '800-text' => 0, - '900-text' => 0, - '950-text' => 0, - 'white-text' => 700, - 'gray-50-text' => 700, - 'gray-100-text' => 700, - 'gray-200-text' => 800, - 'gray-300-text' => 800, - 'gray-400-text' => 950, - 'gray-500-text' => 50, - 'gray-600-text' => 300, - 'gray-700-text' => 400, - 'gray-800-text' => 500, - 'gray-900-text' => 600, - 'gray-950-text' => 600, ]; public const Teal = [ @@ -460,29 +184,6 @@ class Color 800 => 'oklch(0.437 0.078 188.216)', 900 => 'oklch(0.386 0.063 188.416)', 950 => 'oklch(0.277 0.046 192.524)', - '50-text' => 950, - '100-text' => 950, - '200-text' => 950, - '300-text' => 950, - '400-text' => 950, - '500-text' => 950, - '600-text' => 0, - '700-text' => 0, - '800-text' => 0, - '900-text' => 0, - '950-text' => 0, - 'white-text' => 700, - 'gray-50-text' => 700, - 'gray-100-text' => 700, - 'gray-200-text' => 800, - 'gray-300-text' => 800, - 'gray-400-text' => 950, - 'gray-500-text' => 50, - 'gray-600-text' => 300, - 'gray-700-text' => 400, - 'gray-800-text' => 500, - 'gray-900-text' => 600, - 'gray-950-text' => 600, ]; public const Cyan = [ @@ -497,29 +198,6 @@ class Color 800 => 'oklch(0.45 0.085 224.283)', 900 => 'oklch(0.398 0.07 227.392)', 950 => 'oklch(0.302 0.056 229.695)', - '50-text' => 950, - '100-text' => 950, - '200-text' => 950, - '300-text' => 950, - '400-text' => 950, - '500-text' => 950, - '600-text' => 0, - '700-text' => 0, - '800-text' => 0, - '900-text' => 0, - '950-text' => 0, - 'white-text' => 700, - 'gray-50-text' => 700, - 'gray-100-text' => 700, - 'gray-200-text' => 800, - 'gray-300-text' => 800, - 'gray-400-text' => 950, - 'gray-500-text' => 50, - 'gray-600-text' => 300, - 'gray-700-text' => 500, - 'gray-800-text' => 500, - 'gray-900-text' => 600, - 'gray-950-text' => 600, ]; public const Sky = [ @@ -534,29 +212,6 @@ class Color 800 => 'oklch(0.443 0.11 240.79)', 900 => 'oklch(0.391 0.09 240.876)', 950 => 'oklch(0.293 0.066 243.157)', - '50-text' => 950, - '100-text' => 950, - '200-text' => 950, - '300-text' => 950, - '400-text' => 950, - '500-text' => 950, - '600-text' => 0, - '700-text' => 0, - '800-text' => 0, - '900-text' => 0, - '950-text' => 0, - 'white-text' => 700, - 'gray-50-text' => 700, - 'gray-100-text' => 700, - 'gray-200-text' => 700, - 'gray-300-text' => 800, - 'gray-400-text' => 950, - 'gray-500-text' => 50, - 'gray-600-text' => 300, - 'gray-700-text' => 400, - 'gray-800-text' => 500, - 'gray-900-text' => 600, - 'gray-950-text' => 600, ]; public const Blue = [ @@ -571,29 +226,6 @@ class Color 800 => 'oklch(0.424 0.199 265.638)', 900 => 'oklch(0.379 0.146 265.522)', 950 => 'oklch(0.282 0.091 267.935)', - '50-text' => 950, - '100-text' => 950, - '200-text' => 950, - '300-text' => 950, - '400-text' => 950, - '500-text' => 0, - '600-text' => 0, - '700-text' => 0, - '800-text' => 0, - '900-text' => 0, - '950-text' => 0, - 'white-text' => 600, - 'gray-50-text' => 600, - 'gray-100-text' => 600, - 'gray-200-text' => 700, - 'gray-300-text' => 700, - 'gray-400-text' => 950, - 'gray-500-text' => 0, - 'gray-600-text' => 200, - 'gray-700-text' => 300, - 'gray-800-text' => 400, - 'gray-900-text' => 500, - 'gray-950-text' => 500, ]; public const Indigo = [ @@ -608,29 +240,6 @@ class Color 800 => 'oklch(0.398 0.195 277.366)', 900 => 'oklch(0.359 0.144 278.697)', 950 => 'oklch(0.257 0.09 281.288)', - '50-text' => 950, - '100-text' => 950, - '200-text' => 950, - '300-text' => 950, - '400-text' => 950, - '500-text' => 0, - '600-text' => 0, - '700-text' => 0, - '800-text' => 0, - '900-text' => 0, - '950-text' => 0, - 'white-text' => 500, - 'gray-50-text' => 600, - 'gray-100-text' => 600, - 'gray-200-text' => 600, - 'gray-300-text' => 600, - 'gray-400-text' => 900, - 'gray-500-text' => 0, - 'gray-600-text' => 200, - 'gray-700-text' => 300, - 'gray-800-text' => 400, - 'gray-900-text' => 400, - 'gray-950-text' => 500, ]; public const Violet = [ @@ -645,29 +254,6 @@ class Color 800 => 'oklch(0.432 0.232 292.759)', 900 => 'oklch(0.38 0.189 293.745)', 950 => 'oklch(0.283 0.141 291.089)', - '50-text' => 950, - '100-text' => 950, - '200-text' => 950, - '300-text' => 950, - '400-text' => 950, - '500-text' => 0, - '600-text' => 0, - '700-text' => 0, - '800-text' => 0, - '900-text' => 0, - '950-text' => 0, - 'white-text' => 600, - 'gray-50-text' => 600, - 'gray-100-text' => 600, - 'gray-200-text' => 600, - 'gray-300-text' => 700, - 'gray-400-text' => 950, - 'gray-500-text' => 0, - 'gray-600-text' => 200, - 'gray-700-text' => 300, - 'gray-800-text' => 400, - 'gray-900-text' => 400, - 'gray-950-text' => 500, ]; public const Purple = [ @@ -682,29 +268,6 @@ class Color 800 => 'oklch(0.438 0.218 303.724)', 900 => 'oklch(0.381 0.176 304.987)', 950 => 'oklch(0.291 0.149 302.717)', - '50-text' => 950, - '100-text' => 950, - '200-text' => 950, - '300-text' => 950, - '400-text' => 950, - '500-text' => 0, - '600-text' => 0, - '700-text' => 0, - '800-text' => 0, - '900-text' => 0, - '950-text' => 0, - 'white-text' => 600, - 'gray-50-text' => 600, - 'gray-100-text' => 600, - 'gray-200-text' => 600, - 'gray-300-text' => 700, - 'gray-400-text' => 950, - 'gray-500-text' => 0, - 'gray-600-text' => 200, - 'gray-700-text' => 300, - 'gray-800-text' => 400, - 'gray-900-text' => 500, - 'gray-950-text' => 500, ]; public const Fuchsia = [ @@ -719,29 +282,6 @@ class Color 800 => 'oklch(0.452 0.211 324.591)', 900 => 'oklch(0.401 0.17 325.612)', 950 => 'oklch(0.293 0.136 325.661)', - '50-text' => 950, - '100-text' => 950, - '200-text' => 950, - '300-text' => 950, - '400-text' => 950, - '500-text' => 0, - '600-text' => 0, - '700-text' => 0, - '800-text' => 0, - '900-text' => 0, - '950-text' => 0, - 'white-text' => 600, - 'gray-50-text' => 700, - 'gray-100-text' => 700, - 'gray-200-text' => 700, - 'gray-300-text' => 800, - 'gray-400-text' => 950, - 'gray-500-text' => 0, - 'gray-600-text' => 200, - 'gray-700-text' => 300, - 'gray-800-text' => 400, - 'gray-900-text' => 500, - 'gray-950-text' => 600, ]; public const Pink = [ @@ -756,29 +296,6 @@ class Color 800 => 'oklch(0.459 0.187 3.815)', 900 => 'oklch(0.408 0.153 2.432)', 950 => 'oklch(0.284 0.109 3.907)', - '50-text' => 950, - '100-text' => 950, - '200-text' => 950, - '300-text' => 950, - '400-text' => 950, - '500-text' => 0, - '600-text' => 0, - '700-text' => 0, - '800-text' => 0, - '900-text' => 0, - '950-text' => 0, - 'white-text' => 600, - 'gray-50-text' => 700, - 'gray-100-text' => 700, - 'gray-200-text' => 700, - 'gray-300-text' => 800, - 'gray-400-text' => 950, - 'gray-500-text' => 0, - 'gray-600-text' => 200, - 'gray-700-text' => 300, - 'gray-800-text' => 400, - 'gray-900-text' => 500, - 'gray-950-text' => 600, ]; public const Rose = [ @@ -793,29 +310,6 @@ class Color 800 => 'oklch(0.455 0.188 13.697)', 900 => 'oklch(0.41 0.159 10.272)', 950 => 'oklch(0.271 0.105 12.094)', - '50-text' => 950, - '100-text' => 950, - '200-text' => 950, - '300-text' => 950, - '400-text' => 950, - '500-text' => 0, - '600-text' => 0, - '700-text' => 0, - '800-text' => 0, - '900-text' => 0, - '950-text' => 0, - 'white-text' => 600, - 'gray-50-text' => 700, - 'gray-100-text' => 700, - 'gray-200-text' => 700, - 'gray-300-text' => 800, - 'gray-400-text' => 950, - 'gray-500-text' => 0, - 'gray-600-text' => 200, - 'gray-700-text' => 300, - 'gray-800-text' => 400, - 'gray-900-text' => 500, - 'gray-950-text' => 600, ]; public static function convertToOklch(string $color): string @@ -1005,9 +499,10 @@ public static function findMatchingAccessibleTextColorsForBackgroundColors(array /** * @param array $palette + * @param array $grayPalette * @return array */ - public static function findMatchingAccessibleTextColorsForGrayBackgroundColors(array $palette): array + public static function findMatchingAccessibleTextColorsForGrayBackgroundColors(array $palette, array $grayPalette = self::Gray): array { ksort($palette); @@ -1016,15 +511,15 @@ public static function findMatchingAccessibleTextColorsForGrayBackgroundColors(a $possibleDarkTextColors = $palette; // Copy the array so we can remove elements from it $possibleLightTextColors = array_reverse($palette, preserve_keys: true); // Copy the array so we can remove elements from it - $grayColors = collect(static::Gray) + $grayPalette = collect($grayPalette) ->filter(fn ($value, $key): bool => is_numeric($key)) ->all(); - $grayColors[0] ??= 'oklch(1 0 0)'; + $grayPalette[0] ??= 'oklch(1 0 0)'; - ksort($grayColors); + ksort($grayPalette); - foreach ($grayColors as $grayShade => $grayColor) { - $grayShadeKey = $grayShade ? "gray-{$grayShade}-text" : 'white-text'; + foreach ($grayPalette as $grayShade => $grayColor) { + $grayShadeKey = ($grayShade !== 0) ? "gray-{$grayShade}-text" : 'white-text'; foreach ($possibleDarkTextColors as $possibleDarkTextColorShade => $possibleDarkTextColor) { if (static::isContrastRatioAccessible($grayColor, $possibleDarkTextColor)) { diff --git a/packages/support/src/Colors/ColorManager.php b/packages/support/src/Colors/ColorManager.php index bc63acae9e..254d918011 100644 --- a/packages/support/src/Colors/ColorManager.php +++ b/packages/support/src/Colors/ColorManager.php @@ -6,7 +6,6 @@ use Filament\Support\Concerns\EvaluatesClosures; use Filament\Support\View\Components\Contracts\HasColor; use Filament\Support\View\Components\Contracts\HasDefaultGrayColor; -use Illuminate\Support\Arr; class ColorManager { @@ -70,7 +69,7 @@ public function getColors(): array return $this->cachedColors; } - $this->cachedColors = static::DEFAULT_COLORS; + array_unshift($this->colors, static::DEFAULT_COLORS); foreach ($this->colors as $colors) { $colors = $this->evaluate($colors); @@ -85,34 +84,69 @@ public function getColors(): array ); } - $shades = collect($color) - ->keys() - ->filter(fn (int | string $shade): bool => is_numeric($shade)) - ->all(); + $colorShades = $this->filterColorForShadesOnly($color); - $colorOnlyShades = Arr::only($color, $shades); - - if (! array_key_exists((Arr::first($shades) . '-text'), $color)) { - $color = [ - ...Color::findMatchingAccessibleTextColorsForBackgroundColors($colorOnlyShades), - ...$color, - ]; + if (! array_key_exists((array_key_first($colorShades) . '-text'), $color)) { + $color = array_replace( + Color::findMatchingAccessibleTextColorsForBackgroundColors($colorShades), + $color, + ); } + $this->cachedColors[$name] = $color; + } + } + + if (array_key_exists('gray', $this->cachedColors)) { + $gray = $this->cachedColors['gray']; + + foreach ($this->cachedColors as $name => $color) { if (! array_key_exists('white-text', $color)) { - $color = [ - ...Color::findMatchingAccessibleTextColorsForGrayBackgroundColors($colorOnlyShades), - ...$color, - ]; + $this->cachedColors[$name] = array_replace( + Color::findMatchingAccessibleTextColorsForGrayBackgroundColors($this->filterColorForShadesOnly($color), $gray), + $color, + ); } - - $this->cachedColors[$name] = $color; } } return $this->cachedColors; } + /** + * @param array $color + * @return array + */ + public function generateTextLightnessIndex(array $color): array + { + $textLightnessIndex = []; + + foreach (array_keys($this->filterColorForShadesOnly($color)) as $shade) { + $textShade = $color["{$shade}-text"]; + + if ($textShade === 0) { // White + $textLightnessIndex[$shade] = true; + + continue; + } + + $textLightnessIndex[$shade] = Color::isLight($color[$textShade]); + } + + return $textLightnessIndex; + } + + /** + * @param array $color + * @return array + */ + protected function filterColorForShadesOnly(array $color): array + { + return collect($color) + ->filter(fn ($value, $key): bool => is_numeric($key)) + ->all(); + } + /** * @return ?array */ diff --git a/packages/support/src/Facades/FilamentColor.php b/packages/support/src/Facades/FilamentColor.php index 81df935270..56c5196b01 100644 --- a/packages/support/src/Facades/FilamentColor.php +++ b/packages/support/src/Facades/FilamentColor.php @@ -9,6 +9,7 @@ /** * @method static void addShades(string $alias, array $shades) + * @method static array generateTextLightnessIndex(array $color) * @method static array | null getAddedShades(string $alias) * @method static array> getColors() * @method static ?array getColor(string $color) diff --git a/packages/support/src/View/Components/Button.php b/packages/support/src/View/Components/Button.php index 757984fc63..c6fbc04df5 100644 --- a/packages/support/src/View/Components/Button.php +++ b/packages/support/src/View/Components/Button.php @@ -3,6 +3,7 @@ namespace Filament\Support\View\Components; use Filament\Support\Colors\Color; +use Filament\Support\Facades\FilamentColor; use Filament\Support\View\Components\Contracts\HasColor; use Filament\Support\View\Components\Contracts\HasDefaultGrayColor; @@ -28,7 +29,7 @@ public function getColorClasses(array $color): array ]; } - $textLightnessIndex = $this->generateTextLightnessIndexForColorShades($color); + $textLightnessIndex = FilamentColor::generateTextLightnessIndex($color); if (blank($bg)) { if ($textLightnessIndex[600] && $textLightnessIndex[500]) {