Skip to content

Commit

Permalink
Merge branch 'main' into update-imports
Browse files Browse the repository at this point in the history
  • Loading branch information
rortan134 committed May 7, 2024
2 parents 7a894d1 + 40d3a69 commit b443dc9
Show file tree
Hide file tree
Showing 22 changed files with 1,971 additions and 1,007 deletions.
20 changes: 18 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ function MyComponent() {
<Drawer.Trigger>Open</Drawer.Trigger>
<Drawer.Portal>
<Drawer.Content>
<Drawer.Handle />
<p>Content</p>
</Drawer.Content>
<Drawer.Overlay />
Expand All @@ -41,6 +42,7 @@ Play around with the examples on codesandbox:
- [Drawer from right instead of bottom](https://codesandbox.io/p/devbox/drawer-direction-right-n338ml?file=%2Fapp%2Fmy-drawer.tsx%3A47%2C2)
- [Nested drawers](https://codesandbox.io/p/sandbox/drawer-non-dismissable-forked-5z2r3j?file=%2Fapp%2Fmy-drawer.tsx%3A49%2C16-49%2C246)
- [Non-dismissible](https://codesandbox.io/p/sandbox/drawer-without-scale-forked-kxh9j5?file=%2Fapp%2Fmy-drawer.tsx%3A1%2C1)
- [Non-draggable element](https://codesandbox.io/p/devbox/drawer-with-scale-forked-hwtfws?file=%2Fapp%2Fmy-drawer.tsx%3A42%2C37)

## API Reference

Expand All @@ -53,18 +55,28 @@ Additional props:

`closeThreshold`: Number between 0 and 1 that determines when the drawer should be closed. Example: threshold of 0.5 would close the drawer if the user swiped for 50% of the height of the drawer or more.

`scrollLockTimeout`: Duration for which the drawer is not draggable after scrolling content inside of the drawer. Defaults to 500ms
`scrollLockTimeout`: Duration for which the drawer is not draggable after scrolling content inside of the drawer. Defaults to 500ms.

`snapPoints`: Array of numbers from 0 to 100 that corresponds to % of the screen a given snap point should take up. Should go from least visible. Example `[0.2, 0.5, 0.8]`. You can also use px values, which doesn't take screen height into account.

`fadeFromIndex`: Index of a `snapPoint` from which the overlay fade should be applied. Defaults to the last snap point.

`modal`: When `false`it allows to interact with elements outside of the drawer without closing it. Defaults to`true`.
`modal`: When `false` it allows to interact with elements outside of the drawer without closing it. Defaults to `true`.

`handleOnly`: When `true` only allows the drawer to be dragged by the `<Drawer.Handle />` component. Defaults to `false`.

`direction`: Direction of the drawer. Can be `top` or `bottom`, `left`, `right`. Defaults to `bottom`.

`preventScrollRestoration`: When `true` it prevents scroll restoration when the drawer is closed after a navigation happens inside of it. Defaults to `true`.

`disablePreventScroll`: When `true` scroll prevention mechanism will be disabled. Scroll prevention ensures that page will not scroll on mobile when opening drawer. However this mechanism gets confused when drawer has an input with autofocus and therefore opens simulataneosly with touch keyboard. Defaults to `true`. `modal` set to `false` also disables it.

`noBodyStyles`: When `true` the `body` doesn't get any styles assigned from Vaul.

`setBackgroundColorOnScale`: When `false` we don't change body's background color when the drawer is open. `true` by default.

`[data-vaul-no-drag]`: When interacting with an element with this data attribute, the drawer won't be dragged.

### Trigger

The button that opens the dialog. [Props](https://www.radix-ui.com/docs/primitives/components/dialog#trigger).
Expand All @@ -89,6 +101,10 @@ An optional accessible description to be announced when the dialog is opened. [P

The button that closes the dialog. [Props](https://www.radix-ui.com/docs/primitives/components/dialog#close).

### Handle

A drag hint (also known as grabber). Shows people that they can drag the drawer to resize it; they can also tap it to cycle through the snap points, and double tap quickly to close the drawer. Set `preventCycle={true}` to stop this behavior. If you want to change the handle's hit area you can do so by styling the `[vaul-handle-hitarea]` selector (Defaults to 44x44 on mobile devices).

### Portal

Portals your drawer into the body.
34 changes: 25 additions & 9 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,16 +1,27 @@
{
"name": "vaul",
"version": "0.8.0",
"version": "0.9.1",
"description": "Drawer component for React.",
"main": "dist/index.js",
"module": "dist/index.mjs",
"types": "dist/index.d.ts",
"main": "./dist/index.js",
"module": "./dist/index.mjs",
"types": "./dist/index.d.ts",
"files": [
"dist"
],
"exports": {
"import": {
"types": "./dist/index.d.mts",
"default": "./dist/index.mjs"
},
"require": {
"types": "./dist/index.d.ts",
"default": "./dist/index.js"
}
},
"scripts": {
"build": "tsup src/index.tsx",
"dev": "tsup src/index.tsx --watch",
"type-check": "tsc --noEmit",
"build": "pnpm type-check && bunchee",
"dev": "bunchee --watch",
"dev:website": "turbo run dev --filter=website...",
"dev:test": "turbo run dev --filter=test...",
"format": "prettier --write .",
Expand All @@ -35,11 +46,16 @@
"devDependencies": {
"@playwright/test": "^1.37.1",
"@radix-ui/react-dialog": "^1.0.4",
"@types/node": "20.5.7",
"@types/react": "18.2.55",
"@types/react-dom": "18.2.18",
"bunchee": "^4.4.6",
"eslint": "^7.32.0",
"prettier": "^2.5.1",
"typescript": "5.2.2",
"tsup": "^6.4.0",
"turbo": "1.6"
"react": "^18.2.0",
"react-dom": "^18.2.0",
"turbo": "1.6",
"typescript": "5.2.2"
},
"peerDependencies": {
"react": "^16.8 || ^17.0 || ^18.0",
Expand Down
Loading

0 comments on commit b443dc9

Please sign in to comment.