File tree Expand file tree Collapse file tree 3 files changed +35
-12
lines changed Expand file tree Collapse file tree 3 files changed +35
-12
lines changed Original file line number Diff line number Diff line change @@ -16,6 +16,7 @@ import navigation from './navigation'
16
16
import relativeLinks from './relative-links'
17
17
import sideMenu from './side-menu'
18
18
import tracking from './tracking'
19
+ import searchBar from './search-bar'
19
20
feedback ( )
20
21
accordion ( )
21
22
accordionGroup ( )
@@ -33,4 +34,5 @@ backScrolling()
33
34
navigation ( )
34
35
relativeLinks ( )
35
36
sideMenu ( )
36
- tracking ( )
37
+ tracking ( )
38
+ searchBar ( )
Original file line number Diff line number Diff line change
1
+ const ELEMENT_NAME = '.DocsNav-search-input'
2
+
3
+ export default function ( ) {
4
+ const el = document . querySelectorAll ( ELEMENT_NAME ) [ 0 ]
5
+ if ( el ) {
6
+ el . addEventListener ( 'input' , function ( e ) {
7
+ // SwiftType currently trigger based on an `input` event being fired.
8
+ // However, we only want this to occur if there are more than 2 characters typed
9
+ // NOTE: If the user types 0 charactes i.e. removes and cancels a search we will still trigger SwiftType so we can hide the search UX.
10
+
11
+ if ( e . target . value . length > 0 && e . target . value . length < 3 ) {
12
+ e . stopImmediatePropagation ( )
13
+ }
14
+ } )
15
+ }
16
+ }
Original file line number Diff line number Diff line change 1
- export default function ( ) {
2
-
1
+ export default function ( ) {
3
2
// highlight active link slug in side menu
4
3
const pathname = document . location . pathname
5
4
// find all links associated with active catalog page
6
- const links = document . querySelectorAll ( `[data-class-active="menu-item--active"] > ul > li > a[href="${ pathname } "]` )
5
+ const links = document . querySelectorAll (
6
+ `[data-class-active="menu-item--active"] > ul > li > a[href="${ pathname } "]`
7
+ )
7
8
// only open the first 'category' that contains the active integrations
8
- links [ 0 ] . parentElement . parentElement . parentElement . className += ' menu-item--active'
9
- for ( let i = 0 ; i < links . length ; i ++ ) {
10
- let link = links [ i ]
11
- if ( link . classList . contains ( 'menu-item__link' ) ) {
12
- // set link to be active
13
- link . parentElement . className += ' menu-item--active menu-item--indicator'
14
- link . className += ' menu-item__link--indicator'
9
+ if ( ! ! links . length ) {
10
+ links [ 0 ] . parentElement . parentElement . parentElement . className +=
11
+ ' menu-item--active'
12
+ for ( let i = 0 ; i < links . length ; i ++ ) {
13
+ let link = links [ i ]
14
+ if ( link . classList . contains ( 'menu-item__link' ) ) {
15
+ // set link to be active
16
+ link . parentElement . className +=
17
+ ' menu-item--active menu-item--indicator'
18
+ link . className += ' menu-item__link--indicator'
19
+ }
15
20
}
16
21
}
17
- }
22
+ }
You can’t perform that action at this time.
0 commit comments