Skip to content

Commit dddb4ec

Browse files
authored
Fix OpenAPI long tab group description (#2838)
1 parent 470d10c commit dddb4ec

File tree

3 files changed

+24
-12
lines changed

3 files changed

+24
-12
lines changed

.changeset/rare-timers-clap.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
'@gitbook/react-openapi': patch
3+
'gitbook': patch
4+
---
5+
6+
Fix long tab group description

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

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -338,7 +338,7 @@
338338
}
339339

340340
.openapi-response-description.openapi-markdown {
341-
@apply prose-sm text-[0.813rem] h-auto relative leading-[1.125rem] text-tint !font-normal truncate select-text prose-strong:font-semibold prose-strong:text-inherit;
341+
@apply text-left prose-sm text-[0.813rem] h-auto relative leading-[1.125rem] text-tint !font-normal truncate select-text prose-strong:font-semibold prose-strong:text-inherit;
342342
}
343343

344344
.openapi-response-description.openapi-markdown::-webkit-scrollbar {
@@ -525,11 +525,11 @@
525525
}
526526

527527
.openapi-disclosure-group-header {
528-
@apply flex flex-row items-center justify-between gap-3;
528+
@apply flex flex-row items-baseline justify-between gap-3 relative;
529529
}
530530

531531
.openapi-disclosure-group-trigger {
532-
@apply flex items-center relative flex-1 gap-2.5 py-2 truncate -outline-offset-1;
532+
@apply flex items-baseline relative flex-1 gap-2.5 py-2 truncate -outline-offset-1;
533533
}
534534

535535
.openapi-disclosure-group-trigger:disabled {
@@ -545,6 +545,10 @@
545545
@apply invisible;
546546
}
547547

548+
.openapi-disclosure-group-trigger[aria-expanded='true'] .openapi-response-description {
549+
@apply whitespace-normal;
550+
}
551+
548552
.openapi-disclosure-group-icon > svg {
549553
@apply size-3 text-tint-subtle transition-all duration-300;
550554
}
@@ -561,17 +565,16 @@
561565
@apply rotate-90;
562566
}
563567

564-
.openapi-disclosure-group:hover .openapi-disclosure-group-mediatype,
565-
.openapi-disclosure-group[aria-expanded='true'] .openapi-disclosure-group-mediatype {
568+
.openapi-disclosure-group:hover .openapi-disclosure-group-mediatype {
566569
@apply opacity-11 flex;
567570
}
568571

569572
.openapi-disclosure-group-mediatype {
570-
@apply opacity-0 hidden transition-all duration-200 shrink-0;
573+
@apply opacity-0 hidden text-xs transition-all duration-200 shrink-0 absolute right-0 top-2.5;
571574
}
572575

573576
.openapi-disclosure-group-mediatype > span {
574-
@apply text-xs text-tint-subtle;
577+
@apply px-1 bg-tint-6 text-tint-12 rounded-full;
575578
}
576579

577580
/* Disclosure */

packages/react-openapi/src/OpenAPIResponses.tsx

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import { OpenAPIResponse } from './OpenAPIResponse';
44
import { OpenAPIClientContext } from './types';
55
import { InteractiveSection } from './InteractiveSection';
66
import { OpenAPIDisclosureGroup } from './OpenAPIDisclosureGroup';
7-
import { Markdown } from './Markdown';
87

98
/**
109
* Display an interactive response body.
@@ -40,10 +39,9 @@ export function OpenAPIResponses(props: {
4039
{statusCode}
4140
</span>
4241
{description ? (
43-
<Markdown
44-
source={description}
45-
className="openapi-response-description"
46-
/>
42+
<div className="openapi-markdown openapi-response-description">
43+
{htmlToText(description)}
44+
</div>
4745
) : null}
4846
</div>
4947
),
@@ -66,3 +64,8 @@ export function OpenAPIResponses(props: {
6664
</InteractiveSection>
6765
);
6866
}
67+
68+
function htmlToText(html: string): string {
69+
const doc = new DOMParser().parseFromString(html, 'text/html');
70+
return doc.body.textContent?.trim() || '';
71+
}

0 commit comments

Comments
 (0)