castopod/app/Views/Components/Charts/ChartsComponent.php
Yassine Doghri 9da1d0a1b6 feat(plugins): add aside with plugin metadata next to plugin's readme
- enhance plugin card ui
- refactor components to be more consistent
- invert toggler label for better UX
- edit view components regex
2024-05-28 10:14:10 +00:00

37 lines
915 B
PHP

<?php
declare(strict_types=1);
namespace App\Views\Components\Charts;
use ViewComponents\Component;
class ChartsComponent extends Component
{
protected string $title;
protected string $subtitle = '';
protected string $dataUrl;
protected string $type;
public function render(): string
{
$subtitleBlock = '';
if ($this->subtitle !== '') {
$subtitleBlock = '<p class="px-6 -mt-4 text-sm text-skin-muted">' . $this->subtitle . '</p>';
}
$this->mergeClass('bg-elevated border-3 rounded-xl border-subtle');
return <<<HTML
<div {$this->getStringifiedAttributes()}>
<h2 class="px-6 py-4 text-xl">{$this->title}</h2>
{$subtitleBlock}
<div class="w-full h-[500px]" data-chart-type="{$this->type}" data-chart-url="{$this->dataUrl}"></div>
</div>
HTML;
}
}