Skip to content

Commit

Permalink
lwb-14 Implement h1 sections component (#30)
Browse files Browse the repository at this point in the history
* lwb-10 Implement address sections component

* lwb-12 Implement footer sections component

* lwb-13 Implement header sections component

* lwb-14 Implement h1 sections component
  • Loading branch information
t73biz authored Apr 5, 2024
1 parent a37e4a9 commit 2a40822
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/h1.blade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<h1 {!! $globalAttributes !!}>
{{ $slot }}
</h1>
41 changes: 41 additions & 0 deletions src/Components/Sections/H1.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 H1
*/
class H1 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.h1',
[
'globalAttributes' => $this->getGlobalAttributes(),
'slot' => '',
]
);
}
}
119 changes: 119 additions & 0 deletions tests/Feature/Sections/H1Test.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\MyH1;

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

it('can render with translate', function () {
Livewire::test(MyH1::class, ['translate' => true])
->assertSee('translate');
});
9 changes: 9 additions & 0 deletions tests/TestSupport/Components/Sections/MyH1.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\H1;

class MyH1 extends H1
{
}

0 comments on commit 2a40822

Please sign in to comment.