Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add zIndex property #78

Merged
merged 3 commits into from
Nov 1, 2024
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: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.

## [Unreleased]

### Added

- Add `zIndex` as a property argument to control the drawer's z-index

## [0.17.2] - 2024-08-13

### Added
Expand Down
5 changes: 4 additions & 1 deletion react/Drawer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ interface Props {
customPixelEventId?: PixelData['id']
customPixelEventName?: PixelData['event']
onVisibilityChanged?: (visible: boolean) => void
zIndex?: number
}

function menuReducer(state: MenuState, action: MenuAction) {
Expand Down Expand Up @@ -128,6 +129,7 @@ function Drawer(props: Props) {
customPixelEventId,
customPixelEventName,
onVisibilityChanged,
zIndex = 999,
} = props
const handles = useCssHandles(CSS_HANDLES)
const backdropMode = useResponsiveValue(backdropModeProp)
Expand Down Expand Up @@ -203,7 +205,7 @@ function Drawer(props: Props) {
)}
</div>
<Portal>
<Overlay visible={overlayVisible} onClick={closeMenu} />
<Overlay visible={overlayVisible} onClick={closeMenu} zIndex={zIndex} />
<Suspense fallback={<React.Fragment />}>
<Swipable
{...{
Expand All @@ -225,6 +227,7 @@ function Drawer(props: Props) {
maxWidth,
minWidth: 280,
pointerEvents: isMenuOpen ? 'auto' : 'none',
zIndex,
}}
>
<div
Expand Down
4 changes: 3 additions & 1 deletion react/Overlay.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,13 @@ import { useCssHandles, applyModifiers } from 'vtex.css-handles'
interface Props {
visible: boolean
onClick(event: React.MouseEvent | React.TouchEvent): void
zIndex?: number
}

const CSS_HANDLES = ['overlay'] as const

const Overlay: RefForwardingComponent<HTMLDivElement, Props> = (
{ visible, onClick }: Props,
{ visible, onClick, zIndex = 999 }: Props,
ref
) => {
const handles = useCssHandles(CSS_HANDLES)
Expand All @@ -23,6 +24,7 @@ const Overlay: RefForwardingComponent<HTMLDivElement, Props> = (
style={{
opacity: visible ? 0.5 : 0,
pointerEvents: visible ? 'auto' : 'none',
zIndex,
}}
className={`${applyModifiers(
handles.overlay,
Expand Down
Loading