Skip to content

Commit 720bed6

Browse files
committed
added a show sections switch for changelog pages
1 parent 0a86b98 commit 720bed6

5 files changed

Lines changed: 209 additions & 2 deletions

File tree

docs/changelog/on-premise-changelog.en.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -551,7 +551,7 @@ hide:
551551

552552
- Changed the version of the osa-api Alpine base image from 3.21 to 3.20 to support the latest versions of Dynatrace monitoring
553553

554-
### Fixed
554+
#### Fixed
555555

556556
- Fixed the lack of policy alerts in the PDF report download for the first SCA scan
557557
- Optimized database queries when calculating policy ignores

docs/changelog/on-premise-changelog.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -552,7 +552,7 @@ hide:
552552

553553
- Изменена версия базового образа osa-api Alpine c 3.21 до 3.20 для поддержки мониторинга Dynatrace последних версий
554554

555-
### Исправлено
555+
#### Исправлено
556556

557557
- Исправлено отсутствие алертов политик в выгрузке PDF-отчета по первому SCA-сканированию
558558
- Оптимизированы запросы к базе данных при рассчете игноров политик

docs/js/changelog-toc.js

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
(function () {
2+
function isChangelogPage() {
3+
const path = location.pathname || "";
4+
return /\/changelog\//.test(path);
5+
}
6+
7+
function getLang() {
8+
return /\.en\//.test(location.pathname) ? "en" : "ru";
9+
}
10+
11+
function initToggle() {
12+
if (!isChangelogPage()) return;
13+
14+
const toc = document.querySelector('.md-sidebar--secondary .md-nav--secondary');
15+
if (!toc) return;
16+
17+
const title = toc.querySelector('.md-nav__title');
18+
if (!title) return;
19+
20+
if (toc.querySelector('.cs-toc-toggle')) return;
21+
22+
const root = document.documentElement;
23+
const lang = getLang();
24+
25+
const btn = document.createElement('button');
26+
btn.type = 'button';
27+
btn.className = 'cs-toc-toggle';
28+
btn.setAttribute('aria-expanded', 'true');
29+
btn.setAttribute('aria-label', lang === 'en' ? 'Hide sections' : 'Скрыть секции');
30+
btn.innerHTML = '<span class="cs-toc-toggle__thumb" aria-hidden="true"></span>';
31+
32+
let tooltipEl = null;
33+
let tooltipText = lang === 'en' ? 'Hide\nsections' : 'Скрыть\nсекции';
34+
35+
function positionTooltip() {
36+
if (!tooltipEl) return;
37+
const rect = btn.getBoundingClientRect();
38+
const top = rect.top + rect.height / 2 - tooltipEl.offsetHeight / 2;
39+
const left = rect.right + 8;
40+
tooltipEl.style.top = `${Math.max(8, top)}px`;
41+
tooltipEl.style.left = `${left}px`;
42+
}
43+
44+
function showTooltip() {
45+
if (tooltipEl) return;
46+
tooltipEl = document.createElement('div');
47+
tooltipEl.className = 'cs-toc-tooltip';
48+
tooltipEl.textContent = tooltipText;
49+
document.body.appendChild(tooltipEl);
50+
positionTooltip();
51+
// Keep tooltip aligned on scroll/resize while hovering.
52+
window.addEventListener('scroll', positionTooltip, true);
53+
window.addEventListener('resize', positionTooltip);
54+
}
55+
56+
function hideTooltip() {
57+
if (!tooltipEl) return;
58+
tooltipEl.remove();
59+
tooltipEl = null;
60+
window.removeEventListener('scroll', positionTooltip, true);
61+
window.removeEventListener('resize', positionTooltip);
62+
}
63+
64+
btn.addEventListener('mouseenter', showTooltip);
65+
btn.addEventListener('focus', showTooltip);
66+
btn.addEventListener('mouseleave', hideTooltip);
67+
btn.addEventListener('blur', hideTooltip);
68+
69+
btn.addEventListener('click', () => {
70+
const collapsed = root.classList.toggle('cs-changelog-toc-collapsed');
71+
btn.classList.toggle('is-collapsed', collapsed);
72+
btn.setAttribute('aria-expanded', String(!collapsed));
73+
btn.setAttribute('aria-label', collapsed
74+
? (lang === 'en' ? 'Show sections' : 'Показать секции')
75+
: (lang === 'en' ? 'Hide sections' : 'Скрыть секции'));
76+
tooltipText = collapsed
77+
? (lang === 'en' ? 'Show\nsections' : 'Показать\nсекции')
78+
: (lang === 'en' ? 'Hide\nsections' : 'Скрыть\nсекции');
79+
if (tooltipEl) {
80+
tooltipEl.textContent = tooltipText;
81+
positionTooltip();
82+
}
83+
});
84+
85+
title.classList.add('cs-toc-title');
86+
title.appendChild(btn);
87+
}
88+
89+
if (document.readyState === 'loading') {
90+
document.addEventListener('DOMContentLoaded', initToggle);
91+
} else {
92+
initToggle();
93+
}
94+
})();

docs/stylesheets/extra.css

Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,116 @@
6969
text-decoration: none !important;
7070
}
7171

72+
/* Changelog TOC toggle */
73+
.cs-toc-title {
74+
display: inline-flex;
75+
align-items: center;
76+
gap: 0.25rem;
77+
overflow: visible;
78+
position: relative;
79+
}
80+
81+
.md-nav__title.cs-toc-title {
82+
overflow: visible;
83+
}
84+
85+
.md-sidebar--secondary .md-nav--secondary {
86+
overflow: visible;
87+
}
88+
89+
.cs-toc-toggle {
90+
display: inline-flex;
91+
align-items: center;
92+
justify-content: flex-start;
93+
width: 24px;
94+
height: 10px;
95+
padding: 1px;
96+
border-radius: 999px;
97+
border: 1px solid rgba(255, 255, 255, 0.28);
98+
background: rgba(255, 255, 255, 0.12);
99+
cursor: pointer;
100+
position: relative;
101+
z-index: 2;
102+
pointer-events: auto;
103+
transition: background 0.2s ease, border-color 0.2s ease;
104+
}
105+
106+
.cs-toc-toggle__thumb {
107+
width: 6px;
108+
height: 6px;
109+
border-radius: 999px;
110+
background: #d6d6d6;
111+
transition: transform 0.2s ease, background 0.2s ease;
112+
}
113+
114+
.cs-toc-toggle:hover {
115+
background: rgba(255, 255, 255, 0.28);
116+
border-color: rgba(255, 255, 255, 0.5);
117+
}
118+
119+
.cs-toc-toggle:hover .cs-toc-toggle__thumb {
120+
background: #ffffff;
121+
}
122+
123+
.cs-toc-toggle.is-collapsed {
124+
background: rgba(255, 255, 255, 0.08);
125+
border-color: rgba(255, 255, 255, 0.24);
126+
}
127+
128+
.cs-toc-toggle.is-collapsed .cs-toc-toggle__thumb {
129+
transform: translateX(12px);
130+
background: #ffffff;
131+
}
132+
133+
.cs-toc-tooltip {
134+
position: fixed;
135+
padding: 0.25rem 0.5rem;
136+
border-radius: 6px;
137+
background: rgba(28, 29, 31, 0.95);
138+
color: #ffffff;
139+
font-size: 0.7rem;
140+
white-space: pre-line;
141+
line-height: 1.2;
142+
max-width: 90px;
143+
text-align: left;
144+
z-index: 1000;
145+
pointer-events: none;
146+
}
147+
148+
/* Hide nested TOC levels when collapsed (keep versions only) */
149+
.cs-changelog-toc-collapsed .md-sidebar--secondary .md-nav__list .md-nav__list {
150+
display: none;
151+
}
152+
153+
/* Normalize spacing for versions list when sections are hidden */
154+
.cs-changelog-toc-collapsed .md-sidebar--secondary .md-nav__list {
155+
padding-top: 0.2rem;
156+
}
157+
158+
.cs-changelog-toc-collapsed .md-sidebar--secondary .md-nav__list > .md-nav__item {
159+
margin-top: 0;
160+
}
161+
162+
.cs-changelog-toc-collapsed .md-sidebar--secondary .md-nav__list > .md-nav__item + .md-nav__item {
163+
margin-top: 0.45rem;
164+
}
165+
166+
.cs-changelog-toc-collapsed .md-sidebar--secondary .md-nav__item--nested {
167+
padding-bottom: 0 !important;
168+
}
169+
170+
.cs-changelog-toc-collapsed .md-sidebar--secondary .md-nav__item--nested > .md-nav__link {
171+
margin-bottom: 0 !important;
172+
}
173+
174+
.cs-changelog-toc-collapsed .md-sidebar--secondary .md-nav__list > .md-nav__item > .md-nav__link {
175+
margin: 0 !important;
176+
padding-top: 0.2rem !important;
177+
padding-bottom: 0.2rem !important;
178+
line-height: 1.35 !important;
179+
display: block;
180+
}
181+
72182
.md-nav__link:hover,
73183
.md-nav__item .md-nav__link:hover {
74184
text-decoration: underline !important;

mkdocs.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -734,8 +734,11 @@ extra_css:
734734
extra_javascript:
735735
- js/search.js
736736
- js/home.js
737+
- js/feedback.js
738+
- js/changelog-toc.js
737739

738740
extra:
741+
feedback_endpoint: "https://script.google.com/macros/s/AKfycbwK-c3VzYAAMBxg85FKaoA99EL32Lh-3-Bkcr1tWJUyRiVycR4K0r3qy4z0XnT6fpqicg/exec"
739742
social:
740743
- icon: fontawesome/brands/youtube
741744
link: https://www.youtube.com/@codescoring

0 commit comments

Comments
 (0)