Skip to content

Commit

Permalink
lwb-18 Implement h5 sections component
Browse files Browse the repository at this point in the history
  • Loading branch information
t73biz committed Apr 5, 2024
1 parent 6e5f9cf commit d6567a6
Show file tree
Hide file tree
Showing 4 changed files with 172 additions and 0 deletions.
3 changes: 3 additions & 0 deletions resources/views/sections/h5.blade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<h5 {!! $globalAttributes !!}>
{{ $slot }}
</h5>
41 changes: 41 additions & 0 deletions src/Components/Sections/H5.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<?php

namespace T73biz\LwBits\Components\Sections;

use Illuminate\Contracts\Foundation\Application as ContractedApplication;
use Illuminate\Contracts\View\Factory;
use Illuminate\Contracts\View\View as ContractedView;
use Illuminate\Foundation\Application;
use Illuminate\View\View;
use Livewire\Component;
use T73biz\LwBits\Components\GlobalAttributesTrait;

/**
* Class H5
*/
class H5 extends Component
{
use GlobalAttributesTrait;

/**
* Standard mount function
*/
public function mount(): void
{
$this->setGlobalAttributes();
}

/**
* Standard render function
*/
public function render(): Application|ContractedApplication|ContractedView|Factory|View
{
return view(
'lw-bits::sections.h5',
[
'globalAttributes' => $this->getGlobalAttributes(),
'slot' => '',
]
);
}
}
119 changes: 119 additions & 0 deletions tests/Feature/Sections/H5Test.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
<?php

use Livewire\Livewire;
use T73biz\LwBits\Tests\TestSupport\Components\Sections\MyH5;

it('can render', function () {
Livewire::test(MyH5::class)
->assertStatus(200);
});

it('can render with accesskey', function () {
Livewire::test(MyH5::class, ['accessKey' => true])
->assertSee('accesskey');
});

it('can render with autocapitalize', function () {
Livewire::test(MyH5::class, ['autoCapitalize' => true])
->assertSee('autocapitalize');
});

it('can render with autofocus', function () {
Livewire::test(MyH5::class, ['autoFocus' => true])
->assertSee('autofocus');
});

it('can render with contenteditable', function () {
Livewire::test(MyH5::class, ['contentEditable' => true])
->assertSee('contenteditable');
});

it('can render with css classes', function () {
Livewire::test(MyH5::class, ['cssClasses' => ['class1', 'class2']])
->assertSee('class="class1 class2"', false);
});

it('can render with data-*', function () {
Livewire::test(MyH5::class, ['data' => ['name' => 'main-h5']])
->assertSee('data-name="main-h5"', false);
});

it('can render with dir', function () {
Livewire::test(MyH5::class, ['direction' => 'rtl'])
->assertSee('dir="rtl"', false);
});

it('can render with draggable', function () {
Livewire::test(MyH5::class, ['draggable' => true])
->assertSee('draggable');
});

it('can render with enterkeyhint', function () {
Livewire::test(MyH5::class, ['enterKeyHint' => 'enter'])
->assertSee('enterkeyhint="enter"', false);
});

it('can render with hidden', function () {
Livewire::test(MyH5::class, ['hidden' => true])
->assertSee('hidden');
});

it('can render with id', function () {
Livewire::test(MyH5::class, ['id' => 'main-h5'])
->assertSee('id="main-h5"', false);
});

it('can render with language', function () {
Livewire::test(MyH5::class, ['language' => 'en'])
->assertSee('lang="en"', false);
});

it('can render with nonce', function () {
Livewire::test(MyH5::class, ['nonce' => 'abc123'])
->assertSee('nonce="abc123"', false);
});

it('can render with parts', function () {
Livewire::test(MyH5::class, ['parts' => ['part1', 'part2']])
->assertSee('part="part1 part2"', false);
});

it('can render with popOver', function () {
Livewire::test(MyH5::class, ['popOver' => true])
->assertSee('popover');
});

it('can render with role', function () {
Livewire::test(MyH5::class, ['role' => 'main'])
->assertSee('role="main"', false);
});

it('can render with slot', function () {
Livewire::test(MyH5::class, ['slotAttribute' => 'main-h5'])
->assertSee('slot="main-h5"', false);
});

it('can render with spellcheck', function () {
Livewire::test(MyH5::class, ['spellCheck' => true])
->assertSee('spellcheck');
});

it('can render with styles', function () {
Livewire::test(MyH5::class, ['styles' => ['color' => 'red', 'font-size' => '16px']])
->assertSee('style="color:red;font-size:16px"', false);
});

it('can render with tabindex', function () {
Livewire::test(MyH5::class, ['tabIndex' => 1])
->assertSee('tabindex="1"', false);
});

it('can render with title', function () {
Livewire::test(MyH5::class, ['title' => 'main-h5'])
->assertSee('title="main-h5"', false);
});

it('can render with translate', function () {
Livewire::test(MyH5::class, ['translate' => true])
->assertSee('translate');
});
9 changes: 9 additions & 0 deletions tests/TestSupport/Components/Sections/MyH5.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?php

namespace T73biz\LwBits\Tests\TestSupport\Components\Sections;

use T73biz\LwBits\Components\Sections\H5;

class MyH5 extends H5
{
}

0 comments on commit d6567a6

Please sign in to comment.