Skip to content

Commit

Permalink
Refactor modal
Browse files Browse the repository at this point in the history
  • Loading branch information
rajtoshranjan committed Apr 30, 2024
1 parent 9d8c2e4 commit 9327248
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 26 deletions.
48 changes: 24 additions & 24 deletions src/components/ui/modal/modal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,30 +54,30 @@ export const Modal: React.FC<ModalProps> & ModalComponents = ({
);
};

Modal.Body = React.forwardRef<HTMLElement, ModalBaseProps>(
({ children, className, ...rest }) => {
// Constants.
const customClassNames = classNames(
"p-4 overflow-y-auto text-gray-50",
className
);
Modal.Body = React.forwardRef(({ children, className, ...rest }, ref) => {
// Constants.
const customClassNames = classNames(
"p-4 overflow-y-auto text-gray-50",
className
);

return (
<div className={customClassNames} {...rest}>
{children}
</div>
);
}
);
return (
<div ref={ref} className={customClassNames} {...rest}>
{children}
</div>
);
});

Modal.Footer = React.forwardRef<HTMLElement, ModalBaseProps>(
({ children, className, ...rest }) => {
// Constants.
const customClassNames = classNames(
"flex justify-end items-center gap-x-2 py-3 px-4 border-t border-neutral-700",
className
);
Modal.Footer = React.forwardRef(({ children, className, ...rest }, ref) => {
// Constants.
const customClassNames = classNames(
"flex justify-end items-center gap-x-2 py-3 px-4 border-t border-neutral-700",
className
);

return <div className={customClassNames}>{children}</div>;
}
);
return (
<div ref={ref} className={customClassNames}>
{children}
</div>
);
});
4 changes: 2 additions & 2 deletions src/components/ui/modal/type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@ export type ModalProps = ModalBaseProps & {
};

export type ModalComponents = {
Body: ForwardRef<HTMLElement, ModalBaseProps>;
Footer: ForwardRef<HTMLElement, ModalBaseProps>;
Body: ForwardRef<HTMLDivElement, ModalBaseProps>;
Footer: ForwardRef<HTMLDivElement, ModalBaseProps>;
};

0 comments on commit 9327248

Please sign in to comment.