castopod/app/Views/Components/Forms/ColorRadioButton.php
Yassine Doghri 5c529a83aa feat(settings): add theme settings to set an accent color for all public pages
set 6 base accent colors: pine, lake, jacaranda, crimson, amber and onyx
2021-12-29 12:06:13 +00:00

36 lines
856 B
PHP

<?php
declare(strict_types=1);
namespace App\Views\Components\Forms;
class ColorRadioButton extends FormComponent
{
protected bool $isChecked = false;
public function setIsChecked(string $value): void
{
$this->isChecked = $value === 'true';
}
public function render(): string
{
$radioInput = form_radio(
[
'id' => $this->value,
'name' => $this->name,
'class' => 'color-radio-btn',
],
$this->value,
old($this->name) ? old($this->name) === $this->value : $this->isChecked,
);
return <<<HTML
<div class="{$this->class}">
{$radioInput}
<label for="{$this->value}" title="{$this->slot}" data-tooltip="bottom"></label>
</div>
HTML;
}
}