From 558af69142556be88e391ee1109c8e14884e8d55 Mon Sep 17 00:00:00 2001 From: Ron Chaplin Date: Fri, 5 Apr 2024 12:20:02 -0500 Subject: [PATCH] lwb-16 Implement h3 sections component --- resources/views/sections/h3.blade.php | 3 + src/Components/Sections/H3.php | 41 ++++++ tests/Feature/Sections/H3Test.php | 119 ++++++++++++++++++ .../TestSupport/Components/Sections/MyH3.php | 9 ++ 4 files changed, 172 insertions(+) create mode 100644 resources/views/sections/h3.blade.php create mode 100644 src/Components/Sections/H3.php create mode 100644 tests/Feature/Sections/H3Test.php create mode 100644 tests/TestSupport/Components/Sections/MyH3.php diff --git a/resources/views/sections/h3.blade.php b/resources/views/sections/h3.blade.php new file mode 100644 index 00000000..a8c286d2 --- /dev/null +++ b/resources/views/sections/h3.blade.php @@ -0,0 +1,3 @@ +

+ {{ $slot }} +

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