Skip to content

Commit 9e7b891

Browse files
authored
Merge pull request #74 from DouglasNeuroInformatics/mobile-dialog-styles
refactor: remove forwardRef from dialog
2 parents 91b42ff + 6d596c4 commit 9e7b891

File tree

4 files changed

+16
-31
lines changed

4 files changed

+16
-31
lines changed
Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { forwardRef } from 'react';
1+
import {} from 'react';
22

33
import { Close, Content, Portal } from '@radix-ui/react-dialog';
44
import { XIcon } from 'lucide-react';
@@ -7,19 +7,15 @@ import { cn } from '@/utils';
77

88
import { DialogOverlay } from './DialogOverlay';
99

10-
export const DialogContent = forwardRef<
11-
React.ElementRef<typeof Content>,
12-
React.ComponentPropsWithoutRef<typeof Content>
13-
>(function DialogContent({ children, className, ...props }, ref) {
10+
export const DialogContent = ({ children, className, ...props }: React.ComponentProps<typeof Content>) => {
1411
return (
1512
<Portal>
1613
<DialogOverlay />
1714
<Content
1815
className={cn(
19-
'bg-background data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 fixed top-[50%] left-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border p-6 shadow-lg duration-200 sm:rounded-lg',
16+
'bg-background data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 fixed top-[50%] left-[50%] z-50 grid w-full max-w-[calc(100%-2rem)] translate-x-[-50%] translate-y-[-50%] gap-4 rounded-md border p-6 shadow-lg duration-300 sm:max-w-lg sm:rounded-lg',
2017
className
2118
)}
22-
ref={ref}
2319
{...props}
2420
>
2521
{children}
@@ -29,4 +25,4 @@ export const DialogContent = forwardRef<
2925
</Content>
3026
</Portal>
3127
);
32-
});
28+
};
Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,9 @@
1-
import { forwardRef } from 'react';
1+
import {} from 'react';
22

33
import { Description } from '@radix-ui/react-dialog';
44

55
import { cn } from '@/utils';
66

7-
export const DialogDescription = forwardRef<
8-
React.ElementRef<typeof Description>,
9-
React.ComponentPropsWithoutRef<typeof Description>
10-
>(function DialogDescription({ className, ...props }, ref) {
11-
return <Description className={cn('text-sm text-muted-foreground', className)} ref={ref} {...props} />;
12-
});
7+
export const DialogDescription = ({ className, ...props }: React.ComponentProps<typeof Description>) => {
8+
return <Description className={cn('text-muted-foreground text-sm', className)} {...props} />;
9+
};
Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,17 @@
1-
import { forwardRef } from 'react';
1+
import {} from 'react';
22

33
import { Overlay } from '@radix-ui/react-dialog';
44

55
import { cn } from '@/utils';
66

7-
export const DialogOverlay = forwardRef<
8-
React.ElementRef<typeof Overlay>,
9-
React.ComponentPropsWithoutRef<typeof Overlay>
10-
>(function DialogOverlay({ className, ...props }, ref) {
7+
export const DialogOverlay = ({ className, ...props }: React.ComponentProps<typeof Overlay>) => {
118
return (
129
<Overlay
1310
className={cn(
14-
'data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 fixed inset-0 z-50 bg-black/80 duration-200',
11+
'data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 fixed inset-0 z-50 bg-black/80 duration-300',
1512
className
1613
)}
17-
ref={ref}
1814
{...props}
1915
/>
2016
);
21-
});
17+
};
Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,9 @@
1-
import { forwardRef } from 'react';
1+
import {} from 'react';
22

33
import { Title } from '@radix-ui/react-dialog';
44

55
import { cn } from '@/utils';
66

7-
export const DialogTitle = forwardRef<React.ElementRef<typeof Title>, React.ComponentPropsWithoutRef<typeof Title>>(
8-
function DialogTitle({ className, ...props }, ref) {
9-
return (
10-
<Title className={cn('text-lg font-semibold leading-none tracking-tight', className)} ref={ref} {...props} />
11-
);
12-
}
13-
);
7+
export const DialogTitle = ({ className, ...props }: React.ComponentProps<typeof Title>) => {
8+
return <Title className={cn('text-lg leading-none font-semibold tracking-tight', className)} {...props} />;
9+
};

0 commit comments

Comments
 (0)