Skip to content

Commit face7a1

Browse files
Increased main-panel width(#761)
1 parent 3d1adfa commit face7a1

File tree

1 file changed

+88
-15
lines changed

1 file changed

+88
-15
lines changed

packages/base/src/mainview/mainView.tsx

Lines changed: 88 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,34 @@ export class MainView extends React.Component<IProps, IStates> {
112112
constructor(props: IProps) {
113113
super(props);
114114

115+
const el = document.getElementById('main-panel');
116+
117+
if (el) {
118+
const setWidthOneHundred = (selector: string) => {
119+
(document.querySelector(selector) as HTMLElement).style.setProperty(
120+
'width',
121+
'100%',
122+
);
123+
};
124+
//We need to observe the size to counteract
125+
//What the default jupyter plugin will try
126+
//To do dynamically with the width
127+
const resizeObserver = new ResizeObserver(_ => {
128+
el.style.setProperty('width', '100%');
129+
el.style.setProperty('max-width', '100%');
130+
el?.style.setProperty('left', '0px');
131+
132+
setWidthOneHundred('#main-panel jp-toolbar');
133+
setWidthOneHundred('#main-panel .lm-SplitPanel ');
134+
135+
setWidthOneHundred(
136+
'#main-panel .lm-SplitPanel .lm-SplitPanel-child ',
137+
);
138+
});
139+
140+
resizeObserver.observe(el);
141+
}
142+
115143
this._mainViewModel = this.props.viewModel;
116144
this._mainViewModel.viewSettingChanged.connect(this._onViewChanged, this);
117145

@@ -173,7 +201,9 @@ export class MainView extends React.Component<IProps, IStates> {
173201
this._sources = [];
174202
this._loadingLayers = new Set();
175203
this._commands = new CommandRegistry();
176-
this._contextMenu = new ContextMenu({ commands: this._commands });
204+
this._contextMenu = new ContextMenu({
205+
commands: this._commands,
206+
});
177207
}
178208

179209
async componentDidMount(): Promise<void> {
@@ -184,6 +214,7 @@ export class MainView extends React.Component<IProps, IStates> {
184214
? fromLonLat([options.longitude!, options.latitude!])
185215
: [0, 0];
186216
const zoom = options.zoom !== undefined ? options.zoom! : 1;
217+
187218
await this.generateMap(center, zoom);
188219
this.addContextMenu();
189220
this._mainViewModel.initSignal();
@@ -285,7 +316,13 @@ export class MainView extends React.Component<IProps, IStates> {
285316
return;
286317
}
287318
this._model.syncViewport(
288-
{ coordinates: { x: center[0], y: center[1] }, zoom },
319+
{
320+
coordinates: {
321+
x: center[0],
322+
y: center[1],
323+
},
324+
zoom,
325+
},
289326
this._mainViewModel.id,
290327
);
291328
}),
@@ -458,7 +495,10 @@ export class MainView extends React.Component<IProps, IStates> {
458495
}
459496

460497
this._mainViewModel.addAnnotation({
461-
position: { x: this._clickCoords[0], y: this._clickCoords[1] },
498+
position: {
499+
x: this._clickCoords[0],
500+
y: this._clickCoords[1],
501+
},
462502
zoom: this._Map.getView().getZoom() ?? 0,
463503
label: 'New annotation',
464504
contents: [],
@@ -538,7 +578,9 @@ export class MainView extends React.Component<IProps, IStates> {
538578
minZoom: sourceParameters.minZoom,
539579
maxZoom: sourceParameters.maxZoom,
540580
url: url,
541-
format: new MVT({ featureClass: RenderFeature }),
581+
format: new MVT({
582+
featureClass: RenderFeature,
583+
}),
542584
});
543585
} else {
544586
newSource = new PMTilesVectorSource({
@@ -916,7 +958,9 @@ export class MainView extends React.Component<IProps, IStates> {
916958
};
917959

918960
if (layerParameters.color) {
919-
layerOptions['style'] = { color: layerParameters.color };
961+
layerOptions['style'] = {
962+
color: layerParameters.color,
963+
};
920964
}
921965

922966
newMapLayer = new WebGlTileLayer(layerOptions);
@@ -1339,8 +1383,13 @@ export class MainView extends React.Component<IProps, IStates> {
13391383
return new Style({
13401384
image: new Circle({
13411385
radius: 6,
1342-
fill: new Fill({ color: 'rgba(255, 255, 0, 0.8)' }),
1343-
stroke: new Stroke({ color: '#ff0', width: 2 }),
1386+
fill: new Fill({
1387+
color: 'rgba(255, 255, 0, 0.8)',
1388+
}),
1389+
stroke: new Stroke({
1390+
color: '#ff0',
1391+
width: 2,
1392+
}),
13441393
}),
13451394
});
13461395
case 'LineString':
@@ -1388,7 +1437,10 @@ export class MainView extends React.Component<IProps, IStates> {
13881437
return new Promise(resolve => {
13891438
const checkReady = () => {
13901439
if (this._loadingLayers.size === 0) {
1391-
this.setState(old => ({ ...old, loadingLayer: false }));
1440+
this.setState(old => ({
1441+
...old,
1442+
loadingLayer: false,
1443+
}));
13921444
resolve();
13931445
} else {
13941446
setTimeout(checkReady, 50);
@@ -1454,7 +1506,10 @@ export class MainView extends React.Component<IProps, IStates> {
14541506
}
14551507

14561508
if (remoteState.user?.username !== this.state.remoteUser?.username) {
1457-
this.setState(old => ({ ...old, remoteUser: remoteState.user }));
1509+
this.setState(old => ({
1510+
...old,
1511+
remoteUser: remoteState.user,
1512+
}));
14581513
}
14591514

14601515
const remoteViewport = remoteState.viewportState;
@@ -1468,7 +1523,10 @@ export class MainView extends React.Component<IProps, IStates> {
14681523
} else {
14691524
// If we are unfollowing a remote user, we reset our center and zoom to their previous values
14701525
if (this.state.remoteUser !== null) {
1471-
this.setState(old => ({ ...old, remoteUser: null }));
1526+
this.setState(old => ({
1527+
...old,
1528+
remoteUser: null,
1529+
}));
14721530
const viewportState = localState.viewportState?.value;
14731531

14741532
if (viewportState) {
@@ -1506,14 +1564,26 @@ export class MainView extends React.Component<IProps, IStates> {
15061564
username: client.user.username,
15071565
displayName: client.user.display_name,
15081566
color: client.user.color,
1509-
coordinates: { x: pixel[0], y: pixel[1] },
1510-
lonLat: { longitude: lonLat[0], latitude: lonLat[1] },
1567+
coordinates: {
1568+
x: pixel[0],
1569+
y: pixel[1],
1570+
},
1571+
lonLat: {
1572+
longitude: lonLat[0],
1573+
latitude: lonLat[1],
1574+
},
15111575
};
15121576
} else {
15131577
currentClientPointer = {
15141578
...currentClientPointer,
1515-
coordinates: { x: pixel[0], y: pixel[1] },
1516-
lonLat: { longitude: lonLat[0], latitude: lonLat[1] },
1579+
coordinates: {
1580+
x: pixel[0],
1581+
y: pixel[1],
1582+
},
1583+
lonLat: {
1584+
longitude: lonLat[0],
1585+
latitude: lonLat[1],
1586+
},
15171587
};
15181588
}
15191589

@@ -1875,7 +1945,10 @@ export class MainView extends React.Component<IProps, IStates> {
18751945
// Zoom needs to be set before changing center
18761946
if (!view.animate === undefined) {
18771947
view.animate({ zoom, duration });
1878-
view.animate({ center: [center.x, center.y], duration });
1948+
view.animate({
1949+
center: [center.x, center.y],
1950+
duration,
1951+
});
18791952
}
18801953
}
18811954

0 commit comments

Comments
 (0)