MediaWiki:Gadget-toc-progress.css: различия между версиями
Перейти к навигации
Перейти к поиску
Ланселот (обсуждение | вклад) Новая страница: «→Gadget: toc-progress: .gadget-toc { position: fixed; right: 16px; bottom: 24px; z-index: 1000; font: 14px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; color: #202122; } .gadget-toc__btn { position: relative; width: 56px; height: 56px; border-radius: 50%; border: none; background: #fff; box-shadow: 0 2px 10px rgba(0, 0, 0, .18); cursor: pointer; display: grid; place-items: center; opacity: 0; pointer-events: none; tran...» |
Ланселот (обсуждение | вклад) Нет описания правки |
||
| (не показано 5 промежуточных версий этого же участника) | |||
| Строка 1: | Строка 1: | ||
/* Gadget: toc-progress */ | /* ============================================================ | ||
Gadget: toc-progress | |||
Плавающее оглавление с прогрессом чтения. | |||
Поддержка тёмной темы «АСТРЕЯ» (html.dm) + системной. | |||
Позиция кнопки задаётся через JS (transform: translate + scale). | |||
Идёт в связке с [[MediaWiki:Gadget-toc-progress.js]] | |||
Лицензия: MIT (opensource.org/license/mit) ==> 2026, absurdopedia.wiki | |||
============================================================ */ | |||
/* ---------- Светлая тема (по умолчанию) ---------- */ | |||
.gadget-toc { | .gadget-toc { | ||
--toc-bg: #fff; | |||
--toc-fg: #202122; | |||
--toc-muted: #72777d; | |||
--toc-border: #eee; | |||
--toc-hover: #f2f5fa; | |||
--toc-active-bg: #eaf3ff; | |||
--toc-active-border: #36c; | |||
--toc-accent: #36c; | |||
--toc-ring-bg: #e6e6e6; | |||
--toc-shadow: 0 2px 10px rgba(0, 0, 0, .18); | |||
--toc-shadow-panel: 0 6px 24px rgba(0, 0, 0, .2); | |||
--toc-shadow-drag: 0 6px 20px rgba(0, 0, 0, .28); | |||
position: fixed; | position: fixed; | ||
top: 0; | |||
left: 0; | |||
will-change: transform; | |||
transform-origin: 0 0; | |||
z-index: 1000; | z-index: 1000; | ||
font: 14px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; | font: 14px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; | ||
color: # | color: var(--toc-fg); | ||
} | |||
/* ---------- Тёмная тема «АСТРЕЯ» (html.dm) ---------- */ | |||
html.dm .gadget-toc { | |||
--toc-bg: #1f2329; | |||
--toc-fg: #d0d0d0; | |||
--toc-muted: #9aa0a6; | |||
--toc-border: #444; | |||
--toc-hover: #2a3038; | |||
--toc-active-bg: #1c3a5e; | |||
--toc-active-border: #8cc8ff; | |||
--toc-accent: #8cc8ff; | |||
--toc-ring-bg: #3a4048; | |||
--toc-shadow: 0 2px 10px rgba(0, 0, 0, .5); | |||
--toc-shadow-panel: 0 6px 24px rgba(0, 0, 0, .6); | |||
--toc-shadow-drag: 0 6px 20px rgba(0, 0, 0, .7); | |||
} | } | ||
/* ---------- Системная тёмная тема — fallback ---------- */ | |||
/* Срабатывает только если html.dm НЕ установлен. */ | |||
@media ( prefers-color-scheme: dark ) { | |||
html:not(.dm) .gadget-toc { | |||
--toc-bg: #1f2329; | |||
--toc-fg: #d0d0d0; | |||
--toc-muted: #9aa0a6; | |||
--toc-border: #444; | |||
--toc-hover: #2a3038; | |||
--toc-active-bg: #1c3a5e; | |||
--toc-active-border: #8cc8ff; | |||
--toc-accent: #8cc8ff; | |||
--toc-ring-bg: #3a4048; | |||
--toc-shadow: 0 2px 10px rgba(0, 0, 0, .5); | |||
--toc-shadow-panel: 0 6px 24px rgba(0, 0, 0, .6); | |||
--toc-shadow-drag: 0 6px 20px rgba(0, 0, 0, .7); | |||
} | |||
} | |||
/* ============================================================ | |||
Кнопка | |||
============================================================ */ | |||
.gadget-toc__btn { | .gadget-toc__btn { | ||
position: relative; | position: relative; | ||
| Строка 14: | Строка 77: | ||
border-radius: 50%; | border-radius: 50%; | ||
border: none; | border: none; | ||
background: | background: var(--toc-bg); | ||
box-shadow: | box-shadow: var(--toc-shadow); | ||
cursor: | cursor: grab; | ||
display: grid; | display: grid; | ||
place-items: center; | place-items: center; | ||
| Строка 22: | Строка 85: | ||
pointer-events: none; | pointer-events: none; | ||
transition: opacity .2s ease, transform .2s ease; | transition: opacity .2s ease, transform .2s ease; | ||
touch-action: none; | |||
user-select: none; | |||
} | } | ||
.gadget-toc.is-visible .gadget-toc__btn { | .gadget-toc.is-visible .gadget-toc__btn { | ||
| Строка 30: | Строка 95: | ||
transform: scale(1.05); | transform: scale(1.05); | ||
} | } | ||
.gadget-toc__btn.is-dragging { | |||
cursor: grabbing; | |||
transform: scale(1.1); | |||
transition: none; | |||
box-shadow: var(--toc-shadow-drag); | |||
} | |||
/* ============================================================ | |||
Кольцо прогресса | |||
============================================================ */ | |||
.gadget-toc__ring { | .gadget-toc__ring { | ||
position: absolute; | position: absolute; | ||
| Строка 37: | Строка 112: | ||
.gadget-toc__ring-bg { | .gadget-toc__ring-bg { | ||
fill: none; | fill: none; | ||
stroke: | stroke: var(--toc-ring-bg); | ||
stroke-width: 3; | stroke-width: 3; | ||
} | } | ||
.gadget-toc__ring-fg { | .gadget-toc__ring-fg { | ||
fill: none; | fill: none; | ||
stroke: | stroke: var(--toc-accent); | ||
stroke-width: 3; | stroke-width: 3; | ||
stroke-linecap: round; | stroke-linecap: round; | ||
| Строка 50: | Строка 125: | ||
font-size: 11px; | font-size: 11px; | ||
font-weight: 600; | font-weight: 600; | ||
color: | color: var(--toc-accent); | ||
} | } | ||
/* ============================================================ | |||
Панель | |||
============================================================ */ | |||
.gadget-toc__panel { | .gadget-toc__panel { | ||
position: absolute; | position: absolute; | ||
top: 0; | |||
left: 0; | |||
width: 280px; | width: 280px; | ||
max-height: 60vh; | max-height: 60vh; | ||
overflow: auto; | overflow: auto; | ||
background: | background: var(--toc-bg); | ||
color: var(--toc-fg); | |||
border-radius: 10px; | border-radius: 10px; | ||
box-shadow: | box-shadow: var(--toc-shadow-panel); | ||
padding: 8px; | padding: 8px; | ||
/* Позиция задаётся через JS (transform), чтобы открывать панель | |||
в ту сторону, где есть место. */ | |||
will-change: transform; | |||
} | } | ||
.gadget-toc__head { | .gadget-toc__head { | ||
| Строка 71: | Строка 153: | ||
font-weight: 600; | font-weight: 600; | ||
padding: 4px 8px 8px; | padding: 4px 8px 8px; | ||
border-bottom: 1px solid | border-bottom: 1px solid var(--toc-border); | ||
} | } | ||
.gadget-toc__close { | .gadget-toc__close { | ||
border: none; | border: none; | ||
background: none; | background: none; | ||
color: var(--toc-fg); | |||
font-size: 20px; | font-size: 20px; | ||
cursor: pointer; | cursor: pointer; | ||
| Строка 89: | Строка 172: | ||
padding: 6px 10px; | padding: 6px 10px; | ||
border-radius: 6px; | border-radius: 6px; | ||
color: | color: var(--toc-fg); | ||
text-decoration: none; | text-decoration: none; | ||
border-left: 3px solid transparent; | border-left: 3px solid transparent; | ||
| Строка 97: | Строка 180: | ||
font-size: 13px; | font-size: 13px; | ||
} | } | ||
.gadget-toc__item--intro a { | |||
font-weight: 600; | |||
border-bottom: 1px solid var(--toc-border); | |||
margin-bottom: 4px; | |||
padding-bottom: 8px; | |||
} | |||
.gadget-toc__item a:hover { | .gadget-toc__item a:hover { | ||
background: | background: var(--toc-hover); | ||
} | } | ||
.gadget-toc__item a.is-active { | .gadget-toc__item a.is-active { | ||
background: | background: var(--toc-active-bg); | ||
border-left-color: | border-left-color: var(--toc-active-border); | ||
font-weight: 600; | font-weight: 600; | ||
} | } | ||
.gadget-toc__item a.is-done { | .gadget-toc__item a.is-done { | ||
color: | color: var(--toc-muted); | ||
} | } | ||
/* Отступ под фиксированную шапку */ | /* ============================================================ | ||
Отступ под фиксированную шапку | |||
============================================================ */ | |||
#mw-content-text h2, | #mw-content-text h2, | ||
#mw-content-text h3 { | #mw-content-text h3 { | ||
| Строка 115: | Строка 208: | ||
} | } | ||
/* ============================================================ | |||
Мобильный bottom-sheet | |||
============================================================ */ | |||
@media ( max-width: 719px ) { | @media ( max-width: 719px ) { | ||
.gadget-toc__panel { | .gadget-toc__panel { | ||
position: absolute; | |||
right: 0; | |||
bottom: 68px; | |||
width: 280px; | |||
max-height: 60vh; | |||
max-height: 60dvh; /* учитывает зум и visual viewport */ | |||
overflow-y: auto; | |||
} | overflow-x: hidden; | ||
overscroll-behavior: contain; | |||
-webkit-overflow-scrolling: touch; | |||
background: var(--toc-bg); | |||
color: var(--toc-fg); | |||
border-radius: 10px; | |||
box-shadow: var(--toc-shadow-panel); | |||
padding: 8px; | |||
} | |||
} | } | ||
/* ============================================================ | |||
Reduced motion | |||
============================================================ */ | |||
@media ( prefers-reduced-motion: reduce ) { | @media ( prefers-reduced-motion: reduce ) { | ||
.gadget-toc__btn, | .gadget-toc__btn, | ||
| Строка 135: | Строка 242: | ||
} | } | ||
/* ============================================================ | |||
Печать | |||
============================================================ */ | |||
@media print { | @media print { | ||
.gadget-toc { | .gadget-toc { | ||
Текущая версия от 20:28, 15 ноября 2026
/* ============================================================
Gadget: toc-progress
Плавающее оглавление с прогрессом чтения.
Поддержка тёмной темы «АСТРЕЯ» (html.dm) + системной.
Позиция кнопки задаётся через JS (transform: translate + scale).
Идёт в связке с [[MediaWiki:Gadget-toc-progress.js]]
Лицензия: MIT (opensource.org/license/mit) ==> 2026, absurdopedia.wiki
============================================================ */
/* ---------- Светлая тема (по умолчанию) ---------- */
.gadget-toc {
--toc-bg: #fff;
--toc-fg: #202122;
--toc-muted: #72777d;
--toc-border: #eee;
--toc-hover: #f2f5fa;
--toc-active-bg: #eaf3ff;
--toc-active-border: #36c;
--toc-accent: #36c;
--toc-ring-bg: #e6e6e6;
--toc-shadow: 0 2px 10px rgba(0, 0, 0, .18);
--toc-shadow-panel: 0 6px 24px rgba(0, 0, 0, .2);
--toc-shadow-drag: 0 6px 20px rgba(0, 0, 0, .28);
position: fixed;
top: 0;
left: 0;
will-change: transform;
transform-origin: 0 0;
z-index: 1000;
font: 14px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
color: var(--toc-fg);
}
/* ---------- Тёмная тема «АСТРЕЯ» (html.dm) ---------- */
html.dm .gadget-toc {
--toc-bg: #1f2329;
--toc-fg: #d0d0d0;
--toc-muted: #9aa0a6;
--toc-border: #444;
--toc-hover: #2a3038;
--toc-active-bg: #1c3a5e;
--toc-active-border: #8cc8ff;
--toc-accent: #8cc8ff;
--toc-ring-bg: #3a4048;
--toc-shadow: 0 2px 10px rgba(0, 0, 0, .5);
--toc-shadow-panel: 0 6px 24px rgba(0, 0, 0, .6);
--toc-shadow-drag: 0 6px 20px rgba(0, 0, 0, .7);
}
/* ---------- Системная тёмная тема — fallback ---------- */
/* Срабатывает только если html.dm НЕ установлен. */
@media ( prefers-color-scheme: dark ) {
html:not(.dm) .gadget-toc {
--toc-bg: #1f2329;
--toc-fg: #d0d0d0;
--toc-muted: #9aa0a6;
--toc-border: #444;
--toc-hover: #2a3038;
--toc-active-bg: #1c3a5e;
--toc-active-border: #8cc8ff;
--toc-accent: #8cc8ff;
--toc-ring-bg: #3a4048;
--toc-shadow: 0 2px 10px rgba(0, 0, 0, .5);
--toc-shadow-panel: 0 6px 24px rgba(0, 0, 0, .6);
--toc-shadow-drag: 0 6px 20px rgba(0, 0, 0, .7);
}
}
/* ============================================================
Кнопка
============================================================ */
.gadget-toc__btn {
position: relative;
width: 56px;
height: 56px;
border-radius: 50%;
border: none;
background: var(--toc-bg);
box-shadow: var(--toc-shadow);
cursor: grab;
display: grid;
place-items: center;
opacity: 0;
pointer-events: none;
transition: opacity .2s ease, transform .2s ease;
touch-action: none;
user-select: none;
}
.gadget-toc.is-visible .gadget-toc__btn {
opacity: 1;
pointer-events: auto;
}
.gadget-toc__btn:hover {
transform: scale(1.05);
}
.gadget-toc__btn.is-dragging {
cursor: grabbing;
transform: scale(1.1);
transition: none;
box-shadow: var(--toc-shadow-drag);
}
/* ============================================================
Кольцо прогресса
============================================================ */
.gadget-toc__ring {
position: absolute;
inset: 0;
transform: rotate(-90deg);
}
.gadget-toc__ring-bg {
fill: none;
stroke: var(--toc-ring-bg);
stroke-width: 3;
}
.gadget-toc__ring-fg {
fill: none;
stroke: var(--toc-accent);
stroke-width: 3;
stroke-linecap: round;
transition: stroke-dashoffset .15s linear;
}
.gadget-toc__pct {
font-size: 11px;
font-weight: 600;
color: var(--toc-accent);
}
/* ============================================================
Панель
============================================================ */
.gadget-toc__panel {
position: absolute;
top: 0;
left: 0;
width: 280px;
max-height: 60vh;
overflow: auto;
background: var(--toc-bg);
color: var(--toc-fg);
border-radius: 10px;
box-shadow: var(--toc-shadow-panel);
padding: 8px;
/* Позиция задаётся через JS (transform), чтобы открывать панель
в ту сторону, где есть место. */
will-change: transform;
}
.gadget-toc__head {
display: flex;
justify-content: space-between;
align-items: center;
font-weight: 600;
padding: 4px 8px 8px;
border-bottom: 1px solid var(--toc-border);
}
.gadget-toc__close {
border: none;
background: none;
color: var(--toc-fg);
font-size: 20px;
cursor: pointer;
line-height: 1;
}
.gadget-toc__list {
list-style: none;
margin: 6px 0 0;
padding: 0;
}
.gadget-toc__item a {
display: block;
padding: 6px 10px;
border-radius: 6px;
color: var(--toc-fg);
text-decoration: none;
border-left: 3px solid transparent;
}
.gadget-toc__item--sub a {
padding-left: 24px;
font-size: 13px;
}
.gadget-toc__item--intro a {
font-weight: 600;
border-bottom: 1px solid var(--toc-border);
margin-bottom: 4px;
padding-bottom: 8px;
}
.gadget-toc__item a:hover {
background: var(--toc-hover);
}
.gadget-toc__item a.is-active {
background: var(--toc-active-bg);
border-left-color: var(--toc-active-border);
font-weight: 600;
}
.gadget-toc__item a.is-done {
color: var(--toc-muted);
}
/* ============================================================
Отступ под фиксированную шапку
============================================================ */
#mw-content-text h2,
#mw-content-text h3 {
scroll-margin-top: 72px;
}
/* ============================================================
Мобильный bottom-sheet
============================================================ */
@media ( max-width: 719px ) {
.gadget-toc__panel {
position: absolute;
right: 0;
bottom: 68px;
width: 280px;
max-height: 60vh;
max-height: 60dvh; /* учитывает зум и visual viewport */
overflow-y: auto;
overflow-x: hidden;
overscroll-behavior: contain;
-webkit-overflow-scrolling: touch;
background: var(--toc-bg);
color: var(--toc-fg);
border-radius: 10px;
box-shadow: var(--toc-shadow-panel);
padding: 8px;
}
}
/* ============================================================
Reduced motion
============================================================ */
@media ( prefers-reduced-motion: reduce ) {
.gadget-toc__btn,
.gadget-toc__ring-fg,
.gadget-toc__item a {
transition: none;
}
}
/* ============================================================
Печать
============================================================ */
@media print {
.gadget-toc {
display: none;
}
}