Skip to content

Commit d74f8a7

Browse files
authored
Improve wide page width (#3692)
1 parent 1e53f46 commit d74f8a7

File tree

6 files changed

+46
-35
lines changed

6 files changed

+46
-35
lines changed

.changeset/silly-ducks-kiss.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"gitbook": patch
3+
---
4+
5+
Improve wide page width layout

packages/gitbook/src/components/DocumentView/Blocks.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ export function UnwrappedBlocks<TBlock extends DocumentBlock>(props: UnwrappedBl
8989
node.data && 'fullWidth' in node.data && node.data.fullWidth
9090
? 'max-w-screen-xl'
9191
: 'max-w-3xl',
92-
FULL_WIDTH_BLOCKS.includes(node.type) && 'page-width-wide:max-w-screen-2xl',
92+
FULL_WIDTH_BLOCKS.includes(node.type) && 'page-width-wide:max-w-full',
9393
blockStyle,
9494
]}
9595
isEstimatedOffscreen={isOffscreen}

packages/gitbook/src/components/PageAside/PageAside.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ export function PageAside(props: {
3535
<aside
3636
className={tcls(
3737
'group/aside',
38+
'order-last',
3839
'hidden',
3940
'pt-8',
4041
'pb-4',

packages/gitbook/src/components/PageBody/PageBody.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,10 +51,10 @@ export function PageBody(props: {
5151
<main
5252
className={tcls(
5353
'relative min-w-0 flex-1',
54-
'mx-auto max-w-screen-2xl py-8',
54+
'max-w-screen-2xl py-8',
5555
// Allow words to break if they are too long.
5656
'break-anywhere',
57-
pageWidthWide ? 'page-width-wide 2xl:px-8' : 'page-width-default',
57+
pageWidthWide ? 'page-width-wide 3xl:px-8' : 'page-width-default',
5858
siteWidthWide ? 'site-width-wide' : 'site-width-default',
5959
page.layout.tableOfContents ? 'page-has-toc' : 'page-no-toc'
6060
)}

packages/gitbook/src/components/SitePage/SitePage.tsx

Lines changed: 35 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -43,38 +43,42 @@ export async function SitePage(props: SitePageProps) {
4343

4444
return (
4545
<PageContextProvider pageId={page.id} spaceId={context.space.id} title={page.title}>
46-
{withFullPageCover && page.cover ? (
47-
<PageCover as="full" page={page} cover={page.cover} context={context} />
48-
) : null}
49-
{/* We use a flex row reverse to render the aside first because the page is streamed. */}
50-
<div
51-
className={tcls(
52-
'flex grow flex-row-reverse justify-end',
53-
withSections
54-
? '[--content-scroll-margin:calc(var(--spacing)*27)]'
55-
: '[--content-scroll-margin:calc(var(--spacing)*16)]'
56-
)}
57-
>
58-
<PageAside
59-
page={page}
60-
document={document}
61-
withHeaderOffset={headerOffset}
62-
withFullPageCover={withFullPageCover}
63-
withPageFeedback={withPageFeedback}
64-
context={context}
65-
/>
66-
<PageBody
67-
context={context}
68-
page={page}
69-
ancestors={ancestors}
70-
document={document}
71-
withPageFeedback={withPageFeedback}
72-
insightsDisplayContext={SiteInsightsDisplayContext.Site}
73-
/>
46+
{/* Using `contents` makes the children of this div according to its parent — which keeps them in a single flex row with the TOC by default.
47+
If there's a page cover, we use `flex flex-col` to lay out the PageCover above the PageBody + PageAside instead. */}
48+
<div className={withFullPageCover && page.cover ? 'flex grow flex-col' : 'contents'}>
49+
{withFullPageCover && page.cover ? (
50+
<PageCover as="full" page={page} cover={page.cover} context={context} />
51+
) : null}
52+
53+
<div
54+
className={tcls(
55+
withFullPageCover && page.cover ? 'flex grow flex-row' : 'contents',
56+
withSections
57+
? '[--content-scroll-margin:calc(var(--spacing)*27)]'
58+
: '[--content-scroll-margin:calc(var(--spacing)*16)]'
59+
)}
60+
>
61+
<PageAside
62+
page={page}
63+
document={document}
64+
withHeaderOffset={headerOffset}
65+
withFullPageCover={withFullPageCover}
66+
withPageFeedback={withPageFeedback}
67+
context={context}
68+
/>
69+
<PageBody
70+
context={context}
71+
page={page}
72+
ancestors={ancestors}
73+
document={document}
74+
withPageFeedback={withPageFeedback}
75+
insightsDisplayContext={SiteInsightsDisplayContext.Site}
76+
/>
77+
</div>
78+
<React.Suspense fallback={null}>
79+
<PageClientLayout />
80+
</React.Suspense>
7481
</div>
75-
<React.Suspense fallback={null}>
76-
<PageClientLayout />
77-
</React.Suspense>
7882
</PageContextProvider>
7983
);
8084
}

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,7 @@ export function SpaceLayout(props: SpaceLayoutProps) {
137137
'flex',
138138
'flex-col',
139139
'lg:flex-row',
140+
'lg:justify-center',
140141
CONTAINER_STYLE,
141142
'site-width-wide:max-w-full',
142143

@@ -223,7 +224,7 @@ export function SpaceLayout(props: SpaceLayoutProps) {
223224
</>
224225
}
225226
/>
226-
<div className="flex min-w-0 flex-1 flex-col">{children}</div>
227+
{children}
227228
</div>
228229
</div>
229230

0 commit comments

Comments
 (0)