Skip to content

Commit ff913c5

Browse files
committed
use DialogPanel and drop Dialog.Overlay
1 parent 943c12e commit ff913c5

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed

src/components/Header.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { VersionSwitcher } from '@/components/VersionSwitcher'
33
import { SearchButton } from '@/components/Search'
44
import Router from 'next/router'
55
import { Logo } from '@/components/Logo'
6-
import { Dialog } from '@headlessui/react'
6+
import { Dialog, DialogPanel } from '@headlessui/react'
77
import { useEffect, useState } from 'react'
88
import clsx from 'clsx'
99
import { ThemeSelect, ThemeToggle } from './ThemeToggle'
@@ -77,8 +77,8 @@ export function NavPopover({ display = 'md:hidden', className, ...props }) {
7777
</svg>
7878
</button>
7979
<Dialog open={isOpen} onClose={setIsOpen} className={clsx('fixed z-50 inset-0', display)}>
80-
<Dialog.Overlay className="fixed inset-0 bg-black/20 backdrop-blur-sm dark:bg-slate-900/80" />
81-
<div className="fixed top-4 right-4 w-full max-w-xs bg-white rounded-lg shadow-lg p-6 text-base font-semibold text-slate-900 dark:bg-slate-800 dark:text-slate-400 dark:highlight-white/5">
80+
<div className="fixed inset-0 bg-black/20 backdrop-blur-sm dark:bg-slate-900/80" />
81+
<DialogPanel className="fixed top-4 right-4 w-full max-w-xs bg-white rounded-lg shadow-lg p-6 text-base font-semibold text-slate-900 dark:bg-slate-800 dark:text-slate-400 dark:highlight-white/5">
8282
<button
8383
type="button"
8484
className="absolute top-5 right-5 w-8 h-8 flex items-center justify-center text-slate-500 hover:text-slate-600 dark:text-slate-400 dark:hover:text-slate-300"
@@ -109,7 +109,7 @@ export function NavPopover({ display = 'md:hidden', className, ...props }) {
109109
<div className="mt-6 pt-6 border-t border-slate-200 dark:border-slate-200/10">
110110
<ThemeSelect />
111111
</div>
112-
</div>
112+
</DialogPanel>
113113
</Dialog>
114114
</div>
115115
)

src/layouts/SidebarLayout.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { createContext, forwardRef, useRef } from 'react'
44
import { useIsomorphicLayoutEffect } from '@/hooks/useIsomorphicLayoutEffect'
55
import clsx from 'clsx'
66
import { SearchButton } from '@/components/Search'
7-
import { Dialog } from '@headlessui/react'
7+
import { Dialog, DialogPanel } from '@headlessui/react'
88

99
export const SidebarContext = createContext()
1010

@@ -28,7 +28,7 @@ const NavItem = forwardRef(({ href, children, isActive, isPublished, fallbackHre
2828
})
2929

3030
/**
31-
* Find the nearst scrollable ancestor (or self if scrollable)
31+
* Find the nearest scrollable ancestor (or self if scrollable)
3232
*
3333
* Code adapted and simplified from the smoothscroll polyfill
3434
*
@@ -534,8 +534,8 @@ export function SidebarLayout({
534534
onClose={() => setNavIsOpen(false)}
535535
className="fixed z-50 inset-0 overflow-y-auto lg:hidden"
536536
>
537-
<Dialog.Overlay className="fixed inset-0 bg-black/20 backdrop-blur-sm dark:bg-slate-900/80" />
538-
<div className="relative bg-white w-80 max-w-[calc(100%-3rem)] p-6 dark:bg-slate-800">
537+
<div className="fixed inset-0 bg-black/20 backdrop-blur-sm dark:bg-slate-900/80" />
538+
<DialogPanel className="relative bg-white w-80 max-w-[calc(100%-3rem)] p-6 dark:bg-slate-800">
539539
<button
540540
type="button"
541541
onClick={() => setNavIsOpen(false)}
@@ -555,7 +555,7 @@ export function SidebarLayout({
555555
<Nav nav={nav} fallbackHref={fallbackHref} mobile={true}>
556556
{sidebar}
557557
</Nav>
558-
</div>
558+
</DialogPanel>
559559
</Dialog>
560560
</SidebarContext.Provider>
561561
)

0 commit comments

Comments
 (0)