Skip to content

Commit ad16ea8

Browse files
committed
Size body card as a percentage of container space, with no fixed max
Previously it was fixed to a max of 560px in all cases. This is still uesd elsewhere (e.g. rule editors) but now in body cards, in modern desktop versions, we use container queries to size the body to 70% of the available space (as a max - smaller is fine). This makes it easier to see more of the important content, without risking very awkward UI cases by being larger than the space available (especially in the narrow layout).
1 parent 30a12f2 commit ad16ea8

File tree

5 files changed

+29
-11
lines changed

5 files changed

+29
-11
lines changed

src/components/editor/base-editor.tsx

Lines changed: 22 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -41,20 +41,21 @@ interface SchemaMapping {
4141
readonly schema?: any;
4242
}
4343

44-
const MAX_HEIGHT = 560;
44+
const DEFAULT_MAX_HEIGHT = 560;
4545

46-
const EditorMaxHeightContainer = styled.div`
47-
${(p: { expanded: boolean }) => p.expanded
46+
const EditorContainer = styled.div<{
47+
expanded: boolean;
48+
}>`
49+
${(p) => p.expanded
4850
? `
4951
position: absolute;
5052
top: 0;
5153
left: 0;
5254
right: 0;
5355
bottom: 0;
54-
height: auto !important;
55-
`
56-
: `
57-
max-height: ${MAX_HEIGHT}px;
56+
height: auto;
57+
` : `
58+
max-height: ${DEFAULT_MAX_HEIGHT}px;
5859
`
5960
}
6061
`;
@@ -63,6 +64,7 @@ const EditorMaxHeightContainer = styled.div`
6364
@observer
6465
export class SelfSizedEditor extends React.Component<
6566
Omit<EditorProps, 'onContentSizeChange'> & {
67+
maxHeight?: string;
6668
expanded?: boolean,
6769
uiStore?: UiStore // Injected automatically
6870
}
@@ -73,7 +75,7 @@ export class SelfSizedEditor extends React.Component<
7375

7476
@action.bound
7577
onContentSizeChange(contentUpdate: MonacoTypes.editor.IContentSizeChangedEvent) {
76-
this.contentHeight = Math.min(contentUpdate.contentHeight, MAX_HEIGHT);
78+
this.contentHeight = contentUpdate.contentHeight;
7779
}
7880

7981
onResize = _.throttle(() => {
@@ -101,10 +103,19 @@ export class SelfSizedEditor extends React.Component<
101103
@observable contentHeight: number = 0;
102104

103105
render() {
104-
return <EditorMaxHeightContainer
106+
return <EditorContainer
105107
ref={this.container}
106108
expanded={!!this.props.expanded}
107-
style={{ 'height': this.contentHeight + 'px' }}
109+
style={
110+
this.props.expanded
111+
? {}
112+
: {
113+
'height': this.contentHeight + 'px',
114+
// Override the CSS default where required (body cards) but carefully because
115+
// we use cqh, which isn't supported in all cases yet.
116+
'maxHeight': this.props.maxHeight
117+
}
118+
}
108119
onContextMenu={buildContextMenuCallback(
109120
this.props.uiStore!,
110121
!!this.props.options?.readOnly,
@@ -117,7 +128,7 @@ export class SelfSizedEditor extends React.Component<
117128
ref={this.editor}
118129
onContentSizeChange={this.onContentSizeChange}
119130
/>
120-
</EditorMaxHeightContainer>
131+
</EditorContainer>
121132
}
122133
}
123134

src/components/editor/content-viewer.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ interface ContentViewerProps {
2525
children: Buffer | string;
2626
schema?: SchemaObject;
2727
expanded: boolean;
28+
maxHeight?: string;
2829
headers?: Headers;
2930
contentType: ViewableContentType;
3031
editorNode: portals.HtmlPortalNode<typeof SelfSizedEditor | typeof ContainerSizedEditor>;
@@ -179,6 +180,7 @@ export class ContentViewer extends React.Component<ContentViewerProps> {
179180
value={content!}
180181
schema={this.props.schema}
181182
expanded={this.props.expanded}
183+
maxHeight={this.props.maxHeight}
182184
/>;
183185
}
184186
} catch (e) {

src/components/view/http/http-body-card.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,7 @@ export class HttpBodyCard extends React.Component<ExpandableCardProps & {
127127
contentType={decodedContentType}
128128
schema={apiBodySchema}
129129
expanded={!!expanded}
130+
maxHeight='70cqh'
130131
cache={message.cache}
131132
>
132133
{ message.body.decodedData }
@@ -181,6 +182,7 @@ export class HttpBodyCard extends React.Component<ExpandableCardProps & {
181182
contentType={encodedDataContentType}
182183
expanded={!!expanded}
183184
cache={message.cache}
185+
maxHeight='70cqh'
184186
>
185187
{ encodedBody }
186188
</ContentViewer>

src/components/view/http/http-breakpoint-body-card.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,7 @@ export class HttpBreakpointBodyCard extends React.Component<ExpandableCardProps
124124
value={bodyString}
125125
onChange={this.onBodyChange}
126126
expanded={!!expanded}
127+
maxHeight='50cqh'
127128
/>
128129
</EditorCardContent>
129130
</CollapsibleCard>;

src/components/view/view-details-pane.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ const PaneScrollOuterContainer = styled.div`
1717
padding: 0 20px 0 20px;
1818
1919
background-color: ${p => p.theme.containerBackground};
20+
21+
container-type: size;
2022
`;
2123

2224
const PaneScrollInnerContainer = styled.div`

0 commit comments

Comments
 (0)