Skip to content

Commit 1fe3286

Browse files
authored
Fix OpenAPI overflow issue (#3015)
1 parent ce030fd commit 1fe3286

File tree

7 files changed

+34
-47
lines changed

7 files changed

+34
-47
lines changed

.changeset/twelve-falcons-exist.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"gitbook": patch
3+
---
4+
5+
Fix OpenAPI block overflow issue

packages/gitbook/e2e/internal.spec.ts

-1
Original file line numberDiff line numberDiff line change
@@ -420,7 +420,6 @@ const testCases: TestsCase[] = [
420420
await zoomImage.first().click();
421421
await expect(page.getByTestId('zoom-image-modal')).toBeVisible();
422422
},
423-
fullPage: true,
424423
screenshot: { threshold: 0.8 },
425424
},
426425
{

packages/gitbook/e2e/util.ts

+5
Original file line numberDiff line numberDiff line change
@@ -340,6 +340,11 @@ async function waitForIcons(page: Page) {
340340
return false;
341341
}
342342

343+
// Ignore icons that are not visible.
344+
if (!icon.checkVisibility()) {
345+
return true;
346+
}
347+
343348
// url("https://ka-p.fontawesome.com/releases/v6.6.0/svgs/light/moon.svg?v=2&token=a463935e93")
344349
const maskImage = window.getComputedStyle(icon).getPropertyValue('mask-image');
345350
const urlMatch = maskImage.match(/url\("([^"]+)"\)/);

packages/gitbook/src/components/DocumentView/OpenAPI/OpenAPIOperation.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import type { AnyOpenAPIOperationsBlock } from '@/lib/openapi/types';
2020
export async function OpenAPIOperation(props: BlockProps<AnyOpenAPIOperationsBlock>) {
2121
const { style } = props;
2222
return (
23-
<div className={tcls('flex w-full', style, 'max-w-full')}>
23+
<div className={tcls('flex w-full min-w-0', style, 'max-w-full')}>
2424
<OpenAPIOperationBody {...props} />
2525
</div>
2626
);

packages/gitbook/src/components/DocumentView/OpenAPI/style.css

+4-6
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/* Layout Components */
22
.openapi-operation {
3-
@apply flex-1 flex flex-col gap-8 mb-14;
3+
@apply flex-1 flex flex-col gap-8 mb-14 min-w-0;
44
}
55

66
.openapi-schemas {
@@ -397,7 +397,7 @@
397397

398398
/* Path */
399399
.openapi-path {
400-
@apply flex items-center text-sm gap-2 h-fit;
400+
@apply flex items-start text-sm gap-2 h-fit min-w-0 max-w-full;
401401
}
402402

403403
.openapi-path-variable {
@@ -409,14 +409,12 @@
409409
}
410410

411411
.openapi-path .openapi-method {
412-
@apply text-[0.813rem] m-0 h-full items-center flex px-2;
412+
@apply text-[0.813rem] m-0 mt-0.5 items-center flex px-2;
413413
}
414414

415415
.openapi-path-title {
416-
@apply flex-1 relative font-normal whitespace-nowrap overflow-x-auto font-mono text-tint-strong/10;
416+
@apply flex-1 relative font-normal text-left font-mono text-tint-strong/10;
417417
@apply py-0.5 px-1 rounded hover:bg-tint cursor-pointer transition-colors;
418-
scrollbar-width: none;
419-
-ms-overflow-style: none;
420418
}
421419

422420
.openapi-path-title[data-deprecated="true"] {

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

+18-38
Original file line numberDiff line numberDiff line change
@@ -35,25 +35,19 @@ export function PageBody(props: {
3535
return (
3636
<>
3737
<main
38-
className={
39-
tcls(
40-
'flex-1',
41-
'relative',
42-
'py-8',
43-
'lg:px-12',
44-
// Allow words to break if they are too long.
45-
'break-anywhere',
46-
// When in api page mode without the aside, we align with the border of the main content
47-
'page-api-block:xl:max-2xl:pr-0',
48-
// Max size to ensure one column in api is aligned with rest of content (2 x 3xl) + (gap-3 + 2) * px-12
49-
'page-api-block:max-w-screen-2xl',
50-
'page-api-block:mx-auto'
51-
52-
// page.layout.tableOfContents ? null : 'xl:ml-56'
53-
) +
54-
(asFullWidth ? ' page-full-width' : ' page-default-width') +
55-
(!page.layout.tableOfContents ? ' page-no-toc' : ' page-has-toc')
56-
}
38+
className={tcls(
39+
'relative min-w-0 flex-1',
40+
'py-8 lg:px-12',
41+
// Allow words to break if they are too long.
42+
'break-anywhere',
43+
// When in api page mode without the aside, we align with the border of the main content
44+
'page-api-block:xl:max-2xl:pr-0',
45+
// Max size to ensure one column in api is aligned with rest of content (2 x 3xl) + (gap-3 + 2) * px-12
46+
'page-api-block:mx-auto page-api-block:max-w-screen-2xl',
47+
// page.layout.tableOfContents ? null : 'xl:ml-56',
48+
asFullWidth ? 'page-full-width' : 'page-default-width',
49+
page.layout.tableOfContents ? 'page-has-toc' : 'page-no-toc'
50+
)}
5751
>
5852
<PreservePageLayout asFullWidth={asFullWidth} />
5953
{page.cover && page.layout.cover && page.layout.coverSize === 'hero' ? (
@@ -66,14 +60,14 @@ export function PageBody(props: {
6660
fallback={
6761
<DocumentViewSkeleton
6862
document={document}
69-
blockStyle={['page-api-block:ml-0']}
63+
blockStyle="page-api-block:ml-0"
7064
/>
7165
}
7266
>
7367
<DocumentView
7468
document={document}
75-
style={['[&>*+*]:mt-5', 'grid']}
76-
blockStyle={['page-api-block:ml-0']}
69+
style="grid [&>*+*]:mt-5"
70+
blockStyle="page-api-block:ml-0"
7771
context={{
7872
mode: 'default',
7973
contentContext: context,
@@ -88,23 +82,9 @@ export function PageBody(props: {
8882
<PageFooterNavigation context={context} page={page} />
8983
) : null}
9084

91-
<div
92-
className={tcls(
93-
'flex',
94-
'flex-row',
95-
'flex-wrap',
96-
'gap-4',
97-
'items-center',
98-
'mt-6',
99-
'max-w-3xl',
100-
'mx-auto',
101-
'page-api-block:ml-0',
102-
'text-tint',
103-
'contrast-more:text-tint-strong'
104-
)}
105-
>
85+
<div className="mx-auto mt-6 page-api-block:ml-0 flex max-w-3xl flex-row flex-wrap items-center gap-4 text-tint contrast-more:text-tint-strong">
10686
{updatedAt ? (
107-
<p className={tcls('mr-auto text-sm')}>
87+
<p className="mr-auto text-sm">
10888
{t(language, 'page_last_modified', <DateRelative value={updatedAt} />)}
10989
</p>
11090
) : null}

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ export function SpaceLayout(props: {
136136
</>
137137
}
138138
/>
139-
<div className={tcls('flex-1', 'flex', 'flex-col')}>{children}</div>
139+
<div className="flex min-w-0 flex-1 flex-col">{children}</div>
140140
</div>
141141
</div>
142142

0 commit comments

Comments
 (0)