@hortonstudio/main 1.1.28 → 1.1.30
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/styles.css +11 -1
- package/utils/toc.js +19 -0
package/package.json
CHANGED
package/styles.css
CHANGED
@@ -16,4 +16,14 @@ body .transition {display: block}
|
|
16
16
|
html, body {
|
17
17
|
overscroll-behavior: none;
|
18
18
|
scrollbar-gutter: stable;
|
19
|
-
}
|
19
|
+
}
|
20
|
+
|
21
|
+
/* TOC focus handling - only show focus outline for keyboard navigation */
|
22
|
+
[data-hs-toc] div[id]:focus:not(:focus-visible) {
|
23
|
+
outline: none !important;
|
24
|
+
}
|
25
|
+
|
26
|
+
[data-hs-toc] div[id]:focus-visible {
|
27
|
+
outline: 2px solid #007bff !important;
|
28
|
+
outline-offset: 2px;
|
29
|
+
}
|
package/utils/toc.js
CHANGED
@@ -44,6 +44,25 @@ export async function init() {
|
|
44
44
|
link.appendChild(number);
|
45
45
|
link.appendChild(document.createTextNode(heading.textContent));
|
46
46
|
|
47
|
+
// Add click handler for smooth scrolling
|
48
|
+
link.addEventListener('click', (e) => {
|
49
|
+
e.preventDefault();
|
50
|
+
|
51
|
+
const targetSection = document.getElementById(sectionId);
|
52
|
+
if (targetSection) {
|
53
|
+
targetSection.scrollIntoView({ behavior: 'smooth' });
|
54
|
+
}
|
55
|
+
});
|
56
|
+
|
57
|
+
// Ensure sections are focusable for keyboard users but use CSS to control focus visibility
|
58
|
+
const targetSection = document.getElementById(sectionId);
|
59
|
+
if (targetSection) {
|
60
|
+
targetSection.setAttribute('tabindex', '-1');
|
61
|
+
// Use focus-visible to only show outline for keyboard focus
|
62
|
+
targetSection.style.outline = 'none';
|
63
|
+
targetSection.style.setProperty('outline', 'none', 'important');
|
64
|
+
}
|
65
|
+
|
47
66
|
// Add item to the TOC list
|
48
67
|
tocList.appendChild(tocItem);
|
49
68
|
});
|