Skip to content

Commit 71ceee7

Browse files
committed
design improvement bug fixes
1 parent 6fde523 commit 71ceee7

File tree

2 files changed

+41
-18
lines changed

2 files changed

+41
-18
lines changed

src/widget.ts

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ import { CodeCell, MarkdownCell } from '@jupyterlab/cells';
44

55
import { Widget } from '@lumino/widgets';
66

7+
import { MessageLoop } from '@lumino/messaging';
8+
79
import { UUID, MimeData } from '@lumino/coreutils';
810

911
import { ArrayExt } from '@lumino/algorithm';
@@ -130,8 +132,20 @@ export class DashboardWidget extends Widget {
130132
this.node.style.opacity = '0';
131133

132134
container.classList.add(DASHBOARD_WIDGET_CHILD_CLASS);
133-
container.appendChild(clone.node);
134-
this.node.appendChild(container);
135+
136+
// Fake an attach in order to render LaTeX properly.
137+
// Note: This is not how you should use Lumino widgets.
138+
if (this.parent) {
139+
if (this.parent!.isAttached) {
140+
MessageLoop.sendMessage(clone, Widget.Msg.BeforeAttach);
141+
container.appendChild(clone.node);
142+
this.node.appendChild(container);
143+
if (this.parent!.isAttached) {
144+
MessageLoop.sendMessage(clone, Widget.Msg.AfterAttach);
145+
}
146+
}
147+
}
148+
135149
this._content = clone;
136150

137151
const done = (): void => {
@@ -421,7 +435,7 @@ export class DashboardWidget extends Widget {
421435
* Fit widget width/height to the width/height of the underlying content.
422436
*/
423437
fitContent(): void {
424-
const element = this._content.node;
438+
const element = this._content.node.firstChild as HTMLElement;
425439
// Pixels are added to prevent weird wrapping issues. Kind of a hack.
426440
this.pos = {
427441
width: element.clientWidth + 3,

style/base.css

Lines changed: 24 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@
44

55
.pr-DashboardWidget {
66
display: inline-flex;
7-
align-items: center;
8-
justify-content: center;
97
}
108

119
.pr-DashboardWidget .pr-MarkdownOutput {
@@ -14,7 +12,7 @@
1412

1513
.pr-EditableWidget {
1614
outline: var(--jp-border-width) solid var(--jp-inverse-layout-color4);
17-
outline-offset: calc( -1 * var(--jp-border-width));
15+
outline-offset: calc(-1 * var(--jp-border-width));
1816
background: var(--jp-layout-color0);
1917
overflow: visible;
2018
}
@@ -25,12 +23,12 @@
2523

2624
.pr-EditableWidget:focus {
2725
outline: var(--jp-border-width) solid var(--jp-brand-color1);
28-
outline-offset: calc( -1 * var(--jp-border-width));
26+
outline-offset: calc(-1 * var(--jp-border-width));
2927
}
3028

3129
.pr-EditableWidget:hover {
3230
outline: var(--jp-border-width) solid var(--jp-brand-color1);
33-
outline-offset: calc( -1 * var(--jp-border-width));
31+
outline-offset: calc(-1 * var(--jp-border-width));
3432
cursor: move;
3533
}
3634

@@ -77,7 +75,12 @@
7775
}
7876

7977
.pr-DashboardWidgetChild {
80-
display: inline-block;
78+
/* width: 100%;
79+
height: 100%; */
80+
overflow: hidden;
81+
display: inline-flex;
82+
align-items: center;
83+
justify-content: center;
8184
}
8285

8386
.pr-EditableWidget:focus .pr-Resizer {
@@ -89,18 +92,24 @@
8992
}
9093

9194
.pr-Canvas.pr-FreeLayout {
92-
background-image:
93-
linear-gradient(to right, #E5E5E5 1px, transparent 1px),
94-
linear-gradient(to bottom, #E5E5E5 1px, transparent 1px);
95-
background-color: white;
95+
background-image: linear-gradient(
96+
to right,
97+
var(--jp-border-color2) 1px,
98+
transparent 1px
99+
),
100+
linear-gradient(to bottom, var(--jp-border-color2) 1px, transparent 1px);
101+
background-color: var(--jp-cell-editor-background);
96102
background-size: 10px 10px;
97103
}
98104

99105
.pr-Canvas.pr-TiledLayout {
100-
background-image:
101-
linear-gradient(to right, #E5E5E5 1px, transparent 1px),
102-
linear-gradient(to bottom, #E5E5E5 1px, transparent 1px);
103-
background-color: white;
106+
background-image: linear-gradient(
107+
to right,
108+
var(--jp-border-color2) 1px,
109+
transparent 1px
110+
),
111+
linear-gradient(to bottom, var(--jp-border-color2) 1px, transparent 1px);
112+
background-color: var(--jp-cell-editor-background);
104113
background-size: 32px 32px;
105114
}
106115

@@ -144,5 +153,5 @@ select.pr-ToolbarSelector.jp-mod-styled {
144153
.pr-DragImage {
145154
box-shadow: var(--jp-elevation-z1);
146155
outline: var(--jp-border-width) solid var(--jp-brand-color1);
147-
outline-offset: calc( -1 * var(--jp-border-width));
156+
outline-offset: calc(-1 * var(--jp-border-width));
148157
}

0 commit comments

Comments
 (0)