@hortonstudio/main 1.1.29 → 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 +9 -19
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,34 +44,24 @@ export async function init() {
|
|
44
44
|
link.appendChild(number);
|
45
45
|
link.appendChild(document.createTextNode(heading.textContent));
|
46
46
|
|
47
|
-
// Add click handler
|
47
|
+
// Add click handler for smooth scrolling
|
48
48
|
link.addEventListener('click', (e) => {
|
49
|
-
// Prevent default to handle scrolling ourselves
|
50
49
|
e.preventDefault();
|
51
50
|
|
52
51
|
const targetSection = document.getElementById(sectionId);
|
53
52
|
if (targetSection) {
|
54
|
-
// Scroll to the section
|
55
53
|
targetSection.scrollIntoView({ behavior: 'smooth' });
|
56
|
-
|
57
|
-
// Don't focus the target element on mouse clicks (Safari focus issue)
|
58
|
-
// Focus will still work with keyboard navigation (Enter key, etc.)
|
59
54
|
}
|
60
55
|
});
|
61
56
|
|
62
|
-
//
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
// Allow focus for keyboard users
|
71
|
-
targetSection.focus();
|
72
|
-
}
|
73
|
-
}
|
74
|
-
});
|
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
|
+
}
|
75
65
|
|
76
66
|
// Add item to the TOC list
|
77
67
|
tocList.appendChild(tocItem);
|