Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Optionally shows the code cell prompt (execution count) #70

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions js/jupyterlab-deck/schema/plugin.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,12 @@
"default": false,
"description": "Whether presentation mode is currently active."
},
"showCodeCellPrompt": {
"title": "Show execution count",
"type": "boolean",
"default": false,
"description": "Whether to show the execution count (input prompt) in Notebook presentation"
},
"stylePresets": {
"title": "Style Presets",
"$ref": "#/definitions/style-presets",
Expand Down
11 changes: 11 additions & 0 deletions js/jupyterlab-deck/src/manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ export class DeckManager implements IDeckManager {
protected _layover: Layover | null = null;
protected _activePresenter: IPresenter<Widget> | null = null;
protected _activeWidgetStack: Widget[] = [];
protected _showCodeCellPrompt: boolean = false;

constructor(options: DeckManager.IOptions) {
this._appStarted = options.appStarted;
Expand Down Expand Up @@ -107,6 +108,10 @@ export class DeckManager implements IDeckManager {
return this._layoverChanged;
}

public get showCodeCellPrompt(): boolean {
return this._showCodeCellPrompt
}

/**
* translate a string by message id (usually the en-US string), potentially
* with positional arguments, starting with %1.
Expand Down Expand Up @@ -525,6 +530,12 @@ export class DeckManager implements IDeckManager {
composite = settings.composite as IDeckSettings;
const active = composite.active === true;

const showCodeCellPrompt = composite.showCodeCellPrompt === true;
if (showCodeCellPrompt !== this._showCodeCellPrompt) {
this._showCodeCellPrompt = showCodeCellPrompt;
void this._addDeckStyles();
}

if (active && !this._active) {
void this.start();
} else if (!active && this._active) {
Expand Down
5 changes: 5 additions & 0 deletions js/jupyterlab-deck/src/notebook/presenter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,11 @@ export class NotebookPresenter implements IPresenter<NotebookPanel> {

public async style(panel: NotebookPanel): Promise<void> {
panel.addClass(CSS.deck);
if (this._manager.showCodeCellPrompt) {
panel.addClass(CSS.showCodeCellPrompt);
} else {
panel.removeClass(CSS.showCodeCellPrompt);
}
this._manager.cacheStyle(panel.node, panel.content.node);
}

Expand Down
3 changes: 3 additions & 0 deletions js/jupyterlab-deck/src/tokens.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ export interface IDeckManager {
setLayerScope(layerScope: TLayerScope | null): void;
getPartStyles(): GlobalStyles | null;
setPartStyles(styles: GlobalStyles | null): void;
readonly showCodeCellPrompt: boolean;
}

export const IDeckManager = new Token<IDeckManager>(PLUGIN_ID);
Expand Down Expand Up @@ -128,6 +129,7 @@ export namespace CSS {
export const stop = 'jp-deck-mod-stop';
export const widgetStack = 'jp-Deck-Remote-WidgetStack';
// notebook
export const showCodeCellPrompt = 'jp-deck-showCodeCellPrompt';
export const direction = 'jp-deck-mod-direction';
export const onScreen = 'jp-deck-mod-onscreen';
export const visible = 'jp-deck-mod-visible';
Expand Down Expand Up @@ -266,6 +268,7 @@ export interface IStylePreset {

export interface IDeckSettings {
active?: boolean;
showCodeCellPrompt?: boolean;
stylePresets?: {
[key: string]: Partial<IStylePreset>;
};
Expand Down
16 changes: 14 additions & 2 deletions js/jupyterlab-deck/style/notebook.css
Original file line number Diff line number Diff line change
@@ -1,11 +1,23 @@
/** heavy ui tweaks **/
.jp-Deck .jp-InputPrompt,
.jp-Deck .jp-OutputPrompt,
.jp-Deck:not(.jp-deck-showCodeCellPrompt) .jp-InputPrompt,
.jp-Deck:not(.jp-deck-showCodeCellPrompt) .jp-OutputPrompt,
.jp-Deck .jp-Notebook-footer,
.jp-Deck .jp-cell-toolbar {
display: none;
}

.jp-Deck.jp-deck-showCodeCellPrompt .jp-InputPrompt,
.jp-Deck.jp-deck-showCodeCellPrompt .jp-OutputPrompt {
/* uses visibility instead of display to keep alignment between markdown and code cell */
visibility: hidden;
}

.jp-Deck.jp-deck-showCodeCellPrompt .jp-CodeCell .jp-InputPrompt,
.jp-Deck.jp-deck-showCodeCellPrompt .jp-CodeCell .jp-OutputPrompt {
display: inherit;
visibility: inherit;
}

.jp-Deck .jp-NotebookPanel-toolbar {
position: absolute;
border: 0;
Expand Down