summaryrefslogtreecommitdiff
path: root/engine/themes.php
blob: 839377f3b36916c435a3648bbc361e948aa51dff (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
<?php

class themes {

    public static array $Themes = [
        'dark' => [
            'bg' => 0x222222,
            // 'alpha' => 0x303132,
            'alpha' => 0x222222,
        ],
        'light' => [
            'bg' => 0xffffff,
            // 'alpha' => 0xf2f2f2,
            'alpha' => 0xffffff,
        ]
    ];

    public static function getThemes(): array {
        return array_keys(self::$Themes);
    }

    public static function themeExists(string $name): bool {
        return array_key_exists($name, self::$Themes);
    }

    public static function getThemeAlphaColorAsRGB(string $name): array {
        $color = self::$Themes[$name]['alpha'];
        $r = ($color >> 16) & 0xff;
        $g = ($color >> 8) & 0xff;
        $b = $color & 0xff;
        return [$r, $g, $b];
    }

    public static function getUserTheme(): string {
        return ($_COOKIE['theme'] ?? 'auto');
    }

}