1
1
import { MarkGithubIcon , SearchIcon , ThreeBarsIcon } from '@primer/octicons-react'
2
- import { Box , Button , Link , StyledOcticon , Text , ThemeProvider , useTheme } from '@primer/react'
2
+ import { Box , Button , Link , StyledOcticon , Text , ThemeProvider , useTheme , UnderlineNav } from '@primer/react'
3
3
import VisuallyHidden from './visually-hidden'
4
4
import { Link as GatsbyLink } from 'gatsby'
5
5
import React from 'react'
6
6
import primerNavItems from '../primer-nav.yml'
7
7
import useSiteMetadata from '../use-site-metadata'
8
8
import MobileSearch from './mobile-search'
9
9
import NavDrawer , { useNavDrawerState } from './nav-drawer'
10
- import NavDropdown , { NavDropdownItem } from './nav-dropdown'
11
10
import Search from './search'
12
11
import SkipLink from './skip-link'
13
12
14
- export const HEADER_HEIGHT = 66
13
+ export const HEADER_HEIGHT = 56
15
14
16
- function Header ( { isSearchEnabled} ) {
15
+ function Header ( { isSearchEnabled, path } ) {
17
16
const { theme} = useTheme ( )
18
17
const [ isNavDrawerOpen , setIsNavDrawerOpen ] = useNavDrawerState ( theme . breakpoints [ 2 ] )
19
18
const [ isMobileSearchOpen , setIsMobileSearchOpen ] = React . useState ( false )
20
19
const siteMetadata = useSiteMetadata ( )
20
+
21
21
return (
22
- < ThemeProvider colorMode = "night" nightScheme = "dark_dimmed" >
22
+ < ThemeProvider >
23
23
< Box sx = { { position : 'sticky' , top : 0 , zIndex : 1 } } >
24
24
< Box
25
25
as = "header"
@@ -29,27 +29,29 @@ function Header({isSearchEnabled}) {
29
29
px : [ 3 , null , null , 4 ] ,
30
30
alignItems : 'center' ,
31
31
justifyContent : 'space-between' ,
32
- bg : 'canvas.default'
32
+ bg : 'canvas.default' ,
33
+ border : '1px solid' ,
34
+ borderColor : 'border.muted'
33
35
} }
34
36
>
35
37
< SkipLink />
36
38
< Box sx = { { display : 'flex' , alignItems : 'center' } } >
37
39
< Link
38
40
href = { siteMetadata . header . logoUrl }
39
41
sx = { {
40
- color : 'accent.fg ' ,
42
+ color : 'fg.default ' ,
41
43
mr : 3 ,
42
44
lineHeight : 'condensedUltra'
43
45
} }
44
46
>
45
- < StyledOcticon icon = { MarkGithubIcon } size = "medium " />
47
+ < StyledOcticon icon = { MarkGithubIcon } size = "24px " />
46
48
</ Link >
47
49
{ siteMetadata . header . title ? (
48
50
< Link
49
51
href = { siteMetadata . header . url }
50
52
sx = { {
51
- color : 'accent.fg ' ,
52
- fontFamily : 'mono ' ,
53
+ color : 'fg.default ' ,
54
+ fontWeight : 'bold ' ,
53
55
display : [
54
56
// We only hide "Primer" on small viewports if a shortName is defined.
55
57
siteMetadata . shortName ? 'none' : 'inline-block' ,
@@ -68,8 +70,7 @@ function Header({isSearchEnabled}) {
68
70
< Text
69
71
sx = { {
70
72
display : [ 'none' , null , null , 'inline-block' ] ,
71
- color : 'accent.fg' ,
72
- fontFamily : 'mono' ,
73
+ color : 'fg.default' ,
73
74
mx : 2
74
75
} }
75
76
>
@@ -80,24 +81,23 @@ function Header({isSearchEnabled}) {
80
81
as = { GatsbyLink }
81
82
to = "/"
82
83
sx = { {
83
- color : 'accent.fg ' ,
84
- fontFamily : 'mono '
84
+ fontWeight : 'bold ' ,
85
+ color : 'fg.default '
85
86
} }
86
87
>
87
88
{ siteMetadata . shortName }
88
89
</ Link >
89
90
</ >
90
91
) : null }
91
-
92
- { isSearchEnabled ? (
93
- < Box sx = { { display : [ 'none' , null , null , 'block' ] , ml : 4 } } >
94
- < Search />
95
- </ Box >
96
- ) : null }
97
92
</ Box >
98
93
< Box >
99
- < Box sx = { { display : [ 'none' , null , null , 'block' ] } } >
100
- < PrimerNavItems siteMetadata = { siteMetadata } items = { primerNavItems } />
94
+ < Box sx = { { display : [ 'none' , null , null , 'flex' ] , alignItems : 'center' } } >
95
+ < PrimerNavItems path = { path } siteMetadata = { siteMetadata } items = { primerNavItems } />
96
+ { isSearchEnabled ? (
97
+ < Box sx = { { display : [ 'none' , null , null , 'block' ] , ml : 3 } } >
98
+ < Search />
99
+ </ Box >
100
+ ) : null }
101
101
</ Box >
102
102
< Box sx = { { display : [ 'flex' , null , null , 'none' ] } } >
103
103
{ isSearchEnabled ? (
@@ -138,48 +138,21 @@ Header.defaultProps = {
138
138
isSearchEnabled : true
139
139
}
140
140
141
- function PrimerNavItems ( { siteMetadata, items} ) {
141
+ function PrimerNavItems ( { siteMetadata, items, path } ) {
142
142
return (
143
143
< >
144
144
< VisuallyHidden >
145
145
< h3 aria-labelledby = "site-header" > { siteMetadata . header . title } </ h3 >
146
146
</ VisuallyHidden >
147
- < Box
148
- as = { 'nav' }
149
- sx = { { display : 'flex' , alignItems : 'center' , justifyContent : 'space-between' , color : 'fg.default' , gap : 2 } }
150
- >
147
+ < UnderlineNav aria-label = "main navigation" sx = { { border : 'none' } } >
151
148
{ items . map ( ( item , index ) => {
152
- if ( item . children ) {
153
- return (
154
- < Box key = { index } >
155
- < NavDropdown title = { item . title } >
156
- { item . children . map ( child => (
157
- < NavDropdownItem key = { child . title } href = { child . url } >
158
- { child . title }
159
- </ NavDropdownItem >
160
- ) ) }
161
- </ NavDropdown >
162
- </ Box >
163
- )
164
- }
165
-
166
149
return (
167
- < Link
168
- key = { index }
169
- href = { item . url }
170
- sx = { {
171
- display : 'block' ,
172
- color : 'fg.default' ,
173
- fontSize : 2 ,
174
- ml : 2 ,
175
- mr : 2
176
- } }
177
- >
150
+ < UnderlineNav . Link key = { index } href = { item . url } selected = { item . url === siteMetadata . header . url + path } >
178
151
{ item . title }
179
- </ Link >
152
+ </ UnderlineNav . Link >
180
153
)
181
154
} ) }
182
- </ Box >
155
+ </ UnderlineNav >
183
156
</ >
184
157
)
185
158
}
0 commit comments