This repository has been archived by the owner on Oct 5, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 63
/
GLRegion.jsx
132 lines (123 loc) · 4.01 KB
/
GLRegion.jsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
import React from 'react';
import PropTypes from 'prop-types';
import GoldenLayout from 'golden-layout';
import 'golden-layout/src/css/goldenlayout-base.css';
import 'golden-layout/src/css/goldenlayout-dark-theme.css';
/**
* React component for Golden Layout based region.
*
* @class GLRegion
* @extends {React.Component}
*/
class GLRegion extends React.Component {
constructor(props) {
super(props);
this.container = undefined;
}
componentDidMount() {
if (this.container) {
// create the layout
this.composerLayout = new GoldenLayout(this.props.layout, this.container);
this.composerLayout.registerComponent('testComponent', (container, componentState) => {
container.getElement().html('<h2>' + componentState.label + '</h2>');
});
this.composerLayout.init();
}
}
render() {
return (
<div className="dynamic-region" ref={(ref) => { this.container = ref; }} />
);
}
}
GLRegion.propTypes = {
layout: PropTypes.objectOf(Object),
};
GLRegion.defaultProps = {
layout: {
settings: {
constrainDragToContainer: true,
reorderEnabled: true,
selectionEnabled: false,
popoutWholeStack: false,
blockedPopoutsThrowError: true,
closePopoutsOnUnload: true,
showPopoutIcon: false,
showMaximiseIcon: false,
showCloseIcon: false,
},
dimensions: {
borderWidth: 2,
minItemHeight: 10,
minItemWidth: 10,
headerHeight: 35,
dragProxyWidth: 300,
dragProxyHeight: 200,
},
labels: {
close: 'close',
maximise: 'maximise',
minimise: 'minimise',
popout: 'open in new window',
},
content: [{
id: 'root',
type: 'column',
content: [{
id: 'body',
type: 'row',
content: [{
header: {
show: false,
},
width: 20,
id: 'left-panel',
type: 'component',
componentName: 'testComponent',
componentState: { label: 'Left' },
},
{
id: 'right-panel',
type: 'column',
content: [{
id: 'editor-area',
type: 'stack',
height: 70,
hasHeaders: true,
content: [{
title: 'file1.bal',
type: 'component',
componentName: 'testComponent',
componentState: { label: 'File1' },
},
{
title: 'file2.bal',
type: 'component',
componentName: 'testComponent',
componentState: { label: 'File2' },
}],
}, {
id: 'footer-area',
type: 'stack',
hasHeaders: true,
content: [{
title: 'debug output',
type: 'component',
componentName: 'testComponent',
componentState: { label: 'Debug output' },
},
{
title: 'console',
type: 'component',
componentName: 'testComponent',
componentState: { label: 'Console' },
}],
}],
},
],
},
],
}],
},
};
export default GLRegion;