Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/components/header.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import * as Search from './search'
import NavDrawer from './nav-drawer'
import Link from './link'
import useSearch from '../hooks/use-search'
import {HEADER_HEIGHT, HEADER_BAR} from '../constants'
import {HEADER_HEIGHT, HEADER_BAR, Z_INDEX} from '../constants'
import headerNavItems from '../../content/header-nav.yml'
import {DarkTheme} from '../theme'
import SiteTitle from './site-title'
Expand All @@ -19,7 +19,7 @@ function Header() {
const search = useSearch()

return (
<DarkTheme sx={{top: 0, position: 'sticky', zIndex: 1}}>
<DarkTheme sx={{top: 0, position: 'sticky', zIndex: Z_INDEX.HEADER}}>
<NpmHeaderBar />
<Box
as="header"
Expand Down
19 changes: 14 additions & 5 deletions src/components/search.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {AnimatePresence, motion} from 'framer-motion'
import {FocusOn} from 'react-focus-on'
import TextInput from './text-input'
import useSiteMetadata from '../hooks/use-site-metadata'
import {HEADER_BAR, HEADER_HEIGHT} from '../constants'
import {HEADER_BAR, HEADER_HEIGHT, Z_INDEX} from '../constants'
import {LightTheme} from '../theme'
import {LinkNoUnderline} from './link'
import * as getNav from '../util/get-nav'
Expand Down Expand Up @@ -106,11 +106,18 @@ export const Mobile = ({
const siteMetadata = useSiteMetadata()
const getCloseAnimation = exit => (isForceClose ? undefined : {exit})

const handleSearchToggle = React.useCallback(() => {
setMobileSearchOpen(true)
}, [setMobileSearchOpen])

return (
<>
<Button aria-label="Search" aria-expanded={isMobileSearchOpen} onClick={() => setMobileSearchOpen(true)}>
<SearchIcon />
</Button>
{!isMobileSearchOpen && (
<Button aria-label="Search" aria-expanded={isMobileSearchOpen} onClick={handleSearchToggle}>
<SearchIcon />
</Button>
)}

<AnimatePresence>
{isMobileSearchOpen ? (
<FocusOn returnFocus={true} onEscapeKey={() => resetAndClose(true)}>
Expand All @@ -121,7 +128,7 @@ export const Mobile = ({
left: 0,
right: 0,
bottom: 0,
zIndex: 1,
zIndex: Z_INDEX.SEARCH_OVERLAY,
}}
>
<Box
Expand Down Expand Up @@ -157,6 +164,8 @@ export const Mobile = ({
borderRightWidth: 0,
borderColor: 'border.muted',
position: 'relative',
bg: 'canvas.default',
zIndex: Z_INDEX.SEARCH_OVERLAY + 1,
}}
>
<motion.div
Expand Down
5 changes: 5 additions & 0 deletions src/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,8 @@ export const SKIP_TO_CONTENT_ID = 'skip-to-content'
export const SKIP_TO_SEARCH_ID = 'search-box-input'

export const CLI_PATH = '/cli'

export const Z_INDEX = {
HEADER: 10,
SEARCH_OVERLAY: 25,
}
Loading