A drawer component for React.
feat: bring back handle component (#427)
Emil Kowalskic0df14b45ff8
diff --git a/README.md b/README.mdindex d9483ce..754a18d 100644--- a/README.md+++ b/README.md@@ -68,6 +68,8 @@ Additional props:`noBodyStyles`: When `true` the `body` doesn't get any styles assigned from Vaul.+`handleOnly`: When `true` only allows the drawer to be dragged by the `<Drawer.Handle />` component. Defaults to `false`.+`setBackgroundColorOnScale`: When `false` we don't change body's background color when the drawer is open. `true` by default.`defaultOpen`: Opened by default, still reacts to `open` state changes.@@ -121,6 +123,29 @@ export default () => {};```+### Handle++A drag hint (also known as grabber). Shows people that they can drag the drawer; they can also tap it to cycle through the snap points, and double tap quickly to close the drawer.++```jsx+import { Drawer } from 'vaul';++function MyComponent() {+ return (+ <Drawer.Root>+ <Drawer.Trigger>Open</Drawer.Trigger>+ <Drawer.Portal>+ <Drawer.Content>+ <Drawer.Handle />+ <p>Content</p>+ </Drawer.Content>+ <Drawer.Overlay />+ </Drawer.Portal>+ </Drawer.Root>+ );+}+```+### TriggerThe button that opens the dialog. [Props](https://www.radix-ui.com/docs/primitives/components/dialog#trigger).diff --git a/src/context.ts b/src/context.tsindex 4718739..0c7bf62 100644--- a/src/context.ts+++ b/src/context.ts@@ -27,6 +27,7 @@ interface DrawerContextValue {shouldScaleBackground: boolean;setBackgroundColorOnScale: boolean;noBodyStyles: boolean;+ handleOnly?: boolean;container?: HTMLElement | null;}@@ -46,6 +47,7 @@ export const DrawerContext = React.createContext<DrawerContextValue>({keyboardIsOpen: { current: false },snapPointsOffset: null,snapPoints: null,+ handleOnly: false,modal: false,shouldFade: false,activeSnapPoint: null,diff --git a/src/index.tsx b/src/index.tsxindex 1833003..322a2c0 100644--- a/src/index.tsx+++ b/src/index.tsx@@ -44,6 +44,7 @@ export type DialogProps = {setBackgroundColorOnScale?: boolean;scrollLockTimeout?: number;fixed?: boolean;+ handleOnly?: boolean;dismissible?: boolean;onDrag?: (event: React.PointerEvent<HTMLDivElement>, percentageDragged: number) => void;onRelease?: (event: React.PointerEvent<HTMLDivElement>, open: boolean) => void;@@ -71,6 +72,7 @@ export function Root({closeThreshold = CLOSE_THRESHOLD,scrollLockTimeout = SCROLL_LOCK_TIMEOUT,dismissible = true,+ handleOnly = false,fadeFromIndex = snapPoints && snapPoints.length - 1,activeSnapPoint: activeSnapPointProp,setActiveSnapPoint: setActiveSnapPointProp,@@ -635,6 +637,7 @@ export function Root({onRelease,onDrag,dismissible,+ handleOnly,isOpen,isDragging,shouldFade,@@ -698,6 +701,7 @@ export const Content = React.forwardRef<HTMLDivElement, ContentProps>(function (direction,snapPoints,container,+ handleOnly,} = useDrawerContext();// Needed to use transition instead of animationsconst [delayedSnapPoints, setDelayedSnapPoints] = React.useState(false);@@ -757,6 +761,7 @@ export const Content = React.forwardRef<HTMLDivElement, ContentProps>(function (: style}onPointerDown={(event) => {+ if (handleOnly) return;rest.onPointerDown?.(event);pointerStartRef.current = { x: event.clientX, y: event.clientY };onPress(event);@@ -780,6 +785,7 @@ export const Content = React.forwardRef<HTMLDivElement, ContentProps>(function (}}}onPointerMove={(event) => {+ if (handleOnly) return;rest.onPointerMove?.(event);if (!pointerStartRef.current) return;const yPosition = event.clientY - pointerStartRef.current.y;@@ -806,6 +812,114 @@ export const Content = React.forwardRef<HTMLDivElement, ContentProps>(function (Content.displayName = 'Drawer.Content';+export type HandleProps = React.ComponentPropsWithoutRef<'div'> & {+ preventCycle?: boolean;+};++const LONG_HANDLE_PRESS_TIMEOUT = 250;+const DOUBLE_TAP_TIMEOUT = 120;++export const Handle = React.forwardRef<HTMLDivElement, HandleProps>(function (+ { preventCycle = false, children, ...rest },+ ref,+) {+ const {+ closeDrawer,+ isDragging,+ snapPoints,+ activeSnapPoint,+ setActiveSnapPoint,+ dismissible,+ handleOnly,+ isOpen,+ onPress,+ onDrag,+ } = useDrawerContext();++ const closeTimeoutIdRef = React.useRef<number | null>(null);+ const shouldCancelInteractionRef = React.useRef(false);++ function handleStartCycle() {+ // Stop if this is the second click of a double click+ if (shouldCancelInteractionRef.current) {+ handleCancelInteraction();+ return;+ }+ window.setTimeout(() => {+ handleCycleSnapPoints();+ }, DOUBLE_TAP_TIMEOUT);+ }++ function handleCycleSnapPoints() {+ // Prevent accidental taps while resizing drawer+ if (isDragging || preventCycle || shouldCancelInteractionRef.current) {+ handleCancelInteraction();+ return;+ }+ // Make sure to clear the timeout id if the user releases the handle before the cancel timeout+ handleCancelInteraction();++ if ((!snapPoints || snapPoints.length === 0) && dismissible) {+ closeDrawer();+ return;+ }++ const isLastSnapPoint = activeSnapPoint === snapPoints[snapPoints.length - 1];+ if (isLastSnapPoint && dismissible) {+ closeDrawer();+ return;+ }++ const currentSnapIndex = snapPoints.findIndex((point) => point === activeSnapPoint);+ if (currentSnapIndex === -1) return; // activeSnapPoint not found in snapPoints+ const nextSnapPoint = snapPoints[currentSnapIndex + 1];+ setActiveSnapPoint(nextSnapPoint);+ }++ function handleStartInteraction() {+ closeTimeoutIdRef.current = window.setTimeout(() => {+ // Cancel click interaction on a long press+ shouldCancelInteractionRef.current = true;+ }, LONG_HANDLE_PRESS_TIMEOUT);+ }++ function handleCancelInteraction() {+ window.clearTimeout(closeTimeoutIdRef.current);+ shouldCancelInteractionRef.current = false;+ }++ return (+ <div+ onClick={handleStartCycle}+ onDoubleClick={() => {+ shouldCancelInteractionRef.current = true;+ closeDrawer();+ }}+ onPointerCancel={handleCancelInteraction}+ onPointerDown={(e) => {+ if (handleOnly) onPress(e);+ handleStartInteraction();+ }}+ onPointerMove={(e) => {+ if (handleOnly) onDrag(e);+ }}+ // onPointerUp is already handled by the content component+ ref={ref}+ data-vaul-drawer-visible={isOpen ? 'true' : 'false'}+ data-vaul-handle=""+ aria-hidden="true"+ {...rest}+ >+ {/* Expand handle's hit area beyond what's visible to ensure a 44x44 tap target for touch devices */}+ <span data-vaul-handle-hitarea="" aria-hidden="true">+ {children}+ </span>+ </div>+ );+});++Handle.displayName = 'Drawer.Handle';+export function NestedRoot({ onDrag, onOpenChange, ...rest }: DialogProps) {const { onNestedDrag, onNestedOpenChange, onNestedRelease } = useDrawerContext();@@ -850,6 +964,7 @@ export const Drawer = {Overlay,Trigger: DialogPrimitive.Trigger,Portal,+ Handle,Close: DialogPrimitive.Close,Title: DialogPrimitive.Title,Description: DialogPrimitive.Description,diff --git a/src/style.css b/src/style.cssindex 7ce6e4f..a8c77e5 100644--- a/src/style.css+++ b/src/style.css@@ -135,6 +135,47 @@opacity: 1;}+[data-vaul-handle] {+ display: block;+ position: relative;+ opacity: 0.7;+ background: #e2e2e4;+ margin-left: auto;+ margin-right: auto;+ height: 5px;+ width: 32px;+ border-radius: 1rem;+ touch-action: pan-y;+}++[data-vaul-handle]:hover,+[data-vaul-handle]:active {+ opacity: 1;+}++[data-vaul-handle-hitarea] {+ position: absolute;+ left: 50%;+ top: 50%;+ transform: translate(-50%, -50%);+ width: max(100%, 2.75rem); /* 44px */+ height: max(100%, 2.75rem); /* 44px */+ touch-action: inherit;+}++@media (hover: hover) and (pointer: fine) {+ [data-vaul-drawer] {+ user-select: none;+ }+}++@media (pointer: fine) {+ [data-vaul-handle-hitarea]: {+ width: 100%;+ height: 100%;+ }+}+/* This will allow us to not animate via animation, but still benefit from delaying unmount via Radix. */@keyframes fake-animation {from {diff --git a/test/src/app/scrollable-page/page.tsx b/test/src/app/scrollable-page/page.tsxnew file mode 100644index 0000000..e719ef3--- /dev/null+++ b/test/src/app/scrollable-page/page.tsx@@ -0,0 +1,167 @@+'use client';++import { useState } from 'react';+import { Drawer } from 'vaul';++export default function Page() {+ const [open, setOpen] = useState(false);++ return (+ <div+ className="w-screen h-screen bg-white p-8 flex flex-col max-w-sm justify-center items-center"+ data-vaul-drawer-wrapper=""+ >+ <p>+ Aenean lacinia bibendum nulla sed consectetur. Praesent commodo cursus magna, vel scelerisque nisl consectetur+ et. Sed posuere consectetur est at lobortis. Donec ullamcorper nulla non metus auctor fringilla. Maecenas+ faucibus mollis interdum.+ </p>+ <p>+ Aenean lacinia bibendum nulla sed consectetur. Praesent commodo cursus magna, vel scelerisque nisl consectetur+ et. Sed posuere consectetur est at lobortis. Donec ullamcorper nulla non metus auctor fringilla. Maecenas+ faucibus mollis interdum.+ </p>+ <p>+ Aenean lacinia bibendum nulla sed consectetur. Praesent commodo cursus magna, vel scelerisque nisl consectetur+ et. Sed posuere consectetur est at lobortis. Donec ullamcorper nulla non metus auctor fringilla. Maecenas+ faucibus mollis interdum.+ </p>+ <p>+ Aenean lacinia bibendum nulla sed consectetur. Praesent commodo cursus magna, vel scelerisque nisl consectetur+ et. Sed posuere consectetur est at lobortis. Donec ullamcorper nulla non metus auctor fringilla. Maecenas+ faucibus mollis interdum.+ </p>+ <p>+ Aenean lacinia bibendum nulla sed consectetur. Praesent commodo cursus magna, vel scelerisque nisl consectetur+ et. Sed posuere consectetur est at lobortis. Donec ullamcorper nulla non metus auctor fringilla. Maecenas+ faucibus mollis interdum.+ </p>+ <p>+ Aenean lacinia bibendum nulla sed consectetur. Praesent commodo cursus magna, vel scelerisque nisl consectetur+ et. Sed posuere consectetur est at lobortis. Donec ullamcorper nulla non metus auctor fringilla. Maecenas+ faucibus mollis interdum.+ </p>+ <p>+ Aenean lacinia bibendum nulla sed consectetur. Praesent commodo cursus magna, vel scelerisque nisl consectetur+ et. Sed posuere consectetur est at lobortis. Donec ullamcorper nulla non metus auctor fringilla. Maecenas+ faucibus mollis interdum.+ </p>+ <p>+ Aenean lacinia bibendum nulla sed consectetur. Praesent commodo cursus magna, vel scelerisque nisl consectetur+ et. Sed posuere consectetur est at lobortis. Donec ullamcorper nulla non metus auctor fringilla. Maecenas+ faucibus mollis interdum.+ </p>+ <p>+ Aenean lacinia bibendum nulla sed consectetur. Praesent commodo cursus magna, vel scelerisque nisl consectetur+ et. Sed posuere consectetur est at lobortis. Donec ullamcorper nulla non metus auctor fringilla. Maecenas+ faucibus mollis interdum.+ </p>+ <p>+ Aenean lacinia bibendum nulla sed consectetur. Praesent commodo cursus magna, vel scelerisque nisl consectetur+ et. Sed posuere consectetur est at lobortis. Donec ullamcorper nulla non metus auctor fringilla. Maecenas+ faucibus mollis interdum.+ </p>+ <p>+ Aenean lacinia bibendum nulla sed consectetur. Praesent commodo cursus magna, vel scelerisque nisl consectetur+ et. Sed posuere consectetur est at lobortis. Donec ullamcorper nulla non metus auctor fringilla. Maecenas+ faucibus mollis interdum.+ </p>+ <Drawer.Root open={open} onOpenChange={setOpen}>+ <Drawer.Trigger asChild onClick={() => setOpen(true)}>+ <button data-testid="trigger" className="text-2xl">+ Open Drawer+ </button>+ </Drawer.Trigger>+ <Drawer.Portal>+ <Drawer.Overlay data-testid="overlay" className="fixed inset-0 bg-black/40" />+ <Drawer.Content+ data-testid="content"+ className="bg-zinc-100 flex flex-col rounded-t-[10px] h-[96%] mt-24 fixed bottom-0 left-0 right-0"+ >+ <Drawer.Close data-testid="drawer-close">Close</Drawer.Close>+ <button data-testid="controlled-close" onClick={() => setOpen(false)} className="text-2xl">+ Close+ </button>+ <div className="p-4 bg-white rounded-t-[10px] flex-1">+ <div className="mx-auto w-12 h-1.5 flex-shrink-0 rounded-full bg-zinc-300 mb-8" />+ <div className="max-w-md mx-auto">+ <Drawer.Title className="font-medium mb-4">Unstyled drawer for React.</Drawer.Title>+ <p className="text-zinc-600 mb-2">+ This component can be used as a replacement for a Dialog on mobile and tablet devices.+ </p>+ <p className="text-zinc-600 mb-8">+ It uses{' '}+ <a+ href="https://www.radix-ui.com/docs/primitives/components/dialog"+ className="underline"+ target="_blank"+ >+ Radix's Dialog primitive+ </a>{' '}+ under the hood and is inspired by{' '}+ <a+ href="https://twitter.com/devongovett/status/1674470185783402496"+ className="underline"+ target="_blank"+ >+ this tweet.+ </a>+ </p>+ </div>+ </div>+ <div className="p-4 bg-zinc-100 border-t border-zinc-200 mt-auto">+ <div className="flex gap-6 justify-end max-w-md mx-auto">+ <a+ className="text-xs text-zinc-600 flex items-center gap-0.25"+ href="https://github.com/emilkowalski/vaul"+ target="_blank"+ >+ GitHub+ <svg+ fill="none"+ height="16"+ stroke="currentColor"+ strokeLinecap="round"+ strokeLinejoin="round"+ strokeWidth="2"+ viewBox="0 0 24 24"+ width="16"+ aria-hidden="true"+ className="w-3 h-3 ml-1"+ >+ <path d="M18 13v6a2 2 0 01-2 2H5a2 2 0 01-2-2V8a2 2 0 012-2h6"></path>+ <path d="M15 3h6v6"></path>+ <path d="M10 14L21 3"></path>+ </svg>+ </a>+ <a+ className="text-xs text-zinc-600 flex items-center gap-0.25"+ href="https://twitter.com/emilkowalski_"+ target="_blank"+ >+ <svg+ fill="none"+ height="16"+ stroke="currentColor"+ strokeLinecap="round"+ strokeLinejoin="round"+ strokeWidth="2"+ viewBox="0 0 24 24"+ width="16"+ aria-hidden="true"+ className="w-3 h-3 ml-1"+ >+ <path d="M18 13v6a2 2 0 01-2 2H5a2 2 0 01-2-2V8a2 2 0 012-2h6"></path>+ <path d="M15 3h6v6"></path>+ <path d="M10 14L21 3"></path>+ </svg>+ </a>+ </div>+ </div>+ </Drawer.Content>+ </Drawer.Portal>+ </Drawer.Root>+ </div>+ );+}diff --git a/test/src/app/with-handle/page.tsx b/test/src/app/with-handle/page.tsxnew file mode 100644index 0000000..e90d208--- /dev/null+++ b/test/src/app/with-handle/page.tsx@@ -0,0 +1,156 @@+'use client';++import { clsx } from 'clsx';+import { useState } from 'react';+import { Drawer } from 'vaul';++const snapPoints = ['148px', '355px'];++export default function Page() {+ const [snap, setSnap] = useState<number | string | null>(snapPoints[0]);++ const activeSnapPointIndex = snapPoints.indexOf(snap as string);++ return (+ <div className="w-screen h-screen bg-white p-8 flex justify-center items-center">+ <div data-testid="active-snap-index">{activeSnapPointIndex}</div>+ <Drawer.Root open snapPoints={snapPoints} activeSnapPoint={snap} setActiveSnapPoint={setSnap}>+ <Drawer.Trigger asChild>+ <button data-testid="trigger">Open Drawer</button>+ </Drawer.Trigger>+ <Drawer.Overlay className="fixed inset-0 bg-black/40" />+ <Drawer.Portal>+ <Drawer.Content+ data-testid="content"+ className="fixed flex flex-col bg-white border border-gray-200 border-b-none rounded-t-[10px] bottom-0 left-0 right-0 h-full max-h-[97%] mx-[-1px]"+ >+ <Drawer.Handle data-testid="handle" className="mb-8 mt-2" />+ <div+ className={clsx('flex flex-col max-w-md mx-auto w-full p-4 pt-5', {+ 'overflow-y-auto': snap === 1,+ 'overflow-hidden': snap !== 1,+ })}+ >+ <div className="flex items-center">+ <svg+ className="text-yellow-400 h-5 w-5 flex-shrink-0"+ viewBox="0 0 20 20"+ fill="currentColor"+ aria-hidden="true"+ >+ <path+ fill-rule="evenodd"+ d="M10.868 2.884c-.321-.772-1.415-.772-1.736 0l-1.83 4.401-4.753.381c-.833.067-1.171 1.107-.536 1.651l3.62 3.102-1.106 4.637c-.194.813.691 1.456 1.405 1.02L10 15.591l4.069 2.485c.713.436 1.598-.207 1.404-1.02l-1.106-4.637 3.62-3.102c.635-.544.297-1.584-.536-1.65l-4.752-.382-1.831-4.401z"+ clip-rule="evenodd"+ ></path>+ </svg>+ <svg+ className="text-yellow-400 h-5 w-5 flex-shrink-0"+ viewBox="0 0 20 20"+ fill="currentColor"+ aria-hidden="true"+ >+ <path+ fill-rule="evenodd"+ d="M10.868 2.884c-.321-.772-1.415-.772-1.736 0l-1.83 4.401-4.753.381c-.833.067-1.171 1.107-.536 1.651l3.62 3.102-1.106 4.637c-.194.813.691 1.456 1.405 1.02L10 15.591l4.069 2.485c.713.436 1.598-.207 1.404-1.02l-1.106-4.637 3.62-3.102c.635-.544.297-1.584-.536-1.65l-4.752-.382-1.831-4.401z"+ clip-rule="evenodd"+ ></path>+ </svg>+ <svg+ className="text-yellow-400 h-5 w-5 flex-shrink-0"+ viewBox="0 0 20 20"+ fill="currentColor"+ aria-hidden="true"+ >+ <path+ fill-rule="evenodd"+ d="M10.868 2.884c-.321-.772-1.415-.772-1.736 0l-1.83 4.401-4.753.381c-.833.067-1.171 1.107-.536 1.651l3.62 3.102-1.106 4.637c-.194.813.691 1.456 1.405 1.02L10 15.591l4.069 2.485c.713.436 1.598-.207 1.404-1.02l-1.106-4.637 3.62-3.102c.635-.544.297-1.584-.536-1.65l-4.752-.382-1.831-4.401z"+ clip-rule="evenodd"+ ></path>+ </svg>+ <svg+ className="text-yellow-400 h-5 w-5 flex-shrink-0"+ viewBox="0 0 20 20"+ fill="currentColor"+ aria-hidden="true"+ >+ <path+ fill-rule="evenodd"+ d="M10.868 2.884c-.321-.772-1.415-.772-1.736 0l-1.83 4.401-4.753.381c-.833.067-1.171 1.107-.536 1.651l3.62 3.102-1.106 4.637c-.194.813.691 1.456 1.405 1.02L10 15.591l4.069 2.485c.713.436 1.598-.207 1.404-1.02l-1.106-4.637 3.62-3.102c.635-.544.297-1.584-.536-1.65l-4.752-.382-1.831-4.401z"+ clip-rule="evenodd"+ ></path>+ </svg>+ <svg+ className="text-gray-300 h-5 w-5 flex-shrink-0"+ viewBox="0 0 20 20"+ fill="currentColor"+ aria-hidden="true"+ >+ <path+ fill-rule="evenodd"+ d="M10.868 2.884c-.321-.772-1.415-.772-1.736 0l-1.83 4.401-4.753.381c-.833.067-1.171 1.107-.536 1.651l3.62 3.102-1.106 4.637c-.194.813.691 1.456 1.405 1.02L10 15.591l4.069 2.485c.713.436 1.598-.207 1.404-1.02l-1.106-4.637 3.62-3.102c.635-.544.297-1.584-.536-1.65l-4.752-.382-1.831-4.401z"+ clip-rule="evenodd"+ ></path>+ </svg>+ </div>{' '}+ <h1 className="text-2xl mt-2 font-medium">The Hidden Details</h1>+ <p className="text-sm mt-1 text-gray-600 mb-6">2 modules, 27 hours of video</p>+ <p className="text-gray-600">+ The world of user interface design is an intricate landscape filled with hidden details and nuance. In+ this course, you will learn something cool. To the untrained eye, a beautifully designed UI.+ </p>+ <button className="bg-black text-gray-50 mt-8 rounded-md h-[48px] flex-shrink-0 font-medium">+ Buy for $199+ </button>+ <div className="mt-12">+ <h2 className="text-xl font-medium">Module 01. The Details</h2>+ <div className="space-y-4 mt-4">+ <div>+ <span className="block">Layers of UI</span>+ <span className="text-gray-600">A basic introduction to Layers of Design.</span>+ </div>+ <div>+ <span className="block">Typography</span>+ <span className="text-gray-600">The fundamentals of type.</span>+ </div>+ <div>+ <span className="block">UI Animations</span>+ <span className="text-gray-600">Going through the right easings and durations.</span>+ </div>+ </div>+ </div>+ <div className="mt-12">+ <figure>+ <blockquote className="font-serif">+ “I especially loved the hidden details video. That was so useful, learned a lot by just reading it.+ Can’t wait for more course content!”+ </blockquote>+ <figcaption>+ <span className="text-sm text-gray-600 mt-2 block">Yvonne Ray, Frontend Developer</span>+ </figcaption>+ </figure>+ </div>+ <div className="mt-12">+ <h2 className="text-xl font-medium">Module 02. The Process</h2>+ <div className="space-y-4 mt-4">+ <div>+ <span className="block">Build</span>+ <span className="text-gray-600">Create cool components to practice.</span>+ </div>+ <div>+ <span className="block">User Insight</span>+ <span className="text-gray-600">Find out what users think and fine-tune.</span>+ </div>+ <div>+ <span className="block">Putting it all together</span>+ <span className="text-gray-600">Let's build an app together and apply everything.</span>+ </div>+ </div>+ </div>+ </div>+ </Drawer.Content>+ </Drawer.Portal>+ </Drawer.Root>+ </div>+ );+}diff --git a/test/tests/with-handle.spec.ts b/test/tests/with-handle.spec.tsnew file mode 100644index 0000000..286e36d--- /dev/null+++ b/test/tests/with-handle.spec.ts@@ -0,0 +1,32 @@+import { test, expect } from '@playwright/test';+import { ANIMATION_DURATION } from './constants';++test.beforeEach(async ({ page }) => {+ await page.goto('/with-handle');+});++test.describe('With handle', () => {+ test('click should cycle to the next snap point', async ({ page }) => {+ await page.waitForTimeout(ANIMATION_DURATION);++ await expect(page.getByTestId('content')).toBeVisible();+ await expect(page.getByTestId('active-snap-index')).toHaveText('0');++ await page.getByTestId('handle').click();+ await expect(page.getByTestId('active-snap-index')).toHaveText('1');++ await page.getByTestId('handle').click();+ await expect(page.getByTestId('content')).not.toBeVisible();+ });++ test('double click should close the drawer', async ({ page }) => {+ await page.waitForTimeout(ANIMATION_DURATION);++ await expect(page.getByTestId('content')).toBeVisible();+ await expect(page.getByTestId('active-snap-index')).toHaveText('0');+ await page.getByTestId('handle').dispatchEvent('dblclick');++ await page.waitForTimeout(ANIMATION_DURATION);+ await expect(page.getByTestId('content')).not.toBeVisible();+ });+});diff --git a/website/src/app/test-modal/_page/hero.tsx b/website/src/app/test-modal/_page/hero.tsxdeleted file mode 100644index 31f72a3..0000000--- a/website/src/app/test-modal/_page/hero.tsx+++ /dev/null@@ -1,196 +0,0 @@-'use client';-import React, { useState } from 'react'-import { Drawer } from 'vaul'--export function Hero() {-- const [open, setOpen] = useState<boolean>(false)- const [modal, setModal] = useState<boolean>(true)-- return (- <div className='relative'>- <div- aria-hidden- className='absolute top-0 w-[1000px] z-10 h-[400px] left-1/2 -translate-x-1/2 -translate-y-1/2 opacity-[0.15] pointer-events-none'- style={{ backgroundImage: 'radial-gradient(#A4A4A3, transparent 50%)' }}- />- <svg- className='absolute pointer-events-none inset-0 h-full w-full stroke-gray-200 opacity-50 [mask-image:radial-gradient(100%_100%_at_top_center,white,transparent)]'- aria-hidden- >- <defs>- <pattern- id='83fd4e5a-9d52-42fc-97b6-718e5d7ee527'- width={200}- height={200}- x='50%'- y={-1}- patternUnits='userSpaceOnUse'- >- <path d='M100 200V.5M.5 .5H200' fill='none' />- </pattern>- </defs>- <svg x='50%' y={-1} className='overflow-visible fill-gray-50'>- <path- d='M-100.5 0h201v201h-201Z M699.5 0h201v201h-201Z M499.5 400h201v201h-201Z M-300.5 600h201v201h-201Z'- strokeWidth={0}- />- </svg>- <rect width='100%' height='100%' strokeWidth={0} fill='url(#83fd4e5a-9d52-42fc-97b6-718e5d7ee527)' />- </svg>- <div className='max-w-2xl mx-auto text-center pt-50'>- <div className='flex flex-col relative'>- <h1 className='text-7xl font-semibold mb-4 relative'>Vaul</h1>- <p className='text-gray-600 text-xl'>Drawer component for React.</p>- </div>- <div className='flex gap-4 justify-center mt-6'>- <button- type='button'- className='rounded-full bg-white px-4 py-2.5 text-sm font-medium text-gray-900 shadow-sm ring-1 ring-inset ring-gray-300 hover:bg-gray-50'- onClick={() => {setOpen(true)}}- >- Open Drawer- </button>- <button- type='button'- className='border border-gray-800 w-[200px] rounded-full bg-white px-4 py-2.5 text-sm font-medium text-gray-900 shadow-sm ring-1 ring-inset ring-gray-300 hover:bg-gray-50'- onClick={() => {console.log("DO NOTHING CLICKED!")}}- >- Does nothing- </button>- <a- href='https://github.com/emilkowalski/vaul'- className='font-medium text-sm px-4 py-2.5 hover:bg-gray-100 rounded-full'- target='_blank'- >- GitHub <span aria-hidden='true'>→</span>- </a>- <Drawer.Root open={open} onOpenChange={setOpen} modal={modal} >- <Drawer.Portal>- <Drawer.Overlay className='fixed inset-0 bg-black/40' />- <Drawer.Content className={- 'flex flex-col ' +- 'bg-gray-100 rounded-t-[10px] ' +- 'border border-gray-800 ' +- 'mt-24 ' +- 'h-[60%] max-h-[96%] ' +- 'fixed bottom-0 left-0 right-0 ' +- 'md:max-w-[550px] md:mx-auto lg:max-w-[50vw]'- }>- <div className='p-4 bg-white rounded-t-[10px] flex-1'>- <div className='mx-auto w-12 h-1.5 flex-shrink-0 rounded-full bg-gray-300 mb-8' />- <div className='max-w-md mx-auto flex flex-col items-center'>- <Drawer.Title className='font-medium mb-4'>- {`Drawer for React: ${modal ? '' : 'NON-'}MODAL`}- </Drawer.Title>- <button- type='button'- className={- 'self-center block my-5 ' +- 'border border-gray-800 ' +- 'rounded-full bg-white px-4 py-2.5 text-sm font-medium text-gray-900 shadow-sm ring-1 ring-inset ring-gray-300 hover:bg-gray-50'- }- onClick={() => {setModal(!modal)}}- >- {`Make ${modal ? 'non-' : ''}modal`}- </button>-- <p className='text-gray-600 mb-2'>- This component can be used as a Dialog replacement on mobile and tablet devices. You can read- about why and how it was built{' '}- <a- target='_blank'- className='underline'- href='https://emilkowal.ski/ui/building-a-drawer-component'- >- here- </a>- .- </p>- <p className='text-gray-600 mb-2'>- It comes unstyled, has gesture-driven animations, and is made by{' '}- <a href='https://emilkowal.ski/' className='underline' target='_blank'>- Emil Kowalski- </a>- .- </p>- <p className='text-gray-600 mb-8'>- It uses{' '}- <a- href='https://www.radix-ui.com/docs/primitives/components/dialog'- className='underline'- target='_blank'- >- Radix's Dialog primitive- </a>{' '}- under the hood and is inspired by{' '}- <a- href='https://twitter.com/devongovett/status/1674470185783402496'- className='underline'- target='_blank'- >- this tweet.- </a>- </p>- </div>- </div>- <div className='p-4 bg-gray-100 border-t border-gray-200 mt-auto'>- <div className='flex gap-6 justify-end max-w-md mx-auto'>- <a- className='text-xs text-gray-600 flex items-center gap-0.25'- href='https://github.com/emilkowalski/vaul'- target='_blank'- >- GitHub- <svg- fill='none'- height='16'- stroke='currentColor'- strokeLinecap='round'- strokeLinejoin='round'- strokeWidth='2'- viewBox='0 0 24 24'- width='16'- aria-hidden='true'- className='w-3 h-3 ml-1'- >- <path d='M18 13v6a2 2 0 01-2 2H5a2 2 0 01-2-2V8a2 2 0 012-2h6'></path>- <path d='M15 3h6v6'></path>- <path d='M10 14L21 3'></path>- </svg>- </a>- <a- className='text-xs text-gray-600 flex items-center gap-0.25'- href='https://twitter.com/emilkowalski_'- target='_blank'- >- <svg- fill='none'- height='16'- stroke='currentColor'- strokeLinecap='round'- strokeLinejoin='round'- strokeWidth='2'- viewBox='0 0 24 24'- width='16'- aria-hidden='true'- className='w-3 h-3 ml-1'- >- <path d='M18 13v6a2 2 0 01-2 2H5a2 2 0 01-2-2V8a2 2 0 012-2h6'></path>- <path d='M15 3h6v6'></path>- <path d='M10 14L21 3'></path>- </svg>- </a>- </div>- </div>--- </Drawer.Content>- </Drawer.Portal>- </Drawer.Root>- </div>- </div>- </div>- );-}diff --git a/website/src/app/test-modal/page.tsx b/website/src/app/test-modal/page.tsxdeleted file mode 100644index 6ef73e5..0000000--- a/website/src/app/test-modal/page.tsx+++ /dev/null@@ -1,11 +0,0 @@--import { Hero } from './_page/hero';---export default function Home() {- return (- <div className="antialiased">- <Hero />- </div>- );-}