Skip to content

Commit a3c2f43

Browse files
authored
Update news.html
1 parent 3b9c4b0 commit a3c2f43

1 file changed

Lines changed: 40 additions & 7 deletions

File tree

‎_layouts/news.html‎

Lines changed: 40 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@
103103
font-family: 'JetBrains Mono', monospace;
104104
margin-top: 40px;
105105
margin-bottom: 15px;
106+
scroll-margin-top: 100px; /* Zapewnia poprawną pozycję scrolla przy kliknięciu w TOC */
106107
}
107108
.news-body h2 { font-size: 1.4rem; border-left: 3px solid var(--accent-blue); padding-left: 10px; }
108109
.news-body p { margin-bottom: 20px; }
@@ -231,12 +232,23 @@
231232
color: var(--text-muted);
232233
text-decoration: none;
233234
display: block;
234-
transition: 0.2s;
235+
padding: 4px 8px;
236+
border-radius: 4px;
237+
transition: all 0.2s ease;
235238
}
236239
.toc-item a:hover {
237240
color: var(--accent-blue);
238241
transform: translateX(4px);
239242
}
243+
244+
/* AKTYWNY ELEMENT W SPISIE TREŚCI (PODŚWIETLENIE) */
245+
.toc-item.active a {
246+
color: var(--accent-blue);
247+
background: rgba(0, 210, 255, 0.12);
248+
font-weight: 700;
249+
border-left: 2px solid var(--accent-blue);
250+
transform: translateX(4px);
251+
}
240252

241253
/* SEKCJA KOMENTARZY NA DOLE */
242254
.comments-section {
@@ -397,7 +409,7 @@ <h3 class="comments-title">// Komentarze & Opinie</h3>
397409
</section>
398410
</article>
399411

400-
<!-- BOCZny PANEL: SPIS TREŚCI (TOC) -->
412+
<!-- BOCZNY PANEL: SPIS TREŚCI (TOC) -->
401413
<aside class="sidebar-toc">
402414
<h4 class="toc-title">// Spis Treści</h4>
403415
<ul class="toc-list" id="tocList"></ul>
@@ -411,10 +423,6 @@ <h4 class="toc-title">// Spis Treści</h4>
411423
</a>
412424

413425
<script>
414-
// FAQ markdown structure expected in the post body:
415-
// - `## FAQ` / `## Najczęściej zadawane pytania` (or heading containing these phrases) starts FAQ section
416-
// - each `###` in this section is treated as one question
417-
// - all elements under that `###` until next `###` or next `##` are treated as answer content
418426
function normalizeHeadingText(text) {
419427
return (text || '')
420428
.toLowerCase()
@@ -486,7 +494,7 @@ <h4 class="toc-title">// Spis Treści</h4>
486494
faqHeading.insertAdjacentElement('afterend', faqWrapper);
487495
}
488496

489-
// AUTOMATYCZNY SPIS TREŚCI ZE STRUKTURY NAGŁÓWKÓW
497+
// AUTOMATYCZNY SPIS TREŚCI ZE STRUKTURY NAGŁÓWKÓW I INTERSECTION OBSERVER DLA PODŚWIETLANIA
490498
const articleBody = document.getElementById('articleBody');
491499
const tocList = document.getElementById('tocList');
492500
transformFaqToAccordion(articleBody);
@@ -502,10 +510,35 @@ <h4 class="toc-title">// Spis Treści</h4>
502510
if(!heading.id) { heading.id = 'heading-' + index; }
503511
const li = document.createElement('li');
504512
li.className = 'toc-item';
513+
li.setAttribute('data-target', heading.id);
505514
li.style.paddingLeft = heading.tagName === 'H3' ? '12px' : '0';
506515
li.innerHTML = `<a href="#${heading.id}">&rarr; ${heading.textContent}</a>`;
507516
tocList.appendChild(li);
508517
});
518+
519+
// SHADOW SENSOR / INTERSECTION OBSERVER DLA DYNAMICZNEGO PODŚWIETLANIA SPISU TREŚCI
520+
const observerOptions = {
521+
root: null,
522+
rootMargin: '0px 0px -65% 0px', // Aktywuje sekcję po przewinięciu do ~35% wysokości ekranu
523+
threshold: 0
524+
};
525+
526+
const observer = new IntersectionObserver((entries) => {
527+
entries.forEach((entry) => {
528+
if (entry.isIntersecting) {
529+
const id = entry.target.getAttribute('id');
530+
document.querySelectorAll('.toc-item').forEach((item) => {
531+
if (item.getAttribute('data-target') === id) {
532+
item.classList.add('active');
533+
} else {
534+
item.classList.remove('active');
535+
}
536+
});
537+
}
538+
});
539+
}, observerOptions);
540+
541+
headings.forEach((heading) => observer.observe(heading));
509542
}
510543

511544
// PRZYCISKI UDOSTĘPNIANIA (TWITTER & FACEBOOK)

0 commit comments

Comments
 (0)