2021-09-10 18:02:25 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
declare(strict_types=1);
|
|
|
|
|
|
|
|
namespace App\Views\Components\Forms;
|
|
|
|
|
|
|
|
class Input extends FormComponent
|
|
|
|
{
|
|
|
|
protected string $type = 'text';
|
|
|
|
|
|
|
|
public function render(): string
|
|
|
|
{
|
2021-11-01 18:12:03 +01:00
|
|
|
$baseClass = 'w-full bg-white border-black rounded-lg focus:border-black border-3 focus:ring-castopod focus-within:ring-castopod ' . $this->class;
|
2021-09-10 18:02:25 +02:00
|
|
|
|
2021-10-22 15:11:33 +02:00
|
|
|
$this->attributes['class'] = $baseClass;
|
|
|
|
|
|
|
|
if ($this->type === 'file') {
|
|
|
|
$this->attributes['class'] .= ' file:px-3 file:py-2 file:h-[40px] file:font-semibold file:text-gray-800 file:text-sm file:rounded-none file:border-none file:bg-gray-200 file:hover:bg-gray-300 file:cursor-pointer';
|
|
|
|
} else {
|
|
|
|
$this->attributes['class'] .= ' px-3 py-2';
|
|
|
|
}
|
2021-09-10 18:02:25 +02:00
|
|
|
|
|
|
|
if ($this->required) {
|
2021-09-15 17:58:21 +02:00
|
|
|
$this->attributes['required'] = 'required';
|
2021-09-10 18:02:25 +02:00
|
|
|
}
|
|
|
|
|
2021-09-15 17:58:21 +02:00
|
|
|
return form_input($this->attributes, old($this->name, $this->value));
|
2021-09-10 18:02:25 +02:00
|
|
|
}
|
|
|
|
}
|