Skip to content

Commit 02eb6b3

Browse files
author
Josep Martins
authored
Update navigation (#603)
1 parent 78d3ee0 commit 02eb6b3

File tree

4 files changed

+40
-79
lines changed

4 files changed

+40
-79
lines changed

.changeset/stupid-singers-sort.md

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
---
2+
'@primer/gatsby-theme-doctocat': minor
3+
---
4+
5+
Navigation updates:
6+
7+
- Remove monospace font
8+
- Remove dark background and update link colors
9+
- Use UnderlineNav for top right links to provide the correct styling
10+
- Remove "View components" and "React components" from top and leave "Brand" and "About"

theme/src/components/header.js

+27-54
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,25 @@
11
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'
33
import VisuallyHidden from './visually-hidden'
44
import {Link as GatsbyLink} from 'gatsby'
55
import React from 'react'
66
import primerNavItems from '../primer-nav.yml'
77
import useSiteMetadata from '../use-site-metadata'
88
import MobileSearch from './mobile-search'
99
import NavDrawer, {useNavDrawerState} from './nav-drawer'
10-
import NavDropdown, {NavDropdownItem} from './nav-dropdown'
1110
import Search from './search'
1211
import SkipLink from './skip-link'
1312

14-
export const HEADER_HEIGHT = 66
13+
export const HEADER_HEIGHT = 56
1514

16-
function Header({isSearchEnabled}) {
15+
function Header({isSearchEnabled, path}) {
1716
const {theme} = useTheme()
1817
const [isNavDrawerOpen, setIsNavDrawerOpen] = useNavDrawerState(theme.breakpoints[2])
1918
const [isMobileSearchOpen, setIsMobileSearchOpen] = React.useState(false)
2019
const siteMetadata = useSiteMetadata()
20+
2121
return (
22-
<ThemeProvider colorMode="night" nightScheme="dark_dimmed">
22+
<ThemeProvider>
2323
<Box sx={{position: 'sticky', top: 0, zIndex: 1}}>
2424
<Box
2525
as="header"
@@ -29,27 +29,29 @@ function Header({isSearchEnabled}) {
2929
px: [3, null, null, 4],
3030
alignItems: 'center',
3131
justifyContent: 'space-between',
32-
bg: 'canvas.default'
32+
bg: 'canvas.default',
33+
border: '1px solid',
34+
borderColor: 'border.muted'
3335
}}
3436
>
3537
<SkipLink />
3638
<Box sx={{display: 'flex', alignItems: 'center'}}>
3739
<Link
3840
href={siteMetadata.header.logoUrl}
3941
sx={{
40-
color: 'accent.fg',
42+
color: 'fg.default',
4143
mr: 3,
4244
lineHeight: 'condensedUltra'
4345
}}
4446
>
45-
<StyledOcticon icon={MarkGithubIcon} size="medium" />
47+
<StyledOcticon icon={MarkGithubIcon} size="24px" />
4648
</Link>
4749
{siteMetadata.header.title ? (
4850
<Link
4951
href={siteMetadata.header.url}
5052
sx={{
51-
color: 'accent.fg',
52-
fontFamily: 'mono',
53+
color: 'fg.default',
54+
fontWeight: 'bold',
5355
display: [
5456
// We only hide "Primer" on small viewports if a shortName is defined.
5557
siteMetadata.shortName ? 'none' : 'inline-block',
@@ -68,8 +70,7 @@ function Header({isSearchEnabled}) {
6870
<Text
6971
sx={{
7072
display: ['none', null, null, 'inline-block'],
71-
color: 'accent.fg',
72-
fontFamily: 'mono',
73+
color: 'fg.default',
7374
mx: 2
7475
}}
7576
>
@@ -80,24 +81,23 @@ function Header({isSearchEnabled}) {
8081
as={GatsbyLink}
8182
to="/"
8283
sx={{
83-
color: 'accent.fg',
84-
fontFamily: 'mono'
84+
fontWeight: 'bold',
85+
color: 'fg.default'
8586
}}
8687
>
8788
{siteMetadata.shortName}
8889
</Link>
8990
</>
9091
) : null}
91-
92-
{isSearchEnabled ? (
93-
<Box sx={{display: ['none', null, null, 'block'], ml: 4}}>
94-
<Search />
95-
</Box>
96-
) : null}
9792
</Box>
9893
<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}
101101
</Box>
102102
<Box sx={{display: ['flex', null, null, 'none']}}>
103103
{isSearchEnabled ? (
@@ -138,48 +138,21 @@ Header.defaultProps = {
138138
isSearchEnabled: true
139139
}
140140

141-
function PrimerNavItems({siteMetadata, items}) {
141+
function PrimerNavItems({siteMetadata, items, path}) {
142142
return (
143143
<>
144144
<VisuallyHidden>
145145
<h3 aria-labelledby="site-header">{siteMetadata.header.title} </h3>
146146
</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'}}>
151148
{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-
166149
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}>
178151
{item.title}
179-
</Link>
152+
</UnderlineNav.Link>
180153
)
181154
})}
182-
</Box>
155+
</UnderlineNav>
183156
</>
184157
)
185158
}

theme/src/components/layout.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ function Layout({children, pageContext, path}) {
7272
return (
7373
<Box sx={{flexDirection: 'column', minHeight: '100vh', display: 'flex'}}>
7474
<Head title={title} description={description} />
75-
<Header />
75+
<Header path={path} />
7676
<Box css={{zIndex: 0}} sx={{flex: '1 1 auto', flexDirection: 'row', display: 'flex'}}>
7777
<Box sx={{display: ['none', null, null, 'block']}}>
7878
<Sidebar />

theme/src/primer-nav.yml

+2-24
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,4 @@
1-
- title: Design
2-
children:
3-
- title: Interface guidelines
4-
url: https://primer.style/design
5-
- title: Octicons
6-
url: https://primer.style/design/foundations/icons
7-
- title: Desktop
8-
url: https://primer.style/design/native/desktop
9-
- title: Mobile
10-
url: https://primer.style/design/native/mobile
11-
- title: CLI
12-
url: https://primer.style/design/native/cli
13-
- title: Build
14-
children:
15-
- title: CSS
16-
url: https://primer.style/css
17-
- title: React
18-
url: https://primer.style/react
19-
- title: React Brand
20-
url: https://primer.style/brand
21-
- title: ViewComponents
22-
url: https://primer.style/view-components
23-
- title: Contribute
24-
url: https://primer.style/design/guides/contribute
1+
- title: Brand
2+
url: https://primer.style/brand
253
- title: About
264
url: https://primer.style/design/guides/about

0 commit comments

Comments
 (0)