Этап 5: офлайн (PWA)
- vite-plugin-pwa: манифест, иконки, app shell в precache, автообновление - статьи и картинки кешируются при открытии (stale-while-revalidate) - «Скачать раздел для офлайна» с прогрессом, экран «Офлайн-разделы» - баннер «Нет сети: показана сохранённая версия от …», метка «Офлайн» у статьи - scripts/check-offline.mjs: проверка в режиме без сети Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
f2be0df17a
commit
79d49181a6
@@ -7,6 +7,7 @@ import { ArticlePage } from './pages/Article';
|
||||
import { CheatSheetPage } from './pages/CheatSheet';
|
||||
import { FavoritesPage } from './pages/Favorites';
|
||||
import { HomePage } from './pages/Home';
|
||||
import { OfflinePage } from './pages/OfflinePage';
|
||||
import { SearchPage } from './pages/Search';
|
||||
import { SectionPage } from './pages/Section';
|
||||
|
||||
@@ -37,6 +38,7 @@ export function App() {
|
||||
<Route path="/favorites" element={<FavoritesPage />} />
|
||||
<Route path="/s/:slug" element={<SectionPage />} />
|
||||
<Route path="/a/:slug" element={<ArticlePage />} />
|
||||
<Route path="/offline" element={<OfflinePage />} />
|
||||
<Route path="/print/:slug" element={<PrintPage />} />
|
||||
<Route path="*" element={<NotFound />} />
|
||||
</Routes>
|
||||
|
||||
@@ -0,0 +1,114 @@
|
||||
import { useState } from 'react';
|
||||
import { formatBytes, formatDateTime } from '../lib/format';
|
||||
import { downloadSection, useLastSynced, useOnline, useSectionOffline } from '../lib/offline';
|
||||
import type { SectionView } from '../lib/tree';
|
||||
import { CodeTag } from './ui';
|
||||
|
||||
/** Жёлтая полоса сверху, когда сети нет. */
|
||||
export function OfflineBanner() {
|
||||
const online = useOnline();
|
||||
const synced = useLastSynced();
|
||||
if (online) return null;
|
||||
return (
|
||||
<div className="offline-banner" role="status">
|
||||
<span className="warn-tri" aria-hidden="true" />
|
||||
<span>
|
||||
<span className="offline-banner-title">Нет сети: показана сохранённая версия</span>
|
||||
<span className="offline-banner-text">
|
||||
{synced ? `от ${formatDateTime(synced)} · ` : ''}обновится при подключении
|
||||
</span>
|
||||
</span>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
/** Зелёная метка «Офлайн» у статьи, которая есть в кеше. */
|
||||
export function OfflinePill({ long }: { long?: boolean }) {
|
||||
return (
|
||||
<span className="pill-offline">
|
||||
<span className="dot dot--sm" aria-hidden="true" />
|
||||
{long ? 'Доступно офлайн' : 'Офлайн'}
|
||||
</span>
|
||||
);
|
||||
}
|
||||
|
||||
function useDownload(section: SectionView) {
|
||||
const [failed, setFailed] = useState(false);
|
||||
const start = async () => {
|
||||
setFailed(false);
|
||||
setFailed(!(await downloadSection(section)));
|
||||
};
|
||||
return { failed, start };
|
||||
}
|
||||
|
||||
/** Строка на экране раздела: «Сохранено для офлайна · 14 МБ · Обновить». */
|
||||
export function SectionOfflineRow({ section }: { section: SectionView }) {
|
||||
const state = useSectionOffline(section.id);
|
||||
const { failed, start } = useDownload(section);
|
||||
|
||||
if (state.kind === 'done') {
|
||||
return (
|
||||
<div className="offline-row offline-row--done">
|
||||
<span className="dot" aria-hidden="true" />
|
||||
<span className="offline-row-text">Сохранено для офлайна · {formatBytes(state.bytes)}</span>
|
||||
<button type="button" className="offline-row-btn" onClick={start}>
|
||||
Обновить
|
||||
</button>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
if (state.kind === 'loading') {
|
||||
return (
|
||||
<div className="offline-row" role="status">
|
||||
<span className="offline-row-text">
|
||||
Загрузка {state.pct}%
|
||||
<span className="progress">
|
||||
<span style={{ width: `${state.pct}%` }} />
|
||||
</span>
|
||||
</span>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
return (
|
||||
<button type="button" className="btn btn--outline btn--lg btn--block" onClick={start}>
|
||||
{failed ? 'Не скачалось: нет сети. Повторить' : 'Скачать раздел для офлайна'}
|
||||
</button>
|
||||
);
|
||||
}
|
||||
|
||||
/** Карточка раздела на экране «Офлайн-разделы». */
|
||||
export function SectionOfflineCard({ section }: { section: SectionView }) {
|
||||
const state = useSectionOffline(section.id);
|
||||
const { failed, start } = useDownload(section);
|
||||
const bytes = section.articles.reduce((n, a) => n + a.bytes, 0);
|
||||
|
||||
return (
|
||||
<div className="off-card">
|
||||
<div className="off-card-head">
|
||||
<CodeTag code={section.code} />
|
||||
<span className="off-card-name">{section.name}</span>
|
||||
<span className="off-card-size">{formatBytes(state.kind === 'done' ? state.bytes : bytes)}</span>
|
||||
</div>
|
||||
{state.kind === 'done' ? (
|
||||
<div className="off-card-done">
|
||||
<span className="dot" aria-hidden="true" />
|
||||
<span className="offline-row-text">Сохранено · {formatDateTime(state.at)}</span>
|
||||
<button type="button" className="offline-row-btn" onClick={start}>
|
||||
Обновить
|
||||
</button>
|
||||
</div>
|
||||
) : state.kind === 'loading' ? (
|
||||
<div className="off-card-loading" role="status">
|
||||
<span className="progress progress--lg">
|
||||
<span style={{ width: `${state.pct}%` }} />
|
||||
</span>
|
||||
<span className="off-card-pct">Загрузка {state.pct}%</span>
|
||||
</div>
|
||||
) : (
|
||||
<button type="button" className="btn btn--outline btn--block off-card-btn" onClick={start}>
|
||||
{failed ? 'Не скачалось: нет сети. Повторить' : 'Скачать раздел для офлайна'}
|
||||
</button>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -4,6 +4,7 @@ import { Link, NavLink, useLocation } from 'react-router-dom';
|
||||
import { THEME_LABEL, THEME_ORDER, useTheme } from '../lib/theme';
|
||||
import { articleHref, useNav } from '../lib/tree';
|
||||
import { IconDoc, IconHome, IconSearch, IconStar } from './Icons';
|
||||
import { OfflineBanner } from './Offline';
|
||||
import { CodeTag } from './ui';
|
||||
|
||||
export type Tab = 'home' | 'search' | 'cheat' | 'fav';
|
||||
@@ -67,6 +68,9 @@ export function Sidebar({ footer }: { footer?: ReactNode }) {
|
||||
<NavLink to="/favorites" className="tree-link tree-link--top">
|
||||
Избранное
|
||||
</NavLink>
|
||||
<NavLink to="/offline" className="tree-link tree-link--top">
|
||||
Офлайн-разделы
|
||||
</NavLink>
|
||||
{nav.sections.map((s) => (
|
||||
<div key={s.id} className="tree-group">
|
||||
<Link to={`/s/${s.slug}`} className="tree-head">
|
||||
@@ -127,6 +131,7 @@ export function Screen({
|
||||
<div className="shell">
|
||||
<Sidebar />
|
||||
<div className="shell-main">
|
||||
<OfflineBanner />
|
||||
<main className={wide ? 'screen screen--wide' : 'screen'}>{children}</main>
|
||||
</div>
|
||||
{bar ?? (tab ? <TabBar active={tab} /> : null)}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { useQuery } from '@tanstack/react-query';
|
||||
import type { ArticleDto, TreeResponse } from '@kb/shared';
|
||||
import { markSynced } from './offline';
|
||||
|
||||
/** Ошибка ответа API: status нужен, чтобы отличать 401 (надо войти) от 404 и от «нет сети». */
|
||||
export class ApiError extends Error {
|
||||
@@ -37,7 +38,14 @@ export async function api<T>(path: string, init?: RequestInit & { json?: unknown
|
||||
return data as T;
|
||||
}
|
||||
|
||||
export const treeQuery = { queryKey: ['tree'] as const, queryFn: () => api<TreeResponse>('/tree') };
|
||||
export const treeQuery = {
|
||||
queryKey: ['tree'] as const,
|
||||
queryFn: async () => {
|
||||
const tree = await api<TreeResponse>('/tree');
|
||||
markSynced();
|
||||
return tree;
|
||||
},
|
||||
};
|
||||
|
||||
export const articleQuery = (slug: string) => ({
|
||||
queryKey: ['article', slug] as const,
|
||||
|
||||
@@ -0,0 +1,159 @@
|
||||
// Офлайн: скачивание разделов в кеш браузера, статус сети, проверка «статья сохранена».
|
||||
//
|
||||
// Кеши ведёт service worker (см. vite.config.ts): всё, что открывалось, он складывает сам.
|
||||
// «Скачать раздел» делает то же самое заранее: кладёт ответы API и картинки в те же кеши.
|
||||
|
||||
import { useEffect, useState, useSyncExternalStore } from 'react';
|
||||
import type { ArticleDto } from '@kb/shared';
|
||||
import { getStored, setStored, useStored } from './store';
|
||||
import type { SectionView } from './tree';
|
||||
|
||||
// Имена кешей должны совпадать с runtimeCaching в vite.config.ts
|
||||
export const API_CACHE = 'kb-api';
|
||||
export const IMG_CACHE = 'kb-img';
|
||||
|
||||
const SAVED = 'kb-offline';
|
||||
const SYNCED = 'kb-synced';
|
||||
|
||||
export interface SavedSection {
|
||||
/** Когда скачали. */
|
||||
at: number;
|
||||
bytes: number;
|
||||
}
|
||||
type SavedMap = Record<string, SavedSection>;
|
||||
const NONE: SavedMap = {};
|
||||
|
||||
export const cacheSupported = () => typeof caches !== 'undefined';
|
||||
|
||||
// ---------- Статус сети ----------
|
||||
function subscribeOnline(cb: () => void) {
|
||||
window.addEventListener('online', cb);
|
||||
window.addEventListener('offline', cb);
|
||||
return () => {
|
||||
window.removeEventListener('online', cb);
|
||||
window.removeEventListener('offline', cb);
|
||||
};
|
||||
}
|
||||
export function useOnline(): boolean {
|
||||
return useSyncExternalStore(subscribeOnline, () => navigator.onLine);
|
||||
}
|
||||
|
||||
/** Запомнить момент последней успешной загрузки данных с сервера (для баннера «версия от …»). */
|
||||
export function markSynced() {
|
||||
if (navigator.onLine) setStored(SYNCED, Date.now());
|
||||
}
|
||||
export function useLastSynced(): number | null {
|
||||
return useStored<number | null>(SYNCED, null)[0];
|
||||
}
|
||||
|
||||
// ---------- Ход скачивания (живёт в памяти, общий для всех экранов) ----------
|
||||
type Progress = Record<string, number>; // sectionId → проценты
|
||||
let progress: Progress = {};
|
||||
const listeners = new Set<() => void>();
|
||||
function setProgress(id: string, pct: number | null) {
|
||||
const next = { ...progress };
|
||||
if (pct === null) delete next[id];
|
||||
else next[id] = pct;
|
||||
progress = next;
|
||||
listeners.forEach((l) => l());
|
||||
}
|
||||
function subscribeProgress(l: () => void) {
|
||||
listeners.add(l);
|
||||
return () => listeners.delete(l);
|
||||
}
|
||||
|
||||
export type OfflineState =
|
||||
| { kind: 'idle' }
|
||||
| { kind: 'loading'; pct: number }
|
||||
| { kind: 'done'; at: number; bytes: number };
|
||||
|
||||
export function useSectionOffline(sectionId: string): OfflineState {
|
||||
const [saved] = useStored<SavedMap>(SAVED, NONE);
|
||||
const p = useSyncExternalStore(subscribeProgress, () => progress)[sectionId];
|
||||
if (p !== undefined) return { kind: 'loading', pct: p };
|
||||
const s = saved[sectionId];
|
||||
return s ? { kind: 'done', ...s } : { kind: 'idle' };
|
||||
}
|
||||
|
||||
async function fetchInto(cacheName: string, url: string): Promise<number> {
|
||||
const res = await fetch(url, { credentials: 'same-origin', headers: { 'X-Requested-With': 'kb' } });
|
||||
if (!res.ok) throw new Error(`${url}: ${res.status}`);
|
||||
const cache = await caches.open(cacheName);
|
||||
const copy = res.clone();
|
||||
await cache.put(url, res);
|
||||
return (await copy.blob()).size;
|
||||
}
|
||||
|
||||
/**
|
||||
* Скачивает раздел: тексты статей и все их картинки (превью и полный размер).
|
||||
* Возвращает false, если что-то не скачалось (нет сети).
|
||||
*/
|
||||
export async function downloadSection(section: SectionView): Promise<boolean> {
|
||||
if (!cacheSupported() || progress[section.id] !== undefined) return false;
|
||||
setProgress(section.id, 0);
|
||||
let bytes = 0;
|
||||
try {
|
||||
// Сначала статьи: из них узнаём список картинок
|
||||
const images: string[] = [];
|
||||
const cache = await caches.open(API_CACHE);
|
||||
for (const a of section.articles) {
|
||||
const url = `/api/articles/${encodeURIComponent(a.slug)}`;
|
||||
const res = await fetch(url, { credentials: 'same-origin', headers: { 'X-Requested-With': 'kb' } });
|
||||
if (!res.ok) throw new Error(`${url}: ${res.status}`);
|
||||
const copy = res.clone();
|
||||
await cache.put(url, res);
|
||||
const art = (await copy.json()) as ArticleDto;
|
||||
bytes += JSON.stringify(art).length;
|
||||
images.push(...art.images.filter((u) => u.startsWith('/uploads/')));
|
||||
}
|
||||
|
||||
const unique = [...new Set(images)];
|
||||
let done = 0;
|
||||
// По 4 картинки одновременно: быстрее, чем по одной, и не забивает слабую сеть
|
||||
const queue = [...unique];
|
||||
const worker = async () => {
|
||||
for (let url = queue.shift(); url; url = queue.shift()) {
|
||||
bytes += await fetchInto(IMG_CACHE, url);
|
||||
done++;
|
||||
setProgress(section.id, Math.round((done / unique.length) * 100));
|
||||
}
|
||||
};
|
||||
await Promise.all(Array.from({ length: 4 }, worker));
|
||||
|
||||
setStored<SavedMap>(SAVED, { ...getStored<SavedMap>(SAVED, NONE), [section.id]: { at: Date.now(), bytes } });
|
||||
return true;
|
||||
} catch {
|
||||
return false;
|
||||
} finally {
|
||||
setProgress(section.id, null);
|
||||
}
|
||||
}
|
||||
|
||||
/** Есть ли статья в кеше (открывалась раньше или скачана с разделом). */
|
||||
export function useIsCached(slug: string | undefined): boolean {
|
||||
const [cached, setCached] = useState(false);
|
||||
useEffect(() => {
|
||||
let alive = true;
|
||||
if (!slug || !cacheSupported()) return;
|
||||
// Проверяем чуть позже загрузки: service worker кладёт ответ в кеш после того, как отдал его странице
|
||||
const id = setTimeout(() => {
|
||||
void caches
|
||||
.open(API_CACHE)
|
||||
.then((c) => c.match(`/api/articles/${encodeURIComponent(slug)}`))
|
||||
.then((hit) => alive && setCached(!!hit))
|
||||
.catch(() => undefined);
|
||||
}, 1200);
|
||||
return () => {
|
||||
alive = false;
|
||||
clearTimeout(id);
|
||||
};
|
||||
}, [slug]);
|
||||
return cached;
|
||||
}
|
||||
|
||||
/** Стереть сохранённые ответы API (при выходе из аккаунта: чужие данные не должны остаться на устройстве). */
|
||||
export async function clearPrivateCaches() {
|
||||
setStored<SavedMap>(SAVED, {});
|
||||
if (!cacheSupported()) return;
|
||||
await Promise.all([caches.delete(API_CACHE), caches.delete(IMG_CACHE)]).catch(() => undefined);
|
||||
}
|
||||
@@ -7,6 +7,7 @@ import '@fontsource-variable/onest/wght.css';
|
||||
import './styles/tokens.css';
|
||||
import './styles/app.css';
|
||||
import './styles/article.css';
|
||||
import { registerSW } from 'virtual:pwa-register';
|
||||
import { App } from './App';
|
||||
import { ApiError } from './lib/api';
|
||||
|
||||
@@ -24,6 +25,9 @@ const queryClient = new QueryClient({
|
||||
},
|
||||
});
|
||||
|
||||
// Service worker: кеширует интерфейс и открытые статьи, сам обновляется при выходе новой версии
|
||||
registerSW({ immediate: true });
|
||||
|
||||
createRoot(document.getElementById('root')!).render(
|
||||
<StrictMode>
|
||||
<QueryClientProvider client={queryClient}>
|
||||
|
||||
@@ -3,6 +3,8 @@ import { Link, Navigate, useParams } from 'react-router-dom';
|
||||
import { ArticleBody, type Figure } from '../components/ArticleBody';
|
||||
import { IconList, IconPrint, IconStar, IconTheme, IconUp } from '../components/Icons';
|
||||
import { Lightbox } from '../components/Lightbox';
|
||||
import { OfflinePill } from '../components/Offline';
|
||||
import { useIsCached } from '../lib/offline';
|
||||
import { PrintSheet } from '../components/PrintSheet';
|
||||
import { Screen } from '../components/Shell';
|
||||
import { BackLink, Notice, Sheet, Skeleton } from '../components/ui';
|
||||
@@ -51,6 +53,7 @@ function ArticleView({ slug }: { slug: string }) {
|
||||
const fav = useFavorites();
|
||||
const theme = useTheme();
|
||||
const { scrolled, progress } = useReadProgress();
|
||||
const cached = useIsCached(art?.slug);
|
||||
const [tocOpen, setTocOpen] = useState(false);
|
||||
const [printOpen, setPrintOpen] = useState(false);
|
||||
const [lightbox, setLightbox] = useState<{ figures: Figure[]; start: number } | null>(null);
|
||||
@@ -184,7 +187,7 @@ function ArticleView({ slug }: { slug: string }) {
|
||||
{nav.space?.name} / {section ? <Link to={`/s/${section.slug}`}>{section.name}</Link> : null} /{' '}
|
||||
<strong>{nav.short(art)}</strong>
|
||||
</div>
|
||||
<span id="article-offline-slot-desk" />
|
||||
{cached ? <OfflinePill long /> : null}
|
||||
<button type="button" className="btn btn--ghost" onClick={() => fav.toggle(slug)} aria-pressed={isFav}>
|
||||
{isFav ? '★ В избранном' : '☆ В избранное'}
|
||||
</button>
|
||||
@@ -192,14 +195,13 @@ function ArticleView({ slug }: { slug: string }) {
|
||||
<IconPrint size={20} />
|
||||
Печать / PDF
|
||||
</button>
|
||||
<span id="article-edit-slot" />
|
||||
</div>
|
||||
|
||||
<div className="art-layout">
|
||||
<article className="art">
|
||||
<div className="topline art-topline">
|
||||
<BackLink to={backTo}>{section?.name ?? 'Главная'}</BackLink>
|
||||
<span id="article-offline-slot" />
|
||||
{cached ? <OfflinePill /> : null}
|
||||
</div>
|
||||
<div className="art-over">{section?.name}</div>
|
||||
<h1 className="art-title">{art.title}</h1>
|
||||
|
||||
@@ -180,6 +180,19 @@ export function HomePage() {
|
||||
</div>
|
||||
</section>
|
||||
) : null}
|
||||
|
||||
{/* В макете этих ссылок нет: без них с телефона не попасть на экран офлайн-разделов */}
|
||||
<nav className="list home-more" aria-label="Ещё">
|
||||
<Link to="/offline" className="list-row">
|
||||
<span className="list-row-main">
|
||||
<span className="list-row-title">Офлайн-разделы</span>
|
||||
<span className="list-row-sub">Скачать заранее, если на объекте нет связи</span>
|
||||
</span>
|
||||
<span className="list-row-chev" aria-hidden="true">
|
||||
›
|
||||
</span>
|
||||
</Link>
|
||||
</nav>
|
||||
</Screen>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
import { SectionOfflineCard } from '../components/Offline';
|
||||
import { Screen } from '../components/Shell';
|
||||
import { BackLink, Notice, ThemeButton } from '../components/ui';
|
||||
import { cacheSupported } from '../lib/offline';
|
||||
import { useNav } from '../lib/tree';
|
||||
|
||||
export function OfflinePage() {
|
||||
const nav = useNav();
|
||||
return (
|
||||
<Screen tab="home">
|
||||
<div className="topline">
|
||||
<BackLink to="/">Главная</BackLink>
|
||||
<ThemeButton />
|
||||
</div>
|
||||
<h1 className="off-title">Офлайн-разделы</h1>
|
||||
<p className="cheat-intro">Скачайте разделы заранее: в подвалах и паркингах связи часто нет.</p>
|
||||
{!cacheSupported() ? (
|
||||
<Notice title="Браузер не поддерживает офлайн">
|
||||
Откройте сайт по https в обычной вкладке Chrome или Safari.
|
||||
</Notice>
|
||||
) : (
|
||||
nav.sections.map((s) => <SectionOfflineCard key={s.id} section={s} />)
|
||||
)}
|
||||
<p className="off-note">
|
||||
Главная, шпаргалка и статьи, которые вы уже открывали, сохраняются сами. Исходные PDF офлайн недоступны.
|
||||
</p>
|
||||
</Screen>
|
||||
);
|
||||
}
|
||||
@@ -1,6 +1,8 @@
|
||||
import { Link, useParams } from 'react-router-dom';
|
||||
import { plural } from '@kb/shared';
|
||||
import { SectionOfflineRow } from '../components/Offline';
|
||||
import { Screen } from '../components/Shell';
|
||||
import { cacheSupported } from '../lib/offline';
|
||||
import { BackLink, Notice, Plaque, Skeleton, ThemeButton } from '../components/ui';
|
||||
import { num2 } from '../lib/format';
|
||||
import { articleHref, useNav } from '../lib/tree';
|
||||
@@ -42,8 +44,7 @@ export function SectionPage() {
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Сюда на этапе 5 встаёт строка «Сохранено для офлайна» */}
|
||||
<div id="section-offline-slot" data-section={section.id} />
|
||||
{cacheSupported() ? <SectionOfflineRow section={section} /> : null}
|
||||
|
||||
<div className="art-cards">
|
||||
{section.articles.map((a, i) => (
|
||||
|
||||
@@ -2111,3 +2111,126 @@ mark {
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
}
|
||||
|
||||
/* ---------- Офлайн ---------- */
|
||||
.offline-banner {
|
||||
display: flex;
|
||||
gap: var(--sp-6);
|
||||
align-items: flex-start;
|
||||
padding: calc(var(--sp-6) + env(safe-area-inset-top)) var(--sp-8) var(--sp-6);
|
||||
background: var(--brand);
|
||||
color: var(--brand-ink);
|
||||
}
|
||||
.offline-banner + .screen {
|
||||
padding-top: var(--sp-6);
|
||||
}
|
||||
.offline-banner-title {
|
||||
display: block;
|
||||
font-weight: 700;
|
||||
line-height: var(--lh-snug);
|
||||
}
|
||||
.offline-banner-text {
|
||||
display: block;
|
||||
font-size: var(--fs-14);
|
||||
}
|
||||
.warn-tri {
|
||||
flex: none;
|
||||
position: relative;
|
||||
width: 0;
|
||||
height: 0;
|
||||
margin-top: var(--sp-1);
|
||||
border-left: 12px solid transparent;
|
||||
border-right: 12px solid transparent;
|
||||
border-bottom: 20px solid var(--brand-ink);
|
||||
}
|
||||
.warn-tri::after {
|
||||
content: '';
|
||||
position: absolute;
|
||||
left: -2px;
|
||||
top: 6px;
|
||||
width: 4px;
|
||||
height: 8px;
|
||||
background: var(--brand);
|
||||
}
|
||||
.progress {
|
||||
display: block;
|
||||
height: 4px;
|
||||
margin-top: var(--sp-3);
|
||||
border-radius: var(--r-xs);
|
||||
background: var(--sf2);
|
||||
overflow: hidden;
|
||||
}
|
||||
.progress span {
|
||||
display: block;
|
||||
height: 100%;
|
||||
background: var(--grnS);
|
||||
transition: width 0.2s;
|
||||
}
|
||||
.progress--lg {
|
||||
height: 10px;
|
||||
margin: 0;
|
||||
border-radius: 5px;
|
||||
border: var(--bw) solid var(--ln);
|
||||
}
|
||||
.off-title {
|
||||
font-size: var(--fs-24);
|
||||
font-weight: 700;
|
||||
}
|
||||
.off-note {
|
||||
font-size: var(--fs-14);
|
||||
color: var(--ink2);
|
||||
line-height: var(--lh-normal);
|
||||
}
|
||||
.off-card {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: var(--sp-5);
|
||||
padding: var(--sp-7);
|
||||
border: var(--bw) solid var(--ln);
|
||||
border-radius: var(--r-card);
|
||||
background: var(--sf);
|
||||
}
|
||||
.off-card-head {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: var(--sp-6);
|
||||
}
|
||||
.off-card-name {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
font-weight: 700;
|
||||
line-height: var(--lh-snug);
|
||||
}
|
||||
.off-card-size,
|
||||
.off-card-pct {
|
||||
font-size: var(--fs-13);
|
||||
color: var(--ink2);
|
||||
}
|
||||
.off-card-done {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: var(--sp-4);
|
||||
min-height: var(--h-chip);
|
||||
color: var(--grn);
|
||||
font-size: var(--fs-15);
|
||||
font-weight: 700;
|
||||
}
|
||||
.off-card-loading {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: var(--sp-3);
|
||||
}
|
||||
.off-card-btn {
|
||||
min-height: 52px;
|
||||
border-radius: var(--r-btn);
|
||||
font-size: var(--fs-16);
|
||||
white-space: normal;
|
||||
}
|
||||
.btn--lg.btn--block {
|
||||
white-space: normal;
|
||||
}
|
||||
@media (min-width: 1024px) {
|
||||
.home-more {
|
||||
display: none;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user