1
0
Files
re_capitulating_queer/site/plugins/my-helper/index.php
Philip Wagner 78b6c0d381 init
2024-08-31 10:01:49 +02:00

33 lines
839 B
PHP

<?php
function colorToStr(string $color): string {
return match ($color) {
"#f1edeb", "" => "white",
"#ff00ff" => "pink",
"#48bd8d" => "green",
"#8200ff" => "lila",
"#ff6700" => "orange",
"#000000" => "black",
};
}
function bg(string $bgColor, string $gridColor): string {
if ($gridColor == "") $gridColor = "#8200ff";
$bg = 'bg-' . colorToStr($bgColor) . '-' . colorToStr($gridColor);
remember($bg);
return $bg;
}
function remember(string $value): string {
static $oldValue = "bg-white-lila";
$copy = $oldValue;
$oldValue = $value;
return $copy;
}
function randomBg(): string {
static $colors = ["#f1edeb", "#ff00ff", "#48bd8d", "#8200ff", "#ff6700"];
$a = array_rand($colors, 2);
return bg($colors[$a[0]], $colors[$a[1]]);
}