adrema/app/View/Traits/HasColors.php

34 lines
695 B
PHP
Raw Normal View History

2024-10-17 00:25:58 +02:00
<?php
namespace App\View\Traits;
use App\View\Enums\Variant;
trait HasColors
{
public function bgColor(string $variant): string
{
$variant = Variant::fromString($variant);
return implode(' ', [
$variant->background(),
$variant->hoverBackground(),
]);
}
public function fgColor(string $variant): string
{
$variant = Variant::fromString($variant);
return implode(' ', [
$variant->foreground(),
$variant->hoverForeground(),
]);
}
public function allColors(string $variant): string
{
return "{$this->bgColor($variant)} {$this->fgColor($variant)}";
}
}