generated from spatie/package-skeleton-laravel
-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update textarea, add FormSelect component
Enhanced the textarea's styles to take up the full width to improve alignment and user experience. Also, a new FormSelect component was added for better code reusability and standardization of select inputs. All changes have been tested.
- Loading branch information
1 parent
1f6fe24
commit e64fc43
Showing
4 changed files
with
76 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
@props([ | ||
'label' => '', | ||
'help' => '', | ||
'hr' => '' | ||
]) | ||
|
||
@php | ||
$required = $attributes['required'] ?? null; | ||
if ($label) { | ||
$label .= ($required ? '<i class="text-error">*</i>' : ''); | ||
} | ||
$model = $attributes->wire('model'); | ||
$parameter = $model->value(); | ||
$class = []; | ||
@endphp | ||
|
||
|
||
<div class="{{ $label ? 'form-control' : 'inline-block' }}"> | ||
<label class="label cursor-pointer{{ $hr ? ' flex flex-col items-start' : '' }}"> | ||
<span class="label-text{{ $hr ? ' mb-1' : '' }}">{!! $label !!}</span> | ||
<x-lazy-select :attributes="$attributes"> | ||
{{ $slot }} | ||
</x-lazy-select> | ||
</label> | ||
@if ($help) | ||
<div class="tooltip w-6" data-tip="{{ $help }}"> | ||
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" | ||
class="stroke-info h-6 w-6 flex-shrink-0"> | ||
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" | ||
d="M13 16h-1v-4h-1m1-4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"></path> | ||
</svg> | ||
</div> | ||
@endif | ||
@if ($parameter) | ||
@error($parameter) | ||
<div class="alert alert-error mt-1 mb-2 shadow-lg"> | ||
<div> | ||
<svg xmlns="http://www.w3.org/2000/svg" class="h-6 w-6 flex-shrink-0 stroke-current" fill="none" | ||
viewBox="0 0 24 24"> | ||
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" | ||
d="M10 14l2-2m0 0l2-2m-2 2l-2-2m2 2l2 2m7-2a9 9 0 11-18 0 9 9 0 0118 0z"></path> | ||
</svg> | ||
{{ $message }} | ||
</div> | ||
</div> | ||
@enderror | ||
@endif | ||
</div> |
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,25 @@ | ||
<?php | ||
|
||
namespace Step2dev\LazyUI\Components\Form; | ||
|
||
use Illuminate\Contracts\View\View; | ||
use Step2dev\LazyUI\LazyComponent; | ||
|
||
class FormSelect extends LazyComponent | ||
{ | ||
public ?string $placeholder; | ||
|
||
public function __construct(public string $label = '', string $placeholder = '', public bool $required = false) | ||
{ | ||
$this->placeholder = (string) str($placeholder ?: $this->label)->trim()->ucfirst(); | ||
} | ||
|
||
public function render(): \Closure|View | ||
{ | ||
return function (array $data) { | ||
$data['attributes']['required'] = $this->required; | ||
|
||
return view('lazy::form.select', $this->mergeData($data))->render(); | ||
}; | ||
} | ||
} |
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