feat(theme): локальный выбор и показанная тема handoff (#13)
This commit is contained in:
1 parent
3740839321
commit
9c06977e03
11 files changed
+163
-49
No files matched your search
@@ -0,0 +1,16 @@
|
||||
<?php
|
||||
/** preland#13: только оформление; не меняет рекламный набор и не подключает Yii. */
|
||||
function prelandThemePreference(): ?array
|
||||
{
|
||||
$value = $_COOKIE['theme_choice'] ?? null;
|
||||
if (!is_string($value) || strlen($value) > 128
|
||||
|| !preg_match('/\Av1:(light|dark):(manual|preland):([A-Za-z0-9_-]{16,64})\z/', $value, $match)) {
|
||||
return null;
|
||||
}
|
||||
return ['theme' => $match[1], 'source' => $match[2], 'revision' => $match[3]];
|
||||
}
|
||||
|
||||
function prelandThemeResolve(string $fallback): string
|
||||
{
|
||||
return prelandThemePreference()['theme'] ?? $fallback;
|
||||
}
|
||||
Reference in new issue
Block a user