diff --git a/src/nova.php b/src/nova.php index f0c32ba..582e75c 100644 --- a/src/nova.php +++ b/src/nova.php @@ -11,7 +11,7 @@ function color(string $foreground, string $background): string { $palletes = ['light' => '255, 255, 255', 'dark' => '12, 74, 110']; - $background = Arr::get($palletes, $background, $background); + $background = $palletes[$background] ?? $background; $rgba = function ($color) { return tap( diff --git a/tests/Unit/ColorTest.php b/tests/Unit/ColorTest.php index aad8df1..573b675 100644 --- a/tests/Unit/ColorTest.php +++ b/tests/Unit/ColorTest.php @@ -20,16 +20,31 @@ public function colorDataProvider() yield ['24, 182, 155', 'light', '24, 182, 155']; yield ['24, 182, 155', 'dark', '24, 182, 155']; + yield ['24, 182, 155', '255, 255, 255', '24, 182, 155']; + yield ['24, 182, 155', '0, 0, 0', '24, 182, 155']; + yield ['24, 182, 155, 0.1', 'light', '232, 248, 245']; yield ['24, 182, 155, 0.1', 'dark', '13, 85, 115']; + yield ['24, 182, 155, 0.1', '255, 255, 255', '232, 248, 245']; + yield ['24, 182, 155, 0.1', '0, 0, 0', '2, 18, 16']; + yield ['24, 182, 155, 0.5', 'light', '140, 219, 205']; yield ['24, 182, 155, 0.5', 'dark', '18, 128, 133']; + yield ['24, 182, 155, 0.5', '255, 255, 255', '140, 219, 205']; + yield ['24, 182, 155, 0.5', '0, 0, 0', '12, 91, 78']; + yield ['24, 182, 155, 0.75', 'light', '82, 200, 180']; yield ['24, 182, 155, 0.75', 'dark', '21, 155, 144']; + yield ['24, 182, 155, 0.75', '255, 255, 255', '82, 200, 180']; + yield ['24, 182, 155, 0.75', '0, 0, 0', '18, 137, 116']; + yield ['24, 182, 155, 1.25', 'light', '24, 182, 155']; yield ['24, 182, 155, 1.25', 'dark', '24, 182, 155']; + + yield ['24, 182, 155, 1.25', '255, 255, 255', '24, 182, 155']; + yield ['24, 182, 155, 1.25', '0, 0, 0', '24, 182, 155']; } }