Skip to content
This repository has been archived by the owner on Jan 26, 2022. It is now read-only.

Commit

Permalink
Merge pull request #523 from afshin/grid-theme-support
Browse files Browse the repository at this point in the history
Support themes in grid component.
  • Loading branch information
afshin committed Jul 30, 2020
2 parents 8fa2305 + 8a74b98 commit c88a0bb
Show file tree
Hide file tree
Showing 5 changed files with 211 additions and 159 deletions.
33 changes: 4 additions & 29 deletions src/index.ts
Expand Up @@ -334,31 +334,16 @@ const variables: JupyterFrontEndPlugin<void> = {
content: new VariablesBodyGrid({
model,
commands,
scopes: [{ name: title, variables }]
scopes: [{ name: title, variables }],
themeManager
})
});
widget.addClass('jp-DebuggerVariables');
widget.id = id;
widget.title.icon = variableIcon;
widget.title.label = `${service.session?.connection?.name} - ${title}`;
void tracker.add(widget);

model.changed.connect(() => widget.dispose());

if (themeManager) {
const updateStyle = (): void => {
const isLight = themeManager?.theme
? themeManager.isLight(themeManager.theme)
: true;
widget.content.theme = isLight ? 'light' : 'dark';
};
themeManager.themeChanged.connect(updateStyle);
widget.disposed.connect(() =>
themeManager.themeChanged.disconnect(updateStyle)
);
updateStyle();
}

shell.add(widget, 'main', {
mode: tracker.currentWidget ? 'split-right' : 'split-bottom'
});
Expand Down Expand Up @@ -480,7 +465,8 @@ const main: JupyterFrontEndPlugin<void> = {
const sidebar = new Debugger.Sidebar({
service,
callstackCommands,
editorServices
editorServices,
themeManager
});

if (settingRegistry) {
Expand All @@ -500,17 +486,6 @@ const main: JupyterFrontEndPlugin<void> = {
service.sessionChanged.connect(updateSettings);
}

if (themeManager) {
const updateStyle = (): void => {
const isLight = themeManager?.theme
? themeManager.isLight(themeManager.theme)
: true;
sidebar.variables.theme = isLight ? 'light' : 'dark';
};
themeManager.themeChanged.connect(updateStyle);
updateStyle();
}

service.eventMessage.connect((_, event): void => {
commands.notifyCommandChanged();
if (labShell && event.event === 'initialized') {
Expand Down

0 comments on commit c88a0bb

Please sign in to comment.