Skip to content

Commit d1482b6

Browse files
committed
working on passing classes in
1 parent eb0e6cc commit d1482b6

File tree

2 files changed

+41
-11
lines changed

2 files changed

+41
-11
lines changed

packages/nbdime/src/diff/widget/linked-cells.ts

Lines changed: 30 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,35 @@
11
import { Panel, Widget } from "@lumino/widgets";
22
import type { CellDiffWidget } from "./";
3+
import { LabIcon } from "@jupyterlab/ui-components";
34

45
import foldDown from "./fold-down.svg";
56
import foldUp from "./fold-up.svg";
67
import fold from "./fold.svg";
78

9+
export const foldDownIcon = new LabIcon({
10+
name: "nbdime:fold-down",
11+
svgstr: foldDown
12+
});
13+
14+
export const foldUpIcon = new LabIcon({
15+
name: "nbdime:fold-up",
16+
svgstr: foldUp
17+
});
18+
19+
export const foldIcon = new LabIcon({
20+
name: "nbdime:fold",
21+
svgstr: fold
22+
});
23+
24+
export interface ILinkedListCell {
25+
next: () => ILinkedListCell | null;
26+
prev: () => ILinkedListCell | null;
27+
displayed: () => boolean;
28+
lazy: boolean;
29+
expandUp: () => void;
30+
expandDown: () => void;
31+
}
32+
833
class LinkedListCell extends Panel {
934
_next: LinkedListCell | LazyDisplayLinkedListCell | null;
1035
_prev: LinkedListCell | LazyDisplayLinkedListCell | null;
@@ -159,19 +184,15 @@ class LazyDisplayLinkedListCell extends LinkedListCell {
159184
const button = document.createElement("a");
160185
button.title = `Expand ${direction}`;
161186
button.setAttribute("aria-label", `Expand ${direction}`);
162-
button.innerHTML = this.buttonSvg(direction);
163-
if (direction === "Up") {
164-
button.innerHTML = foldUp;
165-
} else if (direction === "Down") {
166-
button.innerHTML = foldDown;
167-
} else {
168-
button.innerHTML = fold;
169-
}
187+
let icon = this.buttonSvg(direction);
188+
icon.element({
189+
container: button,
190+
})
170191
this.expandButtonDisplayed = true;
171192
return button;
172193
}
173194

174-
buttonSvg(direction: "Up" | "Down" | "Fold"): string {
195+
buttonSvg(direction: "Up" | "Down" | "Fold"): LabIcon {
175196
if (direction === "Up") {
176197
return foldUp;
177198
} else if (direction === "Down") {

packages/nbdime/src/diff/widget/notebook.ts

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import { Panel } from "@lumino/widgets";
66

77
import { IRenderMimeRegistry } from "@jupyterlab/rendermime";
8-
import { LazyDisplayLinkedListCell, LinkedListCell } from "./linked-cells";
8+
import { ILinkedListCell, LazyDisplayLinkedListCell, LinkedListCell } from "./linked-cells";
99
import { CellDiffWidget } from "./cell";
1010
import {
1111
CHUNK_PANEL_CLASS,
@@ -23,12 +23,19 @@ const NBDIFF_CLASS = "jp-Notebook-diff";
2323
* NotebookDiffWidget
2424
*/
2525
export class NotebookDiffWidget extends Panel {
26-
constructor(model: NotebookDiffModel, rendermime: IRenderMimeRegistry) {
26+
constructor(
27+
model: NotebookDiffModel,
28+
rendermime: IRenderMimeRegistry,
29+
displayedCellWrapper: ILinkedListCell = LinkedListCell,
30+
lazyDisplayWrapper: ILinkedListCell = LazyDisplayLinkedListCell
31+
) {
2732
super();
2833
this._model = model;
2934
this._rendermime = rendermime;
3035
this.addClass(NBDIFF_CLASS);
3136
this.previousCell = null;
37+
this.displayedCellWrapper = displayedCellWrapper;
38+
this.lazyDisplayWrapper = lazyDisplayWrapper;
3239
}
3340

3441
/**
@@ -136,4 +143,6 @@ export class NotebookDiffWidget extends Panel {
136143
private _model: NotebookDiffModel;
137144
private _rendermime: IRenderMimeRegistry;
138145
private previousCell: LinkedListCell | null;
146+
private displayedCellWrapper: LinkedListCell;
147+
private lazyDisplayWrapper: LazyDisplayLinkedListCell;
139148
}

0 commit comments

Comments
 (0)