Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Beta/drawer improvements #4057

Merged
merged 1 commit into from
Nov 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .changeset/cold-dolls-vanish.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@nextui-org/drawer": patch
"@nextui-org/modal": patch
---

Drawer styles and transition improved
337 changes: 337 additions & 0 deletions apps/docs/content/components/drawer/custom-styles.ts

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions apps/docs/content/components/drawer/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import placement from "./placement";
import form from "./form";
import backdrop from "./backdrop";
import customMotion from "./custom-motion";
import customStyles from "./custom-styles";

export const drawerContent = {
usage,
Expand All @@ -14,4 +15,5 @@ export const drawerContent = {
form,
backdrop,
customMotion,
customStyles,
};
4 changes: 4 additions & 0 deletions apps/docs/content/docs/components/drawer.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,10 @@ Drawer offers a `motionProps` property to customize the `enter` / `exit` animati

> Learn more about Framer motion variants [here](https://www.framer.com/motion/animation/#variants).

### Custom Styles

<CodeDemo title="Custom Styles" files={drawerContent.customStyles} />

## Slots

- **wrapper**: The wrapper slot of the drawer. It wraps the `base` and the `backdrop` slots.
Expand Down
3 changes: 3 additions & 0 deletions packages/components/drawer/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,10 @@
"@nextui-org/system": "workspace:*",
"@nextui-org/input": "workspace:*",
"@nextui-org/checkbox": "workspace:*",
"@nextui-org/tooltip": "workspace:*",
"@nextui-org/image": "workspace:*",
"@nextui-org/button": "workspace:*",
"@nextui-org/avatar": "workspace:*",
"@nextui-org/link": "workspace:*",
"@nextui-org/switch": "workspace:*",
"@nextui-org/shared-icons": "workspace:*",
Expand Down
14 changes: 6 additions & 8 deletions packages/components/drawer/src/use-drawer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {drawer} from "@nextui-org/theme";
import {ReactRef, useDOMRef} from "@nextui-org/react-utils";
import {useCallback, useMemo} from "react";
import {TRANSITION_EASINGS} from "@nextui-org/framer-utils";
import {clsx} from "@nextui-org/shared-utils";
import {clsx, isEmpty} from "@nextui-org/shared-utils";
import {PropGetter} from "@nextui-org/system";

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

const motionProps = useMemo(() => {
if (drawerMotionProps !== void 0) return drawerMotionProps;
if (!isEmpty(drawerMotionProps)) return drawerMotionProps;

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

Expand All @@ -49,19 +49,17 @@ export function useDrawer(originalProps: UseDrawerProps) {
[key]: 0,
transition: {
[key]: {
bounce: 0,
duration: 0.3,
ease: TRANSITION_EASINGS.ease,
duration: 0.2,
ease: TRANSITION_EASINGS.easeOut,
},
},
},
exit: {
[key]: placement === "top" || placement === "left" ? "-100%" : "100%",
transition: {
[key]: {
bounce: 0,
duration: 0.6,
ease: TRANSITION_EASINGS.ease,
duration: 0.1,
ease: TRANSITION_EASINGS.easeIn,
},
},
},
Expand Down
339 changes: 339 additions & 0 deletions packages/components/drawer/stories/drawer.stories.tsx

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion packages/components/modal/src/use-modal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,6 @@ export function useModal(originalProps: UseModalProps) {
as,
className,
classNames,

isOpen,
defaultOpen,
onOpenChange,
Expand Down Expand Up @@ -162,6 +161,7 @@ export function useModal(originalProps: UseModalProps) {
"data-open": dataAttr(state.isOpen),
"data-dismissable": dataAttr(isDismissable),
"aria-modal": dataAttr(true),
"data-placement": originalProps?.placement ?? "right",
"aria-labelledby": headerMounted ? headerId : undefined,
"aria-describedby": bodyMounted ? bodyId : undefined,
});
Expand Down
9 changes: 9 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.