Skip to content

Commit

Permalink
fix data shape
Browse files Browse the repository at this point in the history
  • Loading branch information
miqayelsrapionyan committed Aug 28, 2023
1 parent 40b02e7 commit 9f13d7a
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 36 deletions.
37 changes: 18 additions & 19 deletions src/Strategies/BoxShadowStrategy.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,31 +23,30 @@ public function convert(array $variantStyle): string
}

$property = 'box-shadow:';
$value = $variantStyle['value'];

foreach ($variantStyle['value'] as $value) {
if (!$value['active']) {
return $property.' unset;';
}
if (!$value['active']) {
return $property.' unset;';
}

if (!empty($value['offset-x'])) {
$property .= ' '.$value['offset-x'];
}
if (!empty($value['offset-x'])) {
$property .= ' '.$value['offset-x'];
}

if (!empty($value['offset-y'])) {
$property .= ' '.$value['offset-y'];
}
if (!empty($value['offset-y'])) {
$property .= ' '.$value['offset-y'];
}

if (!empty($value['blur-radius'])) {
$property .= ' '.$value['blur-radius'];
}
if (!empty($value['blur-radius'])) {
$property .= ' '.$value['blur-radius'];
}

if (!empty($value['spread-radius'])) {
$property .= ' '.$value['spread-radius'];
}
if (!empty($value['spread-radius'])) {
$property .= ' '.$value['spread-radius'];
}

if (!empty($value['color'])) {
$property .= ' '.$value['color'];
}
if (!empty($value['color'])) {
$property .= ' '.$value['color'];
}

return $property.';';
Expand Down
29 changes: 12 additions & 17 deletions tests/Unit/Strategies/BoxShadowStrategyTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
namespace CssGenerator\Tests\Unit\Strategies;

use CssGenerator\Strategies\BoxShadowStrategy;
use CssGenerator\Strategies\FilterStrategy;
use PHPUnit\Framework\TestCase;

class BoxShadowStrategyTest extends TestCase
Expand All @@ -15,14 +14,12 @@ public function testConvert_WhenGivenBoxShadow_ReturnsBoxShadowString(): void
$styles = [
"type" => "box-shadow",
"value" => [
[
"offset-x" => "0px",
"offset-y" => "0px",
"blur-radius" => "0px",
"spread-radius" => "0px",
"color" => "rgba(0, 0, 0, 0.1)",
"active" => true
]
"offset-x" => "0px",
"offset-y" => "0px",
"blur-radius" => "0px",
"spread-radius" => "0px",
"color" => "rgba(0, 0, 0, 0.1)",
"active" => true
]
];

Expand All @@ -38,14 +35,12 @@ public function testConvert_WhenBoxShadowIsNotActive_ReturnsBoxShadowUnset(): vo
$styles = [
"type" => "box-shadow",
"value" => [
[
"offset-x" => "0px",
"offset-y" => "0px",
"blur-radius" => "0px",
"spread-radius" => "0px",
"color" => "rgba(0, 0, 0, 0.1)",
"active" => false
]
"offset-x" => "0px",
"offset-y" => "0px",
"blur-radius" => "0px",
"spread-radius" => "0px",
"color" => "rgba(0, 0, 0, 0.1)",
"active" => false
]
];

Expand Down

0 comments on commit 9f13d7a

Please sign in to comment.