- 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>
71 lines
2.4 KiB
TypeScript
71 lines
2.4 KiB
TypeScript
import { Link, useParams } from 'react-router-dom';
|
|
import { plural } from '@kb/shared';
|
|
import { Screen } from '../components/Shell';
|
|
import { BackLink, Notice, Plaque, Skeleton, ThemeButton } from '../components/ui';
|
|
import { num2 } from '../lib/format';
|
|
import { articleHref, useNav } from '../lib/tree';
|
|
|
|
export function SectionPage() {
|
|
const { slug } = useParams();
|
|
const nav = useNav();
|
|
const section = nav.sections.find((s) => s.slug === slug);
|
|
|
|
if (!section) {
|
|
return (
|
|
<Screen tab="home">
|
|
<div className="topline">
|
|
<BackLink to="/">Главная</BackLink>
|
|
<ThemeButton />
|
|
</div>
|
|
{nav.isLoading ? <Skeleton lines={5} /> : <Notice title="Раздел не найден">Возможно, его переименовали или удалили.</Notice>}
|
|
</Screen>
|
|
);
|
|
}
|
|
|
|
const photos = section.articles.reduce((n, a) => n + a.imageCount, 0);
|
|
|
|
return (
|
|
<Screen tab="home">
|
|
<div className="topline">
|
|
<BackLink to="/">Главная</BackLink>
|
|
<ThemeButton />
|
|
</div>
|
|
|
|
<div className="sec-head">
|
|
<Plaque code={section.code} color={section.color} size="lg" />
|
|
<div>
|
|
<h1 className="sec-title">{section.name}</h1>
|
|
<div className="sec-meta">
|
|
{section.articles.length} {plural(section.articles.length, ['статья', 'статьи', 'статей'])}
|
|
{photos ? ` · ${photos} фото` : ''}
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
{/* Сюда на этапе 5 встаёт строка «Сохранено для офлайна» */}
|
|
<div id="section-offline-slot" data-section={section.id} />
|
|
|
|
<div className="art-cards">
|
|
{section.articles.map((a, i) => (
|
|
<Link key={a.id} to={articleHref(a)} className="art-card">
|
|
<div className="art-card-head">
|
|
<span className="art-card-n">{num2(i + 1)}</span>
|
|
<span className="art-card-title">{nav.short(a)}</span>
|
|
</div>
|
|
{a.summary ? <div className="art-card-text">{a.summary}</div> : null}
|
|
{a.tags.length ? (
|
|
<div className="tags">
|
|
{a.tags.slice(0, 4).map((t) => (
|
|
<span key={t} className="tag">
|
|
{t}
|
|
</span>
|
|
))}
|
|
</div>
|
|
) : null}
|
|
</Link>
|
|
))}
|
|
</div>
|
|
</Screen>
|
|
);
|
|
}
|