Skip to content

Commit d947b92

Browse files
authored
feat: drawer improvements (#4057)
1 parent 08f1f1e commit d947b92

File tree

9 files changed

+707
-9
lines changed

9 files changed

+707
-9
lines changed

.changeset/cold-dolls-vanish.md

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
"@nextui-org/drawer": patch
3+
"@nextui-org/modal": patch
4+
---
5+
6+
Drawer styles and transition improved

apps/docs/content/components/drawer/custom-styles.ts

+337
Large diffs are not rendered by default.

apps/docs/content/components/drawer/index.ts

+2
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import placement from "./placement";
55
import form from "./form";
66
import backdrop from "./backdrop";
77
import customMotion from "./custom-motion";
8+
import customStyles from "./custom-styles";
89

910
export const drawerContent = {
1011
usage,
@@ -14,4 +15,5 @@ export const drawerContent = {
1415
form,
1516
backdrop,
1617
customMotion,
18+
customStyles,
1719
};

apps/docs/content/docs/components/drawer.mdx

+4
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,10 @@ Drawer offers a `motionProps` property to customize the `enter` / `exit` animati
115115

116116
> Learn more about Framer motion variants [here](https://www.framer.com/motion/animation/#variants).
117117
118+
### Custom Styles
119+
120+
<CodeDemo title="Custom Styles" files={drawerContent.customStyles} />
121+
118122
## Slots
119123

120124
- **wrapper**: The wrapper slot of the drawer. It wraps the `base` and the `backdrop` slots.

packages/components/drawer/package.json

+3
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,10 @@
5050
"@nextui-org/system": "workspace:*",
5151
"@nextui-org/input": "workspace:*",
5252
"@nextui-org/checkbox": "workspace:*",
53+
"@nextui-org/tooltip": "workspace:*",
54+
"@nextui-org/image": "workspace:*",
5355
"@nextui-org/button": "workspace:*",
56+
"@nextui-org/avatar": "workspace:*",
5457
"@nextui-org/link": "workspace:*",
5558
"@nextui-org/switch": "workspace:*",
5659
"@nextui-org/shared-icons": "workspace:*",

packages/components/drawer/src/use-drawer.ts

+6-8
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import {drawer} from "@nextui-org/theme";
44
import {ReactRef, useDOMRef} from "@nextui-org/react-utils";
55
import {useCallback, useMemo} from "react";
66
import {TRANSITION_EASINGS} from "@nextui-org/framer-utils";
7-
import {clsx} from "@nextui-org/shared-utils";
7+
import {clsx, isEmpty} from "@nextui-org/shared-utils";
88
import {PropGetter} from "@nextui-org/system";
99

1010
interface Props extends Omit<ModalProps, "placement" | "scrollBehavior" | "children"> {
@@ -39,7 +39,7 @@ export function useDrawer(originalProps: UseDrawerProps) {
3939
const domRef = useDOMRef(ref);
4040

4141
const motionProps = useMemo(() => {
42-
if (drawerMotionProps !== void 0) return drawerMotionProps;
42+
if (!isEmpty(drawerMotionProps)) return drawerMotionProps;
4343

4444
const key = placement === "left" || placement === "right" ? "x" : "y";
4545

@@ -49,19 +49,17 @@ export function useDrawer(originalProps: UseDrawerProps) {
4949
[key]: 0,
5050
transition: {
5151
[key]: {
52-
bounce: 0,
53-
duration: 0.3,
54-
ease: TRANSITION_EASINGS.ease,
52+
duration: 0.2,
53+
ease: TRANSITION_EASINGS.easeOut,
5554
},
5655
},
5756
},
5857
exit: {
5958
[key]: placement === "top" || placement === "left" ? "-100%" : "100%",
6059
transition: {
6160
[key]: {
62-
bounce: 0,
63-
duration: 0.6,
64-
ease: TRANSITION_EASINGS.ease,
61+
duration: 0.1,
62+
ease: TRANSITION_EASINGS.easeIn,
6563
},
6664
},
6765
},

packages/components/drawer/stories/drawer.stories.tsx

+339
Large diffs are not rendered by default.

packages/components/modal/src/use-modal.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,6 @@ export function useModal(originalProps: UseModalProps) {
8888
as,
8989
className,
9090
classNames,
91-
9291
isOpen,
9392
defaultOpen,
9493
onOpenChange,
@@ -162,6 +161,7 @@ export function useModal(originalProps: UseModalProps) {
162161
"data-open": dataAttr(state.isOpen),
163162
"data-dismissable": dataAttr(isDismissable),
164163
"aria-modal": dataAttr(true),
164+
"data-placement": originalProps?.placement ?? "right",
165165
"aria-labelledby": headerMounted ? headerId : undefined,
166166
"aria-describedby": bodyMounted ? bodyId : undefined,
167167
});

pnpm-lock.yaml

+9
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)