summaryrefslogtreecommitdiff
path: root/lib/themes.php
diff options
context:
space:
mode:
authorEvgeny Zinoviev <me@ch1p.io>2024-01-31 06:11:00 +0300
committerEvgeny Zinoviev <me@ch1p.io>2024-01-31 20:45:40 +0300
commitc0dc531ebefd8912819f3b6c8bda1fed3c7e750c (patch)
tree2c75aa9df182260aef09faf4befd81a4c2b9c5e2 /lib/themes.php
parent48d688cdf7f9eae1bf11b8a6f0e5b98687c604cb (diff)
make it simple, but not simpler
Diffstat (limited to 'lib/themes.php')
-rw-r--r--lib/themes.php41
1 files changed, 41 insertions, 0 deletions
diff --git a/lib/themes.php b/lib/themes.php
new file mode 100644
index 0000000..f9b9857
--- /dev/null
+++ b/lib/themes.php
@@ -0,0 +1,41 @@
+<?php
+
+const THEMES = [
+ 'dark' => [
+ 'bg' => 0x222222,
+ // 'alpha' => 0x303132,
+ 'alpha' => 0x222222,
+ ],
+ 'light' => [
+ 'bg' => 0xffffff,
+ // 'alpha' => 0xf2f2f2,
+ 'alpha' => 0xffffff,
+ ]
+];
+
+
+function getThemes(): array {
+ return array_keys(THEMES);
+}
+
+function themeExists(string $name): bool {
+ return array_key_exists($name, THEMES);
+}
+
+function getThemeAlphaColorAsRGB(string $name): array {
+ $color = THEMES[$name]['alpha'];
+ $r = ($color >> 16) & 0xff;
+ $g = ($color >> 8) & 0xff;
+ $b = $color & 0xff;
+ return [$r, $g, $b];
+}
+
+function getUserTheme(): string {
+ if (isset($_COOKIE['theme'])) {
+ $val = $_COOKIE['theme'];
+ if (is_array($val))
+ $val = implode($val);
+ } else
+ $val = 'auto';
+ return $val;
+}