Этап 3: экраны чтения по макету
- API: GET /api/tree, GET /api/articles/:slug, раздача /uploads - экраны: Главная, Раздел, Статья, Шпаргалка, Избранное (телефон и компьютер) - блоки статьи, чек-листы с сохранением в localStorage (ключ slug + версия) - просмотр фото: щипок, двойной тап, свайп, клавиатура - липкая шапка с прогрессом, оглавление в bottom sheet, избранное, недавние - три темы (тёмная / светлая / солнце), выбор запоминается - печать и PDF: окно настроек, печатная версия статьи и шпаргалки с QR - дизайн-токены в tokens.css, шрифт Onest в сборке - scripts/check-layout.mjs: проверка отсутствия горизонтальной прокрутки - исправлены два невидимых символа, на которые ругался линтер Lighthouse mobile: Performance 95-96, Accessibility 100. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
be9be3f79e
commit
59be0307cc
@@ -0,0 +1,27 @@
|
||||
import { useEffect } from 'react';
|
||||
import { useStored } from './store';
|
||||
|
||||
export type Theme = 'dark' | 'light' | 'sun';
|
||||
// Порядок переключения кнопкой «Тема»: тёмная → светлая → солнце
|
||||
export const THEME_ORDER: Theme[] = ['dark', 'light', 'sun'];
|
||||
export const THEME_LABEL: Record<Theme, string> = { dark: 'Тёмная', light: 'Светлая', sun: 'Солнце' };
|
||||
export const THEME_KEY = 'kb-theme';
|
||||
|
||||
export function useTheme() {
|
||||
const [stored, setTheme] = useStored<Theme>(THEME_KEY, 'dark');
|
||||
const theme = THEME_ORDER.includes(stored) ? stored : 'dark';
|
||||
|
||||
useEffect(() => {
|
||||
document.documentElement.dataset.theme = theme;
|
||||
// Цвет системной панели браузера берём из токена фона
|
||||
const bg = getComputedStyle(document.documentElement).getPropertyValue('--bg').trim();
|
||||
document.querySelector('meta[name="theme-color"]')?.setAttribute('content', bg);
|
||||
}, [theme]);
|
||||
|
||||
return {
|
||||
theme,
|
||||
label: THEME_LABEL[theme],
|
||||
setTheme,
|
||||
cycle: () => setTheme(THEME_ORDER[(THEME_ORDER.indexOf(theme) + 1) % THEME_ORDER.length]!),
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user