1
1
import React from 'react'
2
- import { StaticQuery , graphql , Link } from 'gatsby'
3
- import Loadable from 'react-loadable'
2
+ import { StaticQuery , graphql } from 'gatsby'
4
3
import classNames from 'classnames'
5
4
6
5
import config from '../../config.js'
7
- import LoadingProvider from './mdxComponents/loading'
8
6
import Sidebar from './sidebar'
9
7
import Icon from './Icon'
8
+ import Link from './Link'
10
9
11
10
const isSearchEnabled = ! ! ( config . header . search && config . header . search . enabled )
12
11
@@ -17,11 +16,6 @@ if (isSearchEnabled && config.header.search.indexName) {
17
16
)
18
17
}
19
18
20
- const LoadableComponent = Loadable ( {
21
- loader : ( ) => import ( './search/index' ) , //eslint-disable-line
22
- loading : LoadingProvider
23
- } )
24
-
25
19
function myFunction ( ) {
26
20
var x = document . getElementById ( 'navbar' )
27
21
if ( x . className === 'topnav' ) {
@@ -31,7 +25,12 @@ function myFunction () {
31
25
}
32
26
}
33
27
34
- const Header = ( { location, showSidebar, border = true } ) => (
28
+ const Header = ( {
29
+ location,
30
+ showSidebar,
31
+ border = true ,
32
+ onSearchClick
33
+ } ) => (
35
34
< StaticQuery
36
35
query = {
37
36
graphql `
@@ -66,47 +65,36 @@ const Header = ({ location, showSidebar, border = true }) => (
66
65
< nav className = { classNames ( 'flex px-10 py-4 items-center z-10 relative' , {
67
66
'border-b border-qrigray-200' : border
68
67
} ) } >
69
- < Link to = { finalLogoLink } className = { 'mr-3' } >
68
+ < Link colorClassName = { 'text-black' } to = { finalLogoLink } className = { 'mr-3' } >
70
69
< img className = { 'img-responsive displayInline' } src = { ( logo . image !== '' ) ? logo . image : logoImg } alt = { 'logo' } />
71
70
</ Link >
72
- < div className = 'text-xl' >
73
- < Link to = '/' >
71
+ < div className = 'text-xl flex ' >
72
+ < Link colorClassName = { 'text-black' } to = '/' >
74
73
< span className = 'font-extrabold' > Qri</ span >
75
74
</ Link >
76
75
< span className = 'text-xl' > /</ span >
77
- < Link to = '/docs' >
76
+ < Link colorClassName = { 'text-black' } to = '/docs' >
78
77
< span className = 'text-qriqritile-600' > Docs</ span >
79
78
</ Link > </ div >
80
79
< span onClick = { myFunction } className = { 'navBarToggle' } >
81
80
< span className = { 'iconBar' } > </ span >
82
81
< span className = { 'iconBar' } > </ span >
83
82
< span className = { 'iconBar' } > </ span >
84
83
</ span >
85
- { isSearchEnabled ? (
86
- < div className = { 'searchWrapper hiddenMobile navBarUL' } >
87
- < LoadableComponent collapse = { true } indices = { searchIndices } />
88
- </ div >
89
- ) : null }
90
84
< div id = "navbar" className = { 'flex-grow text-right' } >
91
85
< div className = { 'sm:hidden' } >
92
86
{ showSidebar && < > < Sidebar location = { location } /> < hr /> </ > }
93
- { isSearchEnabled ? (
94
- < div className = { 'searchWrapper' } >
95
- < LoadableComponent collapse = { true } indices = { searchIndices } />
96
- </ div >
97
- ) : null }
98
87
</ div >
99
88
< ul className = { 'flex justify-end text-sm font-semibold tracking-wide' } >
100
89
{ headerLinks . map ( ( headerLink , key ) => {
101
90
const { link, text, colorClass } = headerLink
102
91
103
92
if ( link !== '' && text !== '' ) {
104
- // internal links get a <Link/>
105
93
if ( link . charAt ( 0 ) === '/' ) {
106
94
return (
107
95
< li key = { key } className = 'ml-10 flex items-center' >
108
96
{ colorClass && ( < Icon icon = 'docsRing' size = '2xs' className = { classNames ( colorClass , 'mr-2' ) } /> ) }
109
- < Link to = { link } > { text } </ Link >
97
+ < Link colorClassName = { 'text-black' } to = { link } > { text } </ Link >
110
98
</ li >
111
99
)
112
100
}
@@ -118,6 +106,9 @@ const Header = ({ location, showSidebar, border = true }) => (
118
106
)
119
107
}
120
108
} ) }
109
+ < li className = 'ml-10 flex items-center' >
110
+ < Link colorClassName = { 'text-black' } onClick = { onSearchClick } > < Icon icon = 'search' size = 'md' /> </ Link >
111
+ </ li >
121
112
</ ul >
122
113
</ div >
123
114
</ nav >
0 commit comments