2021-09-10 16:02:25 +00: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-05 14:36:34 +00:00
|
|
|
$baseClass = 'w-full bg-elevated border-contrast rounded-lg focus:border-contrast border-3 focus:ring-accent focus-within:ring-accent ' . $this->class;
|
2021-09-10 16:02:25 +00:00
|
|
|
|
2021-10-22 13:11:33 +00:00
|
|
|
$this->attributes['class'] = $baseClass;
|
|
|
|
|
|
|
|
if ($this->type === 'file') {
|
2021-11-05 14:36:34 +00:00
|
|
|
$this->attributes['class'] .= ' file:px-3 file:py-2 file:h-[40px] file:font-semibold file:text-skin-muted file:text-sm file:rounded-none file:border-none file:bg-highlight file:cursor-pointer';
|
2021-10-22 13:11:33 +00:00
|
|
|
} else {
|
|
|
|
$this->attributes['class'] .= ' px-3 py-2';
|
|
|
|
}
|
2021-09-10 16:02:25 +00:00
|
|
|
|
2021-09-15 15:58:21 +00:00
|
|
|
return form_input($this->attributes, old($this->name, $this->value));
|
2021-09-10 16:02:25 +00:00
|
|
|
}
|
|
|
|
}
|