diff --git a/app/View/Components/Card.php b/app/View/Components/Card.php new file mode 100644 index 0000000..48fa444 --- /dev/null +++ b/app/View/Components/Card.php @@ -0,0 +1,21 @@ + + @if(!empty($header)) +
+

{{ $header }}

+
+ @endif +
+ {{ $slot }} +
+ \ No newline at end of file diff --git a/resources/views/storybook/index.blade.php b/resources/views/storybook/index.blade.php index f1fdef6..0486b65 100644 --- a/resources/views/storybook/index.blade.php +++ b/resources/views/storybook/index.blade.php @@ -56,11 +56,16 @@

Cards

+

With Header

-
-

Card title

-

This is a simple card component.

-
+ +

This is a card component with header.

+
+ +

Without Header

+ +

This is a card component without header.

+
diff --git a/tests/Feature/Component/CardTest.php b/tests/Feature/Component/CardTest.php new file mode 100644 index 0000000..77a8d21 --- /dev/null +++ b/tests/Feature/Component/CardTest.php @@ -0,0 +1,34 @@ +blade('Card Content'); + + $view->assertSeeHtml('
Test Header'); + } + + public function testCardWithoutHeader(): void + { + $view = $this->blade('Card Content'); + + $view->assertDontSeeHtml('
'); + } + + public function testCardContent(): void + { + $cardContent = '

This is the card content.

'; + $view = $this->blade("{$cardContent}"); + + $view->assertSeeHtml($cardContent); + } +}