From 3a4c1667f6d406be551d664ba918f5bf3c1ff1f1 Mon Sep 17 00:00:00 2001 From: Ronald Chaplin <169922+t73biz@users.noreply.github.com> Date: Fri, 5 Apr 2024 12:23:45 -0500 Subject: [PATCH] lwb-15 Implement h2 sections component (#31) * lwb-10 Implement address sections component * lwb-12 Implement footer sections component * lwb-13 Implement header sections component * lwb-14 Implement h1 sections component * lwb-15 Implement h2 sections component --- resources/views/sections/h2.blade.php | 3 + src/Components/Sections/H2.php | 41 ++++++ tests/Feature/Sections/H2Test.php | 119 ++++++++++++++++++ .../TestSupport/Components/Sections/MyH2.php | 9 ++ 4 files changed, 172 insertions(+) create mode 100644 resources/views/sections/h2.blade.php create mode 100644 src/Components/Sections/H2.php create mode 100644 tests/Feature/Sections/H2Test.php create mode 100644 tests/TestSupport/Components/Sections/MyH2.php diff --git a/resources/views/sections/h2.blade.php b/resources/views/sections/h2.blade.php new file mode 100644 index 00000000..b320f32c --- /dev/null +++ b/resources/views/sections/h2.blade.php @@ -0,0 +1,3 @@ +

+ {{ $slot }} +

diff --git a/src/Components/Sections/H2.php b/src/Components/Sections/H2.php new file mode 100644 index 00000000..7a7a506b --- /dev/null +++ b/src/Components/Sections/H2.php @@ -0,0 +1,41 @@ +setGlobalAttributes(); + } + + /** + * Standard render function + */ + public function render(): Application|ContractedApplication|ContractedView|Factory|View + { + return view( + 'lw-bits::sections.h2', + [ + 'globalAttributes' => $this->getGlobalAttributes(), + 'slot' => '', + ] + ); + } +} diff --git a/tests/Feature/Sections/H2Test.php b/tests/Feature/Sections/H2Test.php new file mode 100644 index 00000000..6ea82364 --- /dev/null +++ b/tests/Feature/Sections/H2Test.php @@ -0,0 +1,119 @@ +assertStatus(200); +}); + +it('can render with accesskey', function () { + Livewire::test(MyH2::class, ['accessKey' => true]) + ->assertSee('accesskey'); +}); + +it('can render with autocapitalize', function () { + Livewire::test(MyH2::class, ['autoCapitalize' => true]) + ->assertSee('autocapitalize'); +}); + +it('can render with autofocus', function () { + Livewire::test(MyH2::class, ['autoFocus' => true]) + ->assertSee('autofocus'); +}); + +it('can render with contenteditable', function () { + Livewire::test(MyH2::class, ['contentEditable' => true]) + ->assertSee('contenteditable'); +}); + +it('can render with css classes', function () { + Livewire::test(MyH2::class, ['cssClasses' => ['class1', 'class2']]) + ->assertSee('class="class1 class2"', false); +}); + +it('can render with data-*', function () { + Livewire::test(MyH2::class, ['data' => ['name' => 'main-h2']]) + ->assertSee('data-name="main-h2"', false); +}); + +it('can render with dir', function () { + Livewire::test(MyH2::class, ['direction' => 'rtl']) + ->assertSee('dir="rtl"', false); +}); + +it('can render with draggable', function () { + Livewire::test(MyH2::class, ['draggable' => true]) + ->assertSee('draggable'); +}); + +it('can render with enterkeyhint', function () { + Livewire::test(MyH2::class, ['enterKeyHint' => 'enter']) + ->assertSee('enterkeyhint="enter"', false); +}); + +it('can render with hidden', function () { + Livewire::test(MyH2::class, ['hidden' => true]) + ->assertSee('hidden'); +}); + +it('can render with id', function () { + Livewire::test(MyH2::class, ['id' => 'main-h2']) + ->assertSee('id="main-h2"', false); +}); + +it('can render with language', function () { + Livewire::test(MyH2::class, ['language' => 'en']) + ->assertSee('lang="en"', false); +}); + +it('can render with nonce', function () { + Livewire::test(MyH2::class, ['nonce' => 'abc123']) + ->assertSee('nonce="abc123"', false); +}); + +it('can render with parts', function () { + Livewire::test(MyH2::class, ['parts' => ['part1', 'part2']]) + ->assertSee('part="part1 part2"', false); +}); + +it('can render with popOver', function () { + Livewire::test(MyH2::class, ['popOver' => true]) + ->assertSee('popover'); +}); + +it('can render with role', function () { + Livewire::test(MyH2::class, ['role' => 'main']) + ->assertSee('role="main"', false); +}); + +it('can render with slot', function () { + Livewire::test(MyH2::class, ['slotAttribute' => 'main-h2']) + ->assertSee('slot="main-h2"', false); +}); + +it('can render with spellcheck', function () { + Livewire::test(MyH2::class, ['spellCheck' => true]) + ->assertSee('spellcheck'); +}); + +it('can render with styles', function () { + Livewire::test(MyH2::class, ['styles' => ['color' => 'red', 'font-size' => '16px']]) + ->assertSee('style="color:red;font-size:16px"', false); +}); + +it('can render with tabindex', function () { + Livewire::test(MyH2::class, ['tabIndex' => 1]) + ->assertSee('tabindex="1"', false); +}); + +it('can render with title', function () { + Livewire::test(MyH2::class, ['title' => 'main-h2']) + ->assertSee('title="main-h2"', false); +}); + +it('can render with translate', function () { + Livewire::test(MyH2::class, ['translate' => true]) + ->assertSee('translate'); +}); diff --git a/tests/TestSupport/Components/Sections/MyH2.php b/tests/TestSupport/Components/Sections/MyH2.php new file mode 100644 index 00000000..232173f3 --- /dev/null +++ b/tests/TestSupport/Components/Sections/MyH2.php @@ -0,0 +1,9 @@ +