Skip to content

Commit

Permalink
lwb-16 Implement h3 sections component
Browse files Browse the repository at this point in the history
  • Loading branch information
t73biz committed Apr 5, 2024
1 parent 77b012b commit 558af69
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/h3.blade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<h3 {!! $globalAttributes !!}>
{{ $slot }}
</h3>
41 changes: 41 additions & 0 deletions src/Components/Sections/H3.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 H3
*/
class H3 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.h3',
[
'globalAttributes' => $this->getGlobalAttributes(),
'slot' => '',
]
);
}
}
119 changes: 119 additions & 0 deletions tests/Feature/Sections/H3Test.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\MyH3;

it('can render', function () {
Livewire::test(MyH3::class)
->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');
});
9 changes: 9 additions & 0 deletions tests/TestSupport/Components/Sections/MyH3.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\H3;

class MyH3 extends H3
{
}

0 comments on commit 558af69

Please sign in to comment.