-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into improve-sr-only-utilities
- Loading branch information
Showing
16 changed files
with
127 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
@include('kontour::forms.input', ['type' => $type ?? 'email', 'name' => $name ?? 'email', | ||
'controlAttributes' => array_merge( | ||
['autocomplete' => 'email', 'autocapitalize' => 'none', 'autocorrect' => 'off'], | ||
$controlAttributes ?? [] | ||
)]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,19 @@ | ||
@include('kontour::forms.partials.nameAttribute') | ||
|
||
id="{{ $controlId }}" | ||
@if($errors->hasAny($errorsKeys ?? $name)) | ||
aria-invalid="true" | ||
aria-describedby="{{ $errorsId }}" | ||
@elseif(isset($ariaDescribedById)) | ||
aria-describedby="{{ $ariaDescribedById }}" | ||
@endif | ||
@if(!empty($autofocusControlId) and $autofocusControlId == $controlId) | ||
autofocus | ||
@endif | ||
@if(!empty($placeholder)) | ||
placeholder="{{ $placeholder }}" | ||
@endif | ||
@if(isset($controlAttributes) and is_iterable($controlAttributes)) | ||
<?php | ||
$controlAttributes['id'] = $controlId; | ||
unset($controlAttributes['name']); | ||
if($errors->hasAny($errorsKeys ?? $name)) { | ||
$controlAttributes['aria-invalid'] = "true"; | ||
$controlAttributes['aria-describedby'] = array_merge([$errorsId], [$controlAttributes['aria-describedby'] ?? []]); | ||
} | ||
if(!empty($autofocusControlId) and $autofocusControlId == $controlId and !in_array('autofocus', $controlAttributes)) { | ||
$controlAttributes[] = 'autofocus'; | ||
} | ||
if(!empty($placeholder)) { | ||
$controlAttributes['placeholder'] = $placeholder; | ||
} | ||
?> | ||
@foreach($controlAttributes as $attributeName => $attributeValue) | ||
@include('kontour::partials.attribute') | ||
@endforeach | ||
@endif | ||
@endforeach |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
<?php | ||
|
||
namespace Kontenta\Kontour\Tests\Feature\FormViewTests; | ||
|
||
use Illuminate\Support\Facades\View; | ||
use Illuminate\Support\MessageBag; | ||
use Kontenta\Kontour\Tests\IntegrationTest; | ||
|
||
class EmailTest extends IntegrationTest | ||
{ | ||
public static $defaultEmailAttributes = [ | ||
'autocomplete' => 'email', | ||
'autocapitalize' => 'none', | ||
'autocorrect' => 'off', | ||
]; | ||
|
||
public function test_input_type_defaults_to_email() | ||
{ | ||
$output = View::make('kontour::forms.email', [ | ||
'errors' => new MessageBag, | ||
])->render(); | ||
|
||
$this->assertRegExp('/<input[\S\s]*type="email"[\S\s]*>/', $output); | ||
} | ||
|
||
public function test_input_type_can_be_specified() | ||
{ | ||
$output = View::make('kontour::forms.email', [ | ||
'errors' => new MessageBag, | ||
'type' => 'text', | ||
])->render(); | ||
|
||
$this->assertRegExp('/<input[\S\s]*type="text"[\S\s]*>/', $output); | ||
} | ||
|
||
public function test_input_name_defaults_to_email() | ||
{ | ||
$output = View::make('kontour::forms.email', [ | ||
'errors' => new MessageBag, | ||
])->render(); | ||
|
||
$this->assertRegExp('/<input[\S\s]*name="email"[\S\s]*>/', $output); | ||
} | ||
|
||
public function test_input_name_can_be_specified() | ||
{ | ||
$output = View::make('kontour::forms.email', [ | ||
'name' => 'test', | ||
'errors' => new MessageBag, | ||
])->render(); | ||
|
||
$this->assertRegExp('/<input[\S\s]*name="test"[\S\s]*>/', $output); | ||
} | ||
|
||
public function test_email_input_has_default_attributes() | ||
{ | ||
$output = View::make('kontour::forms.email', [ | ||
'errors' => new MessageBag, | ||
])->render(); | ||
|
||
foreach (self::$defaultEmailAttributes as $attribute => $default) { | ||
$this->assertStringContainsString("$attribute=\"$default\"", $output); | ||
} | ||
} | ||
|
||
public function test_control_attributes_can_be_set() | ||
{ | ||
$output = View::make('kontour::forms.email', [ | ||
'errors' => new MessageBag, | ||
'controlAttributes' => [ | ||
'autocomplete' => 'off', | ||
'autocapitalize' => 'on', | ||
'autocorrect' => 'on', | ||
'required', | ||
'a' => 'b', | ||
] | ||
])->render(); | ||
|
||
$this->assertRegExp('/\s+autocomplete="off"\W/', $output); | ||
$this->assertRegExp('/\s+autocapitalize="on"\W/', $output); | ||
$this->assertRegExp('/\s+autocorrect="on"\W/', $output); | ||
$this->assertRegExp('/\s+required\W/', $output); | ||
$this->assertRegExp('/\s+a="b"\W/', $output); | ||
|
||
foreach (self::$defaultEmailAttributes as $attribute => $default) { | ||
$this->assertStringNotContainsString("$attribute=\"$default\"", $output); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters