Skip to content

Commit cdcd991

Browse files
committed
Fixes after review
1 parent e848cf5 commit cdcd991

File tree

6 files changed

+55
-4
lines changed

6 files changed

+55
-4
lines changed

packages/gitbook/src/components/Header/HeaderMobileMenuButton.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import { Icon } from '@gitbook/icons';
44
import { useEffect } from 'react';
55

6-
import { useMobileMenuSheet } from '@/components/Header/mobile-menu/useMobileMenuSheet';
6+
import { useMobileMenuSheet } from '@/components/MobileMenu/useMobileMenuSheet';
77
import { tString, useLanguage } from '@/intl/client';
88
import { tcls } from '@/lib/tailwind';
99
import { usePathname } from 'next/navigation';

packages/gitbook/src/components/Header/mobile-menu/MobileMenuSheet.tsx renamed to packages/gitbook/src/components/MobileMenu/MobileMenuSheet.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import {
66
SheetDescription,
77
SheetHeader,
88
SheetTitle,
9-
} from '@/components/utils/Sheet';
9+
} from '@/components/primitives/Sheet';
1010
import { useMobileMenuSheet } from './useMobileMenuSheet';
1111

1212
export function MobileMenuSheet(props: { children: React.ReactNode }) {
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
export * from './MobileMenuSheet';
2+
export * from './useMobileMenuSheet';

packages/gitbook/src/components/SpaceLayout/SpaceLayout.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import { getSpaceLanguage } from '@/intl/server';
1111
import { t } from '@/intl/translate';
1212
import { tcls } from '@/lib/tailwind';
1313

14-
import { MobileMenuSheet } from '@/components/Header/mobile-menu/MobileMenuSheet';
14+
import { MobileMenuSheet } from '@/components/MobileMenu';
1515
import { TOCScrollContent } from '@/components/TableOfContents/TOCScrollContent';
1616
import type { VisitorAuthClaims } from '@/lib/adaptive';
1717
import { GITBOOK_API_PUBLIC_URL, GITBOOK_APP_URL } from '@v2/lib/env';

packages/gitbook/src/components/utils/Sheet.tsx renamed to packages/gitbook/src/components/primitives/Sheet.tsx

Lines changed: 50 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,22 +6,53 @@ import type * as React from 'react';
66
import { Button } from '@/components/primitives';
77
import { tcls } from '@/lib/tailwind';
88

9+
/**
10+
* Root component for the Sheet dialog.
11+
* Wraps the Radix UI Dialog.Root component and provides the context for the sheet dialog.
12+
*
13+
* @example
14+
* <Sheet>
15+
* <SheetTrigger>Open</SheetTrigger>
16+
* <SheetContent>
17+
* <SheetHeader>
18+
* <SheetTitle>Title</SheetTitle>
19+
* <SheetDescription>Description</SheetDescription>
20+
* </SheetHeader>
21+
* </SheetContent>
22+
* </Sheet>
23+
*/
924
export function Sheet({ ...props }: React.ComponentProps<typeof SheetPrimitive.Root>) {
1025
return <SheetPrimitive.Root data-slot="sheet" {...props} />;
1126
}
1227

28+
/**
29+
* Trigger component that opens the sheet dialog.
30+
* Typically used as a button or other interactive element to open the sheet.
31+
*/
1332
export function SheetTrigger({ ...props }: React.ComponentProps<typeof SheetPrimitive.Trigger>) {
1433
return <SheetPrimitive.Trigger data-slot="sheet-trigger" {...props} />;
1534
}
1635

36+
/**
37+
* Close component that closes the sheet dialog.
38+
* Can be used to create custom close buttons or triggers.
39+
*/
1740
export function SheetClose({ ...props }: React.ComponentProps<typeof SheetPrimitive.Close>) {
1841
return <SheetPrimitive.Close data-slot="sheet-close" {...props} />;
1942
}
2043

44+
/**
45+
* Portal component that renders the sheet content outside the DOM hierarchy.
46+
* Ensures proper stacking context and accessibility.
47+
*/
2148
export function SheetPortal({ ...props }: React.ComponentProps<typeof SheetPrimitive.Portal>) {
2249
return <SheetPrimitive.Portal data-slot="sheet-portal" {...props} />;
2350
}
2451

52+
/**
53+
* Overlay component that creates a semi-transparent backdrop behind the sheet.
54+
* Includes blur effect and animation states for opening/closing.
55+
*/
2556
function SheetOverlay({
2657
className,
2758
...props
@@ -30,14 +61,20 @@ function SheetOverlay({
3061
<SheetPrimitive.Overlay
3162
data-slot="sheet-overlay"
3263
className={tcls(
33-
'data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 fixed inset-0 z-30 bg-tint-12/4 backdrop-blur-lg data-[state=closed]:animate-out data-[state=open]:animate-in dark:bg-tint-1/6',
64+
'fixed inset-0 z-30 bg-tint-12/4 backdrop-blur-lg data-[state=closed]:animate-fadeIn data-[state=closed]:animate-out data-[state=open]:animate-fadeOut data-[state=open]:animate-in dark:bg-tint-1/6',
3465
className
3566
)}
3667
{...props}
3768
/>
3869
);
3970
}
4071

72+
/**
73+
* Main content component for the sheet dialog.
74+
* Handles positioning, animations, and styling of the sheet content.
75+
* @param side - Determines which side the sheet slides in from ('left' or 'right')
76+
* @param overlayClassName - Optional className for the overlay component
77+
*/
4178
export function SheetContent({
4279
className,
4380
overlayClassName,
@@ -109,6 +146,10 @@ export function SheetContent({
109146
);
110147
}
111148

149+
/**
150+
* Header component for the sheet dialog.
151+
* Provides consistent padding and layout for the sheet header area.
152+
*/
112153
export function SheetHeader({ className, ...props }: React.ComponentProps<'div'>) {
113154
return (
114155
<div
@@ -119,6 +160,10 @@ export function SheetHeader({ className, ...props }: React.ComponentProps<'div'>
119160
);
120161
}
121162

163+
/**
164+
* Title component for the sheet dialog.
165+
* Renders the main heading of the sheet with consistent styling.
166+
*/
122167
export function SheetTitle({
123168
className,
124169
...props
@@ -132,6 +177,10 @@ export function SheetTitle({
132177
);
133178
}
134179

180+
/**
181+
* Description component for the sheet dialog.
182+
* Renders supplementary text or description with consistent styling.
183+
*/
135184
export function SheetDescription({
136185
className,
137186
...props

0 commit comments

Comments
 (0)