Skip to content

Commit 71e6749

Browse files
authored
Merge pull request #24 from thomasKn/thomas/fv-233-reponsive-dialogsheet-should-appear-from-bottom
Update Sheet
2 parents fb54dc3 + 9fd4f4c commit 71e6749

File tree

4 files changed

+31
-18
lines changed

4 files changed

+31
-18
lines changed

Diff for: app/components/layout/CartCount.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ function Badge(props: {cart?: CartType | null; count: number}) {
9393
<Sheet onOpenChange={setCartOpen} open={cartOpen}>
9494
<SheetTrigger className={buttonClass}>{BadgeCounter}</SheetTrigger>
9595
<SheetContent
96-
className="flex max-h-screen min-h-full w-screen flex-col gap-0 bg-background p-0 text-foreground sm:max-w-lg"
96+
className="flex h-[90%] max-h-screen w-screen flex-col gap-0 bg-background p-0 text-foreground sm:max-w-lg"
9797
onCloseAutoFocus={(e) => e.preventDefault()}
9898
>
9999
<SheetHeader className="px-6 py-5 shadow-sm shadow-foreground/10">

Diff for: app/components/navigation/MobileNavigation.tsx

+7-2
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,16 @@ export function MobileNavigation(props: {data?: NavigationProps}) {
3030
<IconMenu className="size-7" strokeWidth={1.5} />
3131
</SheetTrigger>
3232
<SheetContent
33-
className="flex max-h-screen min-h-full w-screen flex-col gap-0 bg-background p-0 text-foreground sm:max-w-lg"
33+
className="flex h-[var(--dialog-content-height)] max-h-screen w-screen flex-col gap-0 bg-background p-0 text-foreground sm:max-w-lg"
3434
onCloseAutoFocus={(e) => e.preventDefault()}
3535
onOpenAutoFocus={(e) => e.preventDefault()}
36+
style={
37+
{
38+
'--dialog-content-height': 'calc(100dvh * .75)',
39+
} as React.CSSProperties
40+
}
3641
>
37-
<MobileNavigationMenu className="flex-1 overflow-y-scroll text-xl font-medium">
42+
<MobileNavigationMenu className="flex-1 overflow-x-hidden overflow-y-scroll text-xl font-medium">
3843
<MobileNavigationMenuList>
3944
{props.data &&
4045
props.data?.length > 0 &&

Diff for: app/components/ui/MobileNavigationMenu.tsx

+10-9
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,12 @@ const MobileNavigationMenu = forwardRef<
99
React.ComponentPropsWithoutRef<typeof NavigationMenuPrimitive.Root>
1010
>(({children, className, ...props}, ref) => (
1111
<NavigationMenuPrimitive.Root
12-
className={cn('container relative py-[var(--viewport-top)]', className)}
12+
className={cn('relative px-6 py-[var(--viewport-top)]', className)}
1313
ref={ref}
1414
{...props}
1515
style={
1616
{
17-
'--viewport-top': '3.5rem',
17+
'--viewport-top': '4rem',
1818
} as React.CSSProperties
1919
}
2020
>
@@ -44,7 +44,7 @@ const MobileNavigationMenuTrigger = forwardRef<
4444
>(({children, className, ...props}, ref) => (
4545
<NavigationMenuPrimitive.Trigger
4646
className={cn(
47-
'group data-[state=open]:fixed data-[state=open]:top-4 data-[state=open]:duration-300 data-[state=open]:animate-in data-[state=open]:fade-in',
47+
'group data-[state=open]:absolute data-[state=open]:top-0 data-[state=open]:w-full data-[state=open]:translate-y-[-150%]',
4848
className,
4949
)}
5050
ref={ref}
@@ -69,10 +69,11 @@ const MobileNavigationMenuContent = forwardRef<
6969
<NavigationMenuPrimitive.Content
7070
className={cn(
7171
[
72-
'h-[calc(100dvh-var(--viewport-top))] w-screen transition ease-in-out',
73-
'group-data-[state=open]:duration-500',
72+
'h-[calc(var(--dialog-content-height)-var(--viewport-top)-2px)] w-screen transition ease-in-out',
73+
'rounded-t-3xl border-t border-border shadow-[0_0_5px_0] shadow-foreground/20',
74+
'group-data-[state=open]:duration-300',
7475
'group-data-[state=open]:animate-in',
75-
'group-data-[state=open]:fade-in',
76+
'group-data-[state=open]:slide-in-from-bottom-1/2',
7677
],
7778
className,
7879
)}
@@ -81,7 +82,7 @@ const MobileNavigationMenuContent = forwardRef<
8182
{...props}
8283
>
8384
<div className="flex h-full max-h-screen min-h-full w-screen flex-col gap-0">
84-
<div className="container flex h-full flex-1 flex-col gap-3 overflow-y-scroll pb-[var(--viewport-top)] pt-4">
85+
<div className="flex h-full flex-1 flex-col gap-3 overflow-y-scroll px-6 pb-[var(--viewport-top)] pt-6">
8586
{props.children}
8687
</div>
8788
</div>
@@ -98,12 +99,12 @@ const MobileNavigationMenuViewport = forwardRef<
9899
>(({className, ...props}, ref) => (
99100
<NavigationMenuPrimitive.Viewport
100101
className={cn([
101-
'group fixed left-0 top-[var(--viewport-top)] z-50',
102+
'group absolute left-0 top-[var(--viewport-top)] z-50',
102103
'h-[var(--radix-navigation-menu-viewport-height)] w-[var(--radix-navigation-menu-viewport-width)]',
103104
'bg-background text-foreground transition ease-in-out',
104105
'data-[state=closed]:duration-300',
105106
'data-[state=closed]:animate-out',
106-
'data-[state=closed]:fade-out',
107+
'data-[state=closed]:slide-out-to-bottom',
107108
className,
108109
])}
109110
ref={ref}

Diff for: app/components/ui/Sheet.tsx

+13-6
Original file line numberDiff line numberDiff line change
@@ -32,19 +32,26 @@ const SheetOverlay = forwardRef<
3232
SheetOverlay.displayName = SheetPrimitive.Overlay.displayName;
3333

3434
const sheetVariants = cva(
35-
'fixed z-50 gap-4 bg-background p-6 shadow-lg transition ease-in-out data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:duration-300 data-[state=open]:duration-500',
35+
[
36+
'fixed z-50 gap-4 bg-background p-6 shadow-lg transition ease-in-out bottom-0 inset-x-0 md:bottom-auto md:inset-x-auto',
37+
'rounded-t-[2rem] md:rounded-none border md:border-none border-border overflow-hidden',
38+
'data-[state=open]:animate-in data-[state=closed]:animate-out',
39+
'data-[state=closed]:duration-300 data-[state=open]:duration-500',
40+
'data-[state=closed]:slide-out-to-bottom data-[state=open]:slide-in-from-bottom',
41+
'md:data-[state=closed]:slide-out-to-bottom-0 md:data-[state=open]:slide-in-from-bottom-0',
42+
],
3643
{
3744
defaultVariants: {
3845
side: 'right',
3946
},
4047
variants: {
4148
side: {
4249
bottom:
43-
'inset-x-0 bottom-0 data-[state=closed]:slide-out-to-bottom data-[state=open]:slide-in-from-bottom',
44-
left: 'inset-y-0 left-0 h-full w-3/4 data-[state=closed]:slide-out-to-left data-[state=open]:slide-in-from-left sm:max-w-sm',
50+
'md:inset-x-0 md:bottom-0 md:data-[state=closed]:slide-out-to-bottom md:data-[state=open]:slide-in-from-bottom',
51+
left: 'md:inset-y-0 md:left-0 md:h-full w-3/4 md:data-[state=closed]:slide-out-to-left md:data-[state=open]:slide-in-from-left sm:max-w-sm',
4552
right:
46-
'inset-y-0 right-0 h-full w-3/4 data-[state=closed]:slide-out-to-right data-[state=open]:slide-in-from-right sm:max-w-sm',
47-
top: 'inset-x-0 top-0 data-[state=closed]:slide-out-to-top data-[state=open]:slide-in-from-top',
53+
'md:inset-y-0 md:right-0 md:h-full w-3/4 md:data-[state=closed]:slide-out-to-right md:data-[state=open]:slide-in-from-right sm:max-w-sm',
54+
top: 'md:inset-x-0 md:top-0 md:data-[state=closed]:slide-out-to-top md:data-[state=open]:slide-in-from-top',
4855
},
4956
},
5057
},
@@ -66,7 +73,7 @@ const SheetContent = forwardRef<
6673
{...props}
6774
>
6875
{children}
69-
<SheetPrimitive.Close className="absolute right-4 top-4 rounded-sm ring-offset-background transition-opacity hover:opacity-70 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-secondary">
76+
<SheetPrimitive.Close className="absolute right-4 top-4 hidden rounded-sm ring-offset-background transition-opacity hover:opacity-70 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-secondary md:block">
7077
<IconClose className="size-6" strokeWidth={2} />
7178
<span className="sr-only">Close</span>
7279
</SheetPrimitive.Close>

0 commit comments

Comments
 (0)