aboutsummaryrefslogtreecommitdiff
path: root/public/theme.php
blob: ad2441023b19e59423df684834b25f60db3d69b7 (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
<?php
require_once __DIR__ . '/../lib/bootstrap.php';
$themes = Theme::getActiveThemes();

header('Content-Type: text/css');

if (isset($themes['light'])) {
    echo ":root {" . PHP_EOL;
    $values = $themes['light']['values'] ?? [];
    foreach ($values as $name => $value) {
        if ($value !== '') {
            echo "    $name: $value;" . PHP_EOL;
        }
    }
    echo "}" . PHP_EOL;
}

foreach ($themes as $themeName => $themeData) {
    if ($themeName === 'high-contrast') {
        echo "@media (prefers-contrast: more) {" . PHP_EOL;
    } elseif (in_array($themeName, ['light', 'dark'])) {
        echo "@media (prefers-color-scheme: $themeName) {" . PHP_EOL;
    } else {
        continue;
    }

    echo "    :root {" . PHP_EOL;
    $values = $themeData['values'] ?? [];
    foreach ($values as $name => $value) {
        if ($value !== '') {
            echo "        $name: $value;" . PHP_EOL;
        }
    }

    echo "    }" . PHP_EOL;
    echo "}" . PHP_EOL;
}