Skip to content

Commit 39c4f76

Browse files
authored
Add fullwidth page option (#3344)
1 parent 2fe58e8 commit 39c4f76

File tree

16 files changed

+59
-34
lines changed

16 files changed

+59
-34
lines changed

.changeset/fuzzy-bulldogs-listen.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+
Add fullwidth page option

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

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,23 @@ type UnwrappedBlocksProps<TBlock extends DocumentBlock> = DocumentContextProps &
4747
isOffscreen?: boolean;
4848
};
4949

50+
/* Blocks that can be full width are automatically expanded on full-width pages.
51+
* Ideally we'd rely on the block type to determine if it can be full width, but
52+
* the block's `fullWidth` property does not differentiate between `undefined` and `false`.
53+
* So instead we hardcode a list of blocks that can be full width. */
54+
const FULL_WIDTH_BLOCKS = [
55+
'table',
56+
'tabs',
57+
'integration',
58+
'openapi',
59+
'images',
60+
'embed',
61+
'columns',
62+
'code',
63+
'content-ref',
64+
'hint',
65+
];
66+
5067
/**
5168
* Renders a list of blocks without a wrapper element.
5269
*/
@@ -68,10 +85,11 @@ export function UnwrappedBlocks<TBlock extends DocumentBlock>(props: UnwrappedBl
6885
key={node.key || `${node.type}-${index}`}
6986
block={node}
7087
style={[
71-
'mx-auto w-full decoration-primary/6',
88+
'mx-auto page-width-wide:mx-0 w-full decoration-primary/6',
7289
node.data && 'fullWidth' in node.data && node.data.fullWidth
7390
? 'max-w-screen-2xl'
74-
: 'page-full-width:ml-0 max-w-3xl',
91+
: 'max-w-3xl',
92+
FULL_WIDTH_BLOCKS.includes(node.type) && 'page-width-wide:max-w-screen-2xl',
7593
blockStyle,
7694
]}
7795
isEstimatedOffscreen={isOffscreen}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,5 @@ import type { BlockProps } from './Block';
77
export function Divider(props: BlockProps<DocumentBlockDivider>) {
88
const { style } = props;
99

10-
return <hr className={tcls(style, 'page-full-width:max-w-full border-tint-subtle')} />;
10+
return <hr className={tcls(style, 'page-width-wide:max-w-full border-tint-subtle')} />;
1111
}

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ export function Heading(props: BlockProps<DocumentBlockHeading>) {
2727
'flex',
2828
'items-baseline',
2929
'scroll-m-12',
30+
getTextAlignment(block.data.align),
3031
hashLinkButtonWrapperStyles,
3132
style,
3233
textStyle.marginTop

packages/gitbook/src/components/Footer/Footer.tsx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,16 +36,16 @@ export function Footer(props: { context: GitBookSiteContext }) {
3636
<div className={tcls(CONTAINER_STYLE, 'px-4', 'py-8', 'lg:py-12', 'mx-auto')}>
3737
<div
3838
className={tcls(
39-
'lg:!max-w-none mx-auto grid max-w-3xl site-full-width:max-w-screen-2xl justify-between gap-12',
39+
'lg:!max-w-none mx-auto grid max-w-3xl site-width-wide:max-w-screen-2xl justify-between gap-12',
4040
'grid-cols-[auto_auto]',
4141
'lg:grid-cols-[18rem_minmax(auto,_48rem)_auto]',
4242
'xl:grid-cols-[18rem_minmax(auto,_48rem)_14rem]',
43-
'site-full-width:lg:grid-cols-[18rem_minmax(auto,_80rem)_auto]',
44-
'site-full-width:xl:grid-cols-[18rem_minmax(auto,_80rem)_14rem]',
43+
'site-width-wide:lg:grid-cols-[18rem_minmax(auto,_80rem)_auto]',
44+
'site-width-wide:xl:grid-cols-[18rem_minmax(auto,_80rem)_14rem]',
4545
'page-no-toc:lg:grid-cols-[minmax(auto,_48rem)_auto]',
4646
'page-no-toc:xl:grid-cols-[14rem_minmax(auto,_48rem)_14rem]',
47-
'[body:has(.site-full-width,.page-no-toc)_&]:lg:grid-cols-[minmax(auto,_90rem)_auto]',
48-
'[body:has(.site-full-width,.page-no-toc)_&]:xl:grid-cols-[14rem_minmax(auto,_90rem)_14rem]'
47+
'[body:has(.site-width-wide,.page-no-toc)_&]:lg:grid-cols-[minmax(auto,_90rem)_auto]',
48+
'[body:has(.site-width-wide,.page-no-toc)_&]:xl:grid-cols-[14rem_minmax(auto,_90rem)_14rem]'
4949
)}
5050
>
5151
{
@@ -106,7 +106,7 @@ export function Footer(props: { context: GitBookSiteContext }) {
106106
'col-span-2 page-has-toc:lg:col-span-1 page-has-toc:lg:col-start-2 page-no-toc:xl:col-span-1 page-no-toc:xl:col-start-2'
107107
)}
108108
>
109-
<div className="mx-auto flex max-w-3xl site-full-width:max-w-screen-2xl flex-col gap-10 sm:flex-row sm:gap-6">
109+
<div className="mx-auto flex max-w-3xl site-width-wide:max-w-screen-2xl flex-col gap-10 sm:flex-row sm:gap-6">
110110
{partition(customization.footer.groups, FOOTER_COLUMNS).map(
111111
(column, columnIndex) => (
112112
<div

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ export function PageAside(props: {
5555
'chat-open:xl:max-3xl:max-w-0',
5656
'chat-open:xl:max-3xl:ml-0',
5757

58-
'motion-safe:transition-all motion-safe:duration-300',
58+
'motion-safe:xl:transition-all motion-safe:xl:duration-300',
5959
'motion-safe:[transition-behavior:allow-discrete]',
6060

6161
'flex-col',

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@ export function PageBody(props: {
4040
LINK_PREVIEW_MAX_COUNT
4141
)
4242
: false;
43-
const pageFullWidth = page.id === 'wtthNFMqmEQmnt5LKR0q';
44-
const asFullWidth = pageFullWidth || contentFullWidth;
43+
const pageWidthWide = page.layout.width === 'wide';
44+
const siteWidthWide = pageWidthWide || contentFullWidth;
4545
const language = getSpaceLanguage(customization);
4646
const updatedAt = page.updatedAt ?? page.createdAt;
4747

@@ -53,12 +53,12 @@ export function PageBody(props: {
5353
'mx-auto max-w-screen-2xl py-8',
5454
// Allow words to break if they are too long.
5555
'break-anywhere',
56-
pageFullWidth ? 'page-full-width 2xl:px-8' : 'page-default-width',
57-
asFullWidth ? 'site-full-width' : 'site-default-width',
56+
pageWidthWide ? 'page-width-wide 2xl:px-8' : 'page-width-default',
57+
siteWidthWide ? 'site-width-wide' : 'site-width-default',
5858
page.layout.tableOfContents ? 'page-has-toc' : 'page-no-toc'
5959
)}
6060
>
61-
<PreservePageLayout asFullWidth={asFullWidth} />
61+
<PreservePageLayout siteWidthWide={siteWidthWide} />
6262
{page.cover && page.layout.cover && page.layout.coverSize === 'hero' ? (
6363
<PageCover as="hero" page={page} cover={page.cover} context={context} />
6464
) : null}

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,11 +71,13 @@ export async function PageBodyBlankslate(props: {
7171
className={tcls(
7272
'grid',
7373
'max-w-3xl',
74+
'page-width-wide:max-w-screen-2xl',
7475
'w-full',
7576
'mx-auto',
7677
'gap-4',
7778
'grid-cols-1',
78-
'sm:grid-cols-2'
79+
'sm:grid-cols-2',
80+
'page-width-wide:md:grid-cols-3'
7981
)}
8082
>
8183
{pageElements}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ export async function PageCover(props: {
9595
: [
9696
'sm:mx-auto',
9797
'max-w-3xl ',
98-
'page-full-width:max-w-screen-2xl',
98+
'page-width-wide:max-w-screen-2xl',
9999
'sm:rounded-md',
100100
'mb-8',
101101
]

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ export async function PageFooterNavigation(props: {
3434
'mt-6',
3535
'gap-2',
3636
'max-w-3xl',
37-
'page-full-width:max-w-screen-2xl',
37+
'page-width-wide:max-w-screen-2xl',
3838
'mx-auto',
3939
'text-tint'
4040
)}

0 commit comments

Comments
 (0)