1
1
/** @jsx jsx */
2
- import React , { useState , useRef , useEffect } from " react" ;
3
- import { Global } from " @emotion/core" ;
4
- import { jsx , Box } from " theme-ui" ;
5
- import { useMenus , useCurrentDoc } from " docz" ;
2
+ import { Fragment , forwardRef , useState , useRef , useEffect } from ' react'
3
+ import { Global } from ' @emotion/core'
4
+ import { jsx , Box } from ' theme-ui'
5
+ import { useMenus , useCurrentDoc } from ' docz'
6
6
7
- import * as styles from " gatsby-theme-docz/src/components/Sidebar/styles" ;
8
- import { NavSearch } from " gatsby-theme-docz/src/components/NavSearch" ;
9
- import { NavLink } from " gatsby-theme-docz/src/components/NavLink" ;
10
- import { NavGroup } from " gatsby-theme-docz/src/components/NavGroup" ;
7
+ import * as styles from ' gatsby-theme-docz/src/components/Sidebar/styles'
8
+ import { NavSearch } from ' gatsby-theme-docz/src/components/NavSearch'
9
+ import { NavLink } from ' gatsby-theme-docz/src/components/NavLink'
10
+ import { NavGroup } from ' gatsby-theme-docz/src/components/NavGroup'
11
11
12
- export const Sidebar = React . forwardRef ( ( props , ref ) => {
13
- const [ query , setQuery ] = useState ( "" ) ;
14
- const menus = useMenus ( { query } ) ;
15
- const currentDoc = useCurrentDoc ( ) ;
16
- const currentDocRef = useRef ( ) ;
12
+ export const Sidebar = forwardRef ( function Sidebar ( props , ref ) {
13
+ const [ query , setQuery ] = useState ( '' )
14
+ const menus = useMenus ( { query } )
15
+ const currentDoc = useCurrentDoc ( )
16
+ const currentDocRef = useRef ( )
17
17
const handleChange = ev => {
18
- setQuery ( ev . target . value ) ;
19
- } ;
18
+ setQuery ( ev . target . value )
19
+ }
20
20
useEffect ( ( ) => {
21
21
if ( ref . current && currentDocRef . current ) {
22
- ref . current . scrollTo ( 0 , currentDocRef . current . offsetTop ) ;
22
+ ref . current . scrollTo ( 0 , currentDocRef . current . offsetTop )
23
23
}
24
- } , [ ] ) ;
24
+ } , [ ] )
25
25
return (
26
- < >
26
+ < Fragment >
27
27
< Box onClick = { props . onClick } sx = { styles . overlay ( props ) } >
28
28
{ props . open && < Global styles = { styles . global } /> }
29
29
</ Box >
@@ -38,21 +38,21 @@ export const Sidebar = React.forwardRef((props, ref) => {
38
38
{ menus &&
39
39
menus . map ( menu => {
40
40
if ( ! menu . route )
41
- return < NavGroup key = { menu . id } item = { menu } sidebarRef = { ref } /> ;
41
+ return < NavGroup key = { menu . id } item = { menu } sidebarRef = { ref } />
42
42
if ( menu . route === currentDoc . route ) {
43
43
return (
44
44
< NavLink key = { menu . id } item = { menu } ref = { currentDocRef } >
45
45
{ menu . name }
46
46
</ NavLink >
47
- ) ;
47
+ )
48
48
}
49
49
return (
50
50
< NavLink key = { menu . id } item = { menu } >
51
51
{ menu . name }
52
52
</ NavLink >
53
- ) ;
53
+ )
54
54
} ) }
55
55
</ Box >
56
- </ >
57
- ) ;
58
- } ) ;
56
+ </ Fragment >
57
+ )
58
+ } )
0 commit comments