Skip to content

Commit 1718357

Browse files
authored
Allow code editor to be resized (elyra-ai#729)
Update the metadata code editor components so they can be resized.
1 parent a52f270 commit 1718357

File tree

3 files changed

+56
-26
lines changed

3 files changed

+56
-26
lines changed

packages/code-snippet/style/index.css

+12-7
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,11 @@
5555
fill: var(--jp-ui-font-color1);
5656
}
5757

58+
.elyra-codeSnippetsHeader + div:first-of-type {
59+
overflow-y: auto;
60+
height: calc(100vh - 95px);
61+
}
62+
5863
.elyra-codeSnippet-item {
5964
border-bottom: var(--jp-border-width) solid var(--jp-border-color2);
6065
display: flex;
@@ -63,18 +68,18 @@
6368
padding: 0;
6469
}
6570

66-
.elyra-codeSnippet-item .CodeMirror-wrap {
71+
.elyra-codeSnippet-item .elyra-expandableContainer-details-visible {
72+
background-color: var(--jp-cell-editor-background);
73+
resize: vertical;
74+
height: 100px;
75+
}
76+
77+
.elyra-codeSnippet-item .CodeMirror.cm-s-jupyter {
6778
background-color: inherit;
6879
border: none;
6980
font-family: var(--jp-code-font-family);
7081
font-size: var(--jp-code-font-size);
7182
line-height: var(--jp-code-line-height);
72-
height: 100%;
73-
width: 100%;
74-
resize: vertical;
75-
white-space: pre;
76-
word-wrap: normal;
77-
overflow-x: scroll;
7883
}
7984

8085
.elyra-codeSnippet-saveButton {

packages/metadata-editor/src/MetadataEditor.tsx

+9-4
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
* limitations under the License.
1515
*/
1616

17-
import { FormGroup, Intent } from '@blueprintjs/core';
17+
import { FormGroup, Intent, ResizeSensor } from '@blueprintjs/core';
1818

1919
import { FrontendServices, IDictionary } from '@elyra/application';
2020
import { DropDown } from '@elyra/ui-components';
@@ -343,13 +343,19 @@ export class MetadataEditor extends ReactWidget {
343343
}
344344
return (
345345
<FormGroup
346-
style={{ width: '100%', display: 'flex' }}
346+
className={'elyra-metadataEditor-code'}
347347
labelInfo={required}
348348
label={'Code'}
349349
intent={this.schema[fieldName].uihints.intent}
350350
helperText={helperText}
351351
>
352-
<div id={'code:' + this.id} className="elyra-form-code"></div>
352+
<ResizeSensor
353+
onResize={(): void => {
354+
this.editor.refresh();
355+
}}
356+
>
357+
<div id={'code:' + this.id} className="elyra-form-code va-va"></div>
358+
</ResizeSensor>
353359
</FormGroup>
354360
);
355361
} else {
@@ -373,7 +379,6 @@ export class MetadataEditor extends ReactWidget {
373379
return (
374380
<div className={ELYRA_METADATA_EDITOR_CLASS}>
375381
<h3> {headerText} </h3>
376-
<br />
377382
{this.renderTextInput(
378383
'Name',
379384
'',

packages/metadata-editor/style/index.css

+35-15
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@
33
}
44

55
.elyra-metadataEditor .bp3-form-group {
6-
width: 40%;
7-
float: left;
86
margin-bottom: 12px;
97
margin-right: 20px;
8+
flex-basis: 40%;
9+
height: 65px;
1010
}
1111

1212
.bp3-select-popover {
@@ -23,40 +23,60 @@
2323
}
2424

2525
.elyra-metadataEditor {
26-
margin: 20px;
26+
padding: 20px;
2727
display: flex;
2828
flex-wrap: wrap;
29+
height: 100%;
30+
align-content: flex-start;
31+
align-items: flex-start;
32+
justify-content: flex-start;
2933
}
3034

3135
.elyra-metadataEditor h3 {
32-
width: 100%;
33-
margin-bottom: 10px;
36+
flex-basis: 100%;
37+
margin-bottom: 15px;
3438
color: var(--jp-ui-font-color1);
3539
}
3640

3741
.elyra-metadataEditor label.bp3-label {
3842
color: var(--jp-ui-font-color1);
3943
}
4044

41-
.elyra-metadataEditor .CodeMirror-wrap {
45+
.elyra-metadataEditor .elyra-form-code.jp-CodeMirrorEditor {
46+
background-color: var(--jp-cell-editor-background);
47+
border: var(--jp-border-width) solid var(--jp-input-border-color);
48+
overflow-y: auto;
49+
resize: vertical;
50+
min-height: 150px;
51+
height: 150px;
52+
padding-bottom: 10px;
53+
cursor: initial;
54+
}
55+
56+
.elyra-metadataEditor .CodeMirror.cm-s-jupyter {
4257
background-color: inherit;
43-
box-shadow: inset 0 0 0 var(--jp-border-width) var(--jp-input-border-color);
44-
font-family: var(--jp-code-font-family);
45-
font-size: var(--jp-code-font-size);
46-
line-height: var(--jp-code-line-height);
4758
height: 100%;
48-
width: 100%;
49-
resize: vertical;
50-
white-space: pre;
51-
word-wrap: normal;
52-
overflow: scroll;
59+
}
60+
61+
.elyra-metadataEditor .bp3-form-group.elyra-metadataEditor-code {
62+
height: auto;
63+
flex-basis: 100%;
64+
display: flex;
65+
}
66+
67+
.elyra-metadataEditor-code .bp3-form-content {
68+
height: 100%;
5369
}
5470

5571
.bp3-dark .bp3-input {
5672
border: var(--jp-border-width) solid var(--jp-input-border-color);
5773
color: var(--jp-ui-font-color1);
5874
}
5975

76+
.elyra-metadata-editor {
77+
overflow-y: auto;
78+
}
79+
6080
.elyra-metadata-editor.bp3-dark {
6181
background-color: var(--jp-border-color3);
6282
}

0 commit comments

Comments
 (0)