Skip to content

Commit e3a7977

Browse files
load and set basic data table view and headers styles (#46)
1 parent 2e7fc62 commit e3a7977

File tree

3 files changed

+36
-2
lines changed

3 files changed

+36
-2
lines changed

src/renderer/index.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import type {
44
}
55
from 'vscode-notebook-renderer';
66
import errorOverlay from 'vscode-notebook-error-overlay';
7-
import { render } from './render';
7+
import {render} from './render';
88

99
// eslint-disable-next-line @typescript-eslint/naming-convention
1010
declare const __webpack_relative_entrypoint_to_root__: string;
@@ -19,6 +19,7 @@ export const activate: ActivationFunction = context => {
1919
renderOutputItem(outputItem: OutputItem, element: HTMLElement) {
2020
errorOverlay.wrap(element, () => {
2121
const cellOutputContainer: HTMLDivElement = document.createElement('div');
22+
cellOutputContainer.className = 'data-table';
2223
element.appendChild(cellOutputContainer);
2324
render({
2425
container: cellOutputContainer,

src/renderer/render.ts

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,9 @@ export function render(output: IRenderInfo) {
3434
break;
3535
}
3636

37+
// add data table view styles
38+
addStyles(document);
39+
3740
if (Array.isArray(data)) {
3841
// create data table view
3942
const table = inputs.table(data, {
@@ -84,3 +87,24 @@ if (module.hot) {
8487

8588
return 0;
8689
}
90+
91+
function addStyles(document: HTMLDocument): HTMLStyleElement {
92+
const styles: HTMLStyleElement = document.createElement('style');
93+
document.head.appendChild(styles);
94+
styles.textContent = `
95+
.data-table {
96+
max-width: 100%;
97+
background-color: var(--vscode-editor-background);
98+
border: 1px solid var(--vscode-panel-border);
99+
}
100+
101+
.data-table form {
102+
margin: 0px !important;
103+
}
104+
105+
.data-table form table thead th {
106+
background-color: var(--vscode-editor-background) !important;
107+
}
108+
`;
109+
return styles;
110+
}

src/renderer/style.css

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,13 @@
11
.data-table {
22
max-width: 100%;
3-
overflow-y: scroll;
3+
background-color: var(--vscode-editor-background);
4+
border: 1px solid var(--vscode-panel-border);
5+
}
6+
7+
.data-table form {
8+
margin: 0px !important;
9+
}
10+
11+
.data-table form table thead th {
12+
background-color: var(--vscode-editor-background) !important;
413
}

0 commit comments

Comments
 (0)