Skip to content

Commit 099221c

Browse files
refactor(docs): replace hard-coded z-index with constants for header/search overlay
1 parent 50eda04 commit 099221c

File tree

3 files changed

+10
-5
lines changed

3 files changed

+10
-5
lines changed

src/components/header.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import * as Search from './search'
55
import NavDrawer from './nav-drawer'
66
import Link from './link'
77
import useSearch from '../hooks/use-search'
8-
import {HEADER_HEIGHT, HEADER_BAR} from '../constants'
8+
import {HEADER_HEIGHT, HEADER_BAR, Z_INDEX} from '../constants'
99
import headerNavItems from '../../content/header-nav.yml'
1010
import {DarkTheme} from '../theme'
1111
import SiteTitle from './site-title'
@@ -19,7 +19,7 @@ function Header() {
1919
const search = useSearch()
2020

2121
return (
22-
<DarkTheme sx={{top: 0, position: 'sticky', zIndex: 1}}>
22+
<DarkTheme sx={{top: 0, position: 'sticky', zIndex: Z_INDEX.HEADER}}>
2323
<NpmHeaderBar />
2424
<Box
2525
as="header"

src/components/search.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import {AnimatePresence, motion} from 'framer-motion'
55
import {FocusOn} from 'react-focus-on'
66
import TextInput from './text-input'
77
import useSiteMetadata from '../hooks/use-site-metadata'
8-
import {HEADER_BAR, HEADER_HEIGHT} from '../constants'
8+
import {HEADER_BAR, HEADER_HEIGHT, Z_INDEX} from '../constants'
99
import {LightTheme} from '../theme'
1010
import {LinkNoUnderline} from './link'
1111
import * as getNav from '../util/get-nav'
@@ -132,7 +132,7 @@ export const Mobile = ({
132132
left: 0,
133133
right: 0,
134134
bottom: 0,
135-
zIndex: 1,
135+
zIndex: Z_INDEX.SEARCH_OVERLAY,
136136
}}
137137
>
138138
<Box
@@ -169,7 +169,7 @@ export const Mobile = ({
169169
borderColor: 'border.muted',
170170
position: 'relative',
171171
bg: 'canvas.default',
172-
zIndex: 9999,
172+
zIndex: Z_INDEX.SEARCH_OVERLAY + 1,
173173
}}
174174
>
175175
<motion.div

src/constants.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,8 @@ export const SKIP_TO_CONTENT_ID = 'skip-to-content'
1111
export const SKIP_TO_SEARCH_ID = 'search-box-input'
1212

1313
export const CLI_PATH = '/cli'
14+
15+
export const Z_INDEX = {
16+
HEADER: 10,
17+
SEARCH_OVERLAY: 25
18+
}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy