Skip to content

Commit f6003aa

Browse files
committed
[Twig] allow compound variant value to be string
1 parent 272d17e commit f6003aa

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

src/TwigComponent/src/CVA.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,10 @@ public function resolve(array $recipes): string
7777
break;
7878
}
7979

80+
if (!\is_array($compoundValues)) {
81+
$compoundValues = [$compoundValues];
82+
}
83+
8084
if (!\in_array($recipes[$compoundName], $compoundValues)) {
8185
$isCompound = false;
8286
break;

src/TwigComponent/tests/Unit/CVATest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ public static function recipeProvider(): iterable
221221
],
222222
'compounds' => [
223223
[
224-
'colors' => ['primary'],
224+
'colors' => 'primary',
225225
'sizes' => ['sm'],
226226
'class' => 'text-red-500',
227227
],
@@ -361,7 +361,7 @@ public static function recipeProvider(): iterable
361361
'compounds' => [
362362
[
363363
'colors' => ['danger', 'secondary'],
364-
'sizes' => ['sm'],
364+
'sizes' => 'sm',
365365
'class' => 'text-red-500',
366366
],
367367
],

0 commit comments

Comments
 (0)