Skip to content

armgit / vaul

Public Imported from GitHub
0

A drawer component for React.

Update readme

emilkowalski25b30ffe686d
diff --git a/README.md b/README.md
index 4ca0f96..b45ff29 100644
--- a/README.md
+++ b/README.md
@@ -48,8 +48,6 @@ Can be controlled with the `value` and `onOpenChange` props. Can be opened by de
Additional props:
-`fixedHeight`: Height won't be auto adjusted when the `visualViewportHeight` changes.
-
`closeTreshold`: Number between 0 and 1 that determines when the drawer should be closed. Example: `closeTreshold`` of 0.5 would close the drawer if the user swiped for 50% of the height of the drawer or more.
### Trigger
@@ -60,6 +58,10 @@ The button that opens the dialog. [Props](https://www.radix-ui.com/docs/primitiv
Content that should be rendered in the drawer. [Props](https://www.radix-ui.com/docs/primitives/components/dialog#content).
+Additional props:
+
+`onAnimationEnd (open: boolean) => void`: Runs after enter or exit animation ends. Useful to reset the state and avoid flash of a different content when animating out.
+
### Overlay
A layer that covers the inert portion of the view when the dialog is open. [Props](https://www.radix-ui.com/docs/primitives/components/dialog#overlay).
diff --git a/website/src/app/components/hero.tsx b/website/src/app/components/hero.tsx
index ef1552c..0582355 100644
--- a/website/src/app/components/hero.tsx
+++ b/website/src/app/components/hero.tsx
@@ -4,7 +4,7 @@ import { Drawer } from 'vaul';
export function Hero() {
return (
- <div className="relative h-[200vh]">
+ <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"
@@ -40,7 +40,7 @@ export function Hero() {
<p className="text-gray-600 text-xl">Drawer component for React.</p>
</div>
<div className="flex gap-4 justify-center mt-6">
- <Drawer.Root>
+ <Drawer.Root shouldScaleBackground>
<Drawer.Trigger asChild>
<button
type="button"
@@ -51,11 +51,84 @@ export function Hero() {
</Drawer.Trigger>
<Drawer.Overlay className="fixed inset-0 bg-black/40" />
<Drawer.Portal>
- <Drawer.Content className="bg-white flex flex-col fixed bottom-0 left-0 right-0 max-h-[50vh] rounded-t-[10px]">
- <div className="max-w-md w-full mx-auto flex flex-col overflow-auto p-4 rounded-t-[10px]">
- <input className="border border-gray-400 my-8" placeholder="Input" />
-
- <input className="border border-gray-400 my-8" placeholder="Input" />
+ <Drawer.Content className="bg-gray-100 flex flex-col rounded-t-[10px] h-full mt-24 max-h-[96%] fixed bottom-0 left-0 right-0">
+ <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">
+ <Drawer.Title className="font-medium mb-4">Drawer for React.</Drawer.Title>
+ <p className="text-gray-600 mb-2">
+ This component can be used as a Dialog replacement on mobile and tablet devices.
+ </p>
+ <p className="text-gray-600 mb-2">It comes unstyled and has gesture-driven animations.</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"
+ stroke-linecap="round"
+ stroke-linejoin="round"
+ stroke-width="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"
+ >
+ Twitter
+ <svg
+ fill="none"
+ height="16"
+ stroke="currentColor"
+ stroke-linecap="round"
+ stroke-linejoin="round"
+ stroke-width="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>