Skip to content
Draft
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
10 changes: 10 additions & 0 deletions schema/app-meta.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,20 @@
"white"
],
"default": null
},
"/specta/showBorders": {
"title": "Show cell borders",
"type": "string",
"enum": ["Yes", "No"],
"default": "No"
}
}
},
"metadataOptions": {
"/specta/showBorders": {
"metadataLevel": "notebook",
"writeDefault": false
},
"/specta/hideTopbar": {
"metadataLevel": "notebook",
"writeDefault": false
Expand Down
12 changes: 8 additions & 4 deletions src/layout/article.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
import { Panel, Widget } from '@lumino/widgets';
import { SpectaCellOutput } from '../specta_cell_output';
import * as nbformat from '@jupyterlab/nbformat';
import { ISpectaLayout } from '../token';
import { ISpectaAppConfig, ISpectaLayout } from '../token';

class HostPanel extends Panel {
constructor() {
constructor(showBorders?: boolean) {
super();
this.addClass('specta-article-host-widget');
if (showBorders) {
this.addClass('specta-show-borders');
}
this._outputs = new Panel();
this._outputs.addClass('specta-article-outputs-panel');
this.addWidget(this._outputs);
Expand All @@ -23,9 +26,10 @@ export class ArticleLayout implements ISpectaLayout {
items: SpectaCellOutput[];
notebook: nbformat.INotebookContent;
readyCallback: () => Promise<void>;
spectaConfig?: ISpectaAppConfig;
}): Promise<void> {
const { host, items, readyCallback } = options;
const hostPanel = new HostPanel();
const { host, items, readyCallback, spectaConfig } = options;
const hostPanel = new HostPanel(spectaConfig?.showBorders);
for (const el of items) {
const cellModel = el.info.cellModel;
const info = el.info;
Expand Down
1 change: 1 addition & 0 deletions src/token.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ export interface ISpectaAppConfig {
topBar?: ITopbarConfig;
defaultLayout?: string;
hideTopbar?: boolean;
showBorders?: boolean;
slidesTheme?: string;
loadingName?: string;
executionDelay?: number;
Expand Down
6 changes: 6 additions & 0 deletions src/tool.ts
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,12 @@ export function readSpectaConfig({

const spectaMetadata = JSON.parse(JSON.stringify(nbMetadata?.specta ?? {}));

if (spectaMetadata.showBorders === 'Yes') {
spectaMetadata.showBorders = true;
} else if (spectaMetadata.showBorders === 'No') {
spectaMetadata.showBorders = false;
}

if (spectaMetadata.hideTopbar === 'Yes') {
spectaMetadata.hideTopbar = true;
} else if (spectaMetadata.hideTopbar === 'No') {
Expand Down
14 changes: 13 additions & 1 deletion style/article.css
Original file line number Diff line number Diff line change
Expand Up @@ -95,11 +95,22 @@
text-decoration: underline;
}

&.specta-show-borders {
pre,
.jp-InputArea-editor {
border: 1px solid var(--jp-cell-editor-border-color) !important;
}
.jp-OutputArea {
border: 1px solid var(--jp-border-color2, var(--jp-cell-editor-border-color)) !important;
border-radius: 4px;
}
}

pre {
background-color: var(--jp-cell-editor-background) !important;
padding: 32px !important;
border-radius: 4px !important;
border: 1px solid var(--jp-cell-editor-border-color) !important;
border: none !important;
overflow-x: auto;
margin: 0 !important;
margin-top: 56px !important;
Expand Down Expand Up @@ -203,6 +214,7 @@
.jp-InputArea-editor {
padding: 32px !important;
border-radius: 4px !important;
border: none !important;
background-color: var(--jp-cell-editor-background) !important;
}
.jp-InputArea-editor > div.cm-editor {
Expand Down
Loading