Compare commits
1 Commits
1bc3e5f885
...
feature/se
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
38df2d4fc8 |
21
app/View/Components/Card.php
Normal file
21
app/View/Components/Card.php
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace App\View\Components;
|
||||||
|
|
||||||
|
use Illuminate\Contracts\View\View;
|
||||||
|
use Illuminate\View\Component;
|
||||||
|
|
||||||
|
class Card extends Component
|
||||||
|
{
|
||||||
|
public function __construct(public string $header = '')
|
||||||
|
{
|
||||||
|
//
|
||||||
|
}
|
||||||
|
|
||||||
|
public function render(): View
|
||||||
|
{
|
||||||
|
return view('components.card');
|
||||||
|
}
|
||||||
|
}
|
||||||
10
resources/views/components/card.blade.php
Normal file
10
resources/views/components/card.blade.php
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
<div class="card bg-surface rounded border border-primary shadow">
|
||||||
|
@if(!empty($header))
|
||||||
|
<div class="card-header p-4 border-b border-primary">
|
||||||
|
<h3 class="font-semibold">{{ $header }}</h3>
|
||||||
|
</div>
|
||||||
|
@endif
|
||||||
|
<div class="card-body p-4">
|
||||||
|
{{ $slot }}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
@@ -56,11 +56,16 @@
|
|||||||
<!-- CARDS -->
|
<!-- CARDS -->
|
||||||
<section class="space-y-4">
|
<section class="space-y-4">
|
||||||
<h2 class="text-xl font-semibold">Cards</h2>
|
<h2 class="text-xl font-semibold">Cards</h2>
|
||||||
|
<h3 class="text-l font-semibold">With Header</h3>
|
||||||
|
|
||||||
<div class="bg-surface p-6 rounded shadow">
|
<x-card header="Card Header">
|
||||||
<h3 class="font-semibold">Card title</h3>
|
<p class="text-text-muted">This is a card component with header.</p>
|
||||||
<p class="text-text-muted">This is a simple card component.</p>
|
</x-card>
|
||||||
</div>
|
|
||||||
|
<h3 class="text-l font-semibold">Without Header</h3>
|
||||||
|
<x-card>
|
||||||
|
<p class="text-text-muted">This is a card component without header.</p>
|
||||||
|
</x-card>
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
<!-- TYPOGRAPHY -->
|
<!-- TYPOGRAPHY -->
|
||||||
|
|||||||
34
tests/Feature/Component/CardTest.php
Normal file
34
tests/Feature/Component/CardTest.php
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace Tests\Feature\Component;
|
||||||
|
|
||||||
|
use Tests\TestCase;
|
||||||
|
|
||||||
|
class CardTest extends TestCase
|
||||||
|
{
|
||||||
|
public function testCardWithHeader(): void
|
||||||
|
{
|
||||||
|
$view = $this->blade('<x-card header="Test Header">Card Content</x-card>');
|
||||||
|
|
||||||
|
$view->assertSeeHtml('<div class="card-header ');
|
||||||
|
$view->assertSeeHtml('<h3 class="font-semibold">Test Header</h3>');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testCardWithoutHeader(): void
|
||||||
|
{
|
||||||
|
$view = $this->blade('<x-card>Card Content</x-card>');
|
||||||
|
|
||||||
|
$view->assertDontSeeHtml('<div class="card-header ');
|
||||||
|
$view->assertDontSeeHtml('<h3 class="font-semibold">');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testCardContent(): void
|
||||||
|
{
|
||||||
|
$cardContent = '<p class="card-content">This is the card content.</p>';
|
||||||
|
$view = $this->blade("<x-card>{$cardContent}</x-card>");
|
||||||
|
|
||||||
|
$view->assertSeeHtml($cardContent);
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user