diff --git a/resources/views/collapse.blade.php b/resources/views/collapse.blade.php index ea7d63e..f94b517 100644 --- a/resources/views/collapse.blade.php +++ b/resources/views/collapse.blade.php @@ -1,4 +1,10 @@
- {{ $title }} + + @isset($summary) + {{ $summary }} + @else + {{ $title }} + @endisset +
{{ $slot }}
diff --git a/resources/views/swap.blade.php b/resources/views/swap.blade.php index d7c0583..d4255dd 100644 --- a/resources/views/swap.blade.php +++ b/resources/views/swap.blade.php @@ -1,12 +1,14 @@ - + diff --git a/src/Components/Collapse.php b/src/Components/Collapse.php index 915d3d5..1970146 100644 --- a/src/Components/Collapse.php +++ b/src/Components/Collapse.php @@ -10,6 +10,8 @@ class Collapse extends DaisyComponent public function __construct( public string $title = '', + public string $summaryClass = '', + public string $contentClass = '', public bool $open = false, public bool $arrow = true, public bool $plus = false, @@ -18,8 +20,14 @@ public function __construct( protected function viewClasses(): array { return [ - 'title' => 'collapse-title', - 'content' => 'collapse-content', + 'title' => $this->classes([ + 'collapse-title', + $this->summaryClass => $this->summaryClass !== '', + ]), + 'content' => $this->classes([ + 'collapse-content', + $this->contentClass => $this->contentClass !== '', + ]), ]; } diff --git a/src/Components/Swap.php b/src/Components/Swap.php index 92caf7c..8bc167b 100644 --- a/src/Components/Swap.php +++ b/src/Components/Swap.php @@ -8,10 +8,13 @@ class Swap extends DaisyComponent { protected const VIEW = 'lazy::swap'; + public string $tag; + public function __construct( public bool $active = false, public bool $rotate = false, public bool $flip = false, + public bool $controlled = false, public string $name = '', public string $value = '1', public bool $checked = false, @@ -19,7 +22,9 @@ public function __construct( public mixed $onLabel = null, public mixed $offLabel = null, public mixed $indeterminateLabel = null, - ) {} + ) { + $this->tag = $this->controlled ? 'div' : 'label'; + } protected function viewClasses(): array { diff --git a/tests/Components/DaisyUiIntegrationTest.php b/tests/Components/DaisyUiIntegrationTest.php index 6b90a12..434645c 100644 --- a/tests/Components/DaisyUiIntegrationTest.php +++ b/tests/Components/DaisyUiIntegrationTest.php @@ -551,3 +551,26 @@ ->assertSee('Users') ->assertSee('42'); }); + +it('supports externally controlled swap state for Alpine or other state owners', function () { + $this + ->blade('OnOff') + ->assertSee('assertSee('swap-rotate') + ->assertSee('x-bind:class', false) + ->assertSee('swap-on') + ->assertSee('swap-off') + ->assertDontSee('type="checkbox"', false); +}); + +it('supports rich collapse summaries and content classes', function () { + $this + ->blade('Permissions12 totalBody') + ->assertSee('collapse-arrow') + ->assertSee('text-lg') + ->assertSee('font-semibold') + ->assertSee('space-y-5') + ->assertSee('Permissions') + ->assertSee('12 total') + ->assertSee('Body'); +});