Skip to content

Commit e64fc43

Browse files
committed
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.
1 parent 1f6fe24 commit e64fc43

File tree

4 files changed

+76
-1
lines changed

4 files changed

+76
-1
lines changed
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
@props([
2+
'label' => '',
3+
'help' => '',
4+
'hr' => ''
5+
])
6+
7+
@php
8+
$required = $attributes['required'] ?? null;
9+
if ($label) {
10+
$label .= ($required ? '<i class="text-error">*</i>' : '');
11+
}
12+
$model = $attributes->wire('model');
13+
$parameter = $model->value();
14+
$class = [];
15+
@endphp
16+
17+
18+
<div class="{{ $label ? 'form-control' : 'inline-block' }}">
19+
<label class="label cursor-pointer{{ $hr ? ' flex flex-col items-start' : '' }}">
20+
<span class="label-text{{ $hr ? ' mb-1' : '' }}">{!! $label !!}</span>
21+
<x-lazy-select :attributes="$attributes">
22+
{{ $slot }}
23+
</x-lazy-select>
24+
</label>
25+
@if ($help)
26+
<div class="tooltip w-6" data-tip="{{ $help }}">
27+
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24"
28+
class="stroke-info h-6 w-6 flex-shrink-0">
29+
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
30+
d="M13 16h-1v-4h-1m1-4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"></path>
31+
</svg>
32+
</div>
33+
@endif
34+
@if ($parameter)
35+
@error($parameter)
36+
<div class="alert alert-error mt-1 mb-2 shadow-lg">
37+
<div>
38+
<svg xmlns="http://www.w3.org/2000/svg" class="h-6 w-6 flex-shrink-0 stroke-current" fill="none"
39+
viewBox="0 0 24 24">
40+
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
41+
d="M10 14l2-2m0 0l2-2m-2 2l-2-2m2 2l2 2m7-2a9 9 0 11-18 0 9 9 0 0118 0z"></path>
42+
</svg>
43+
{{ $message }}
44+
</div>
45+
</div>
46+
@enderror
47+
@endif
48+
</div>

resources/views/textarea.blade.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22
'hasError' => false,
33
'value' => ''
44
])
5-
<textarea {{ $attributes->merge(['class' => 'textarea'.($hasError ? ' textarea-error' : '')]) }}>{{ $value ?: $slot }}</textarea>
5+
<textarea {{ $attributes->merge(['class' => 'w-full'.($hasError ? ' textarea-error' : '')]) }}>{{ $value ?: $slot }}</textarea>

src/Components/Form/FormSelect.php

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<?php
2+
3+
namespace Step2dev\LazyUI\Components\Form;
4+
5+
use Illuminate\Contracts\View\View;
6+
use Step2dev\LazyUI\LazyComponent;
7+
8+
class FormSelect extends LazyComponent
9+
{
10+
public ?string $placeholder;
11+
12+
public function __construct(public string $label = '', string $placeholder = '', public bool $required = false)
13+
{
14+
$this->placeholder = (string) str($placeholder ?: $this->label)->trim()->ucfirst();
15+
}
16+
17+
public function render(): \Closure|View
18+
{
19+
return function (array $data) {
20+
$data['attributes']['required'] = $this->required;
21+
22+
return view('lazy::form.select', $this->mergeData($data))->render();
23+
};
24+
}
25+
}

src/LazyUiServiceProvider.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
use Step2dev\LazyUI\Components\Form\FormImage;
2929
use Step2dev\LazyUI\Components\Form\FormInput;
3030
use Step2dev\LazyUI\Components\Form\FormRichtext;
31+
use Step2dev\LazyUI\Components\Form\FormSelect;
3132
use Step2dev\LazyUI\Components\Form\FormTextarea;
3233
use Step2dev\LazyUI\Components\Form\FormToggle;
3334
use Step2dev\LazyUI\Components\FormGroup;
@@ -97,6 +98,7 @@ public function configurePackage(Package $package): void
9798
FormImage::class,
9899
FormInput::class,
99100
FormRichtext::class,
101+
FormSelect::class,
100102
FormTextarea::class,
101103
FormToggle::class,
102104
Image::class,

0 commit comments

Comments
 (0)