Commit awal: prototipe UI SIAKAD Untan
This commit is contained in:
@@ -0,0 +1,47 @@
|
||||
{{-- Label + <textarea> + bantuan/galat, selaras dengan form.field. Atribut lain (required, maxlength, placeholder...) ke <textarea>. --}}
|
||||
@props([
|
||||
'name',
|
||||
'label',
|
||||
'value' => null,
|
||||
'rows' => 4,
|
||||
'hint' => null,
|
||||
'error' => null,
|
||||
'optional' => false,
|
||||
'id' => null,
|
||||
])
|
||||
|
||||
@php
|
||||
$key = trim(str_replace(['[', ']'], ['.', ''], $name), '.');
|
||||
$id ??= 'field-'.\Illuminate\Support\Str::slug($key, '-');
|
||||
$message = $error ?? (isset($errors) ? $errors->first($key) : null);
|
||||
$current = old($key, $value);
|
||||
$helpId = $id.'-help';
|
||||
@endphp
|
||||
|
||||
<div class="field">
|
||||
<label class="field__label" for="{{ $id }}">
|
||||
{{ $label }}
|
||||
@if ($optional) <span class="field__optional">(opsional)</span> @endif
|
||||
</label>
|
||||
|
||||
<div class="field__control">
|
||||
<textarea
|
||||
id="{{ $id }}"
|
||||
name="{{ $name }}"
|
||||
rows="{{ $rows }}"
|
||||
@if ($message) aria-invalid="true" @endif
|
||||
@if ($attributes->get('required')) aria-required="true" @endif
|
||||
aria-describedby="{{ $helpId }}"
|
||||
{{ $attributes->class(['field__input', 'field__textarea']) }}
|
||||
>{{ $current }}</textarea>
|
||||
</div>
|
||||
|
||||
<p id="{{ $helpId }}" @class(['field__help', 'field__help--error' => $message]) aria-live="polite" @if ($message) role="alert" @endif>
|
||||
@if ($message)
|
||||
<x-heroicon-s-exclamation-circle />
|
||||
<span>{{ $message }}</span>
|
||||
@elseif ($hint)
|
||||
<span>{{ $hint }}</span>
|
||||
@endif
|
||||
</p>
|
||||
</div>
|
||||
Reference in New Issue
Block a user