Skip to content

Commit 29ff441

Browse files
authored
Merge pull request #2816 from jasongrout/fa5
Change fontawesome support to work for fontawesome 4 and 5.
2 parents 9b28600 + fd1323f commit 29ff441

File tree

3 files changed

+26
-30
lines changed

3 files changed

+26
-30
lines changed

packages/controls/css/widgets-base.css

Lines changed: 5 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -391,27 +391,17 @@
391391
font-size: var(--jp-widgets-font-size);
392392
}
393393

394-
.widget-valid i:before {
394+
.widget-valid i {
395395
line-height: var(--jp-widgets-inline-height);
396396
margin-right: var(--jp-widgets-inline-margin);
397397
margin-left: var(--jp-widgets-inline-margin);
398-
399-
/* from the fa class in FontAwesome: https://github.com/FortAwesome/Font-Awesome/blob/49100c7c3a7b58d50baa71efef11af41a66b03d3/css/font-awesome.css#L14 */
400-
display: inline-block;
401-
font: normal normal normal 14px/1 FontAwesome;
402-
font-size: inherit;
403-
text-rendering: auto;
404-
-webkit-font-smoothing: antialiased;
405-
-moz-osx-font-smoothing: grayscale;
406398
}
407399

408-
.widget-valid.mod-valid i:before {
409-
content: '\f00c';
400+
.widget-valid.mod-valid i {
410401
color: green;
411402
}
412403

413-
.widget-valid.mod-invalid i:before {
414-
content: '\f00d';
404+
.widget-valid.mod-invalid i {
415405
color: red;
416406
}
417407

@@ -953,6 +943,8 @@
953943
margin-left: 4px;
954944
}
955945

946+
/* This font-awesome strategy may not work across FA4 and FA5, but we don't
947+
actually support closable tabs, so it really doesn't matter */
956948
.jupyter-widgets.widget-tab
957949
> .p-TabBar
958950
.p-mod-closable
@@ -998,20 +990,6 @@
998990
border-bottom: none;
999991
}
1000992

1001-
.p-Collapse .p-Collapse-header::before {
1002-
content: '\f0da\00A0'; /* caret-right, non-breaking space */
1003-
display: inline-block;
1004-
font: normal normal normal 14px/1 FontAwesome;
1005-
font-size: inherit;
1006-
text-rendering: auto;
1007-
-webkit-font-smoothing: antialiased;
1008-
-moz-osx-font-smoothing: grayscale;
1009-
}
1010-
1011-
.p-Collapse-open > .p-Collapse-header::before {
1012-
content: '\f0d7\00A0'; /* caret-down, non-breaking space */
1013-
}
1014-
1015993
.p-Collapse-contents {
1016994
padding: var(--jp-widgets-container-padding);
1017995
background-color: var(--jp-layout-color1);

packages/controls/src/lumino/accordion.ts

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,13 @@ export class Collapse extends Widget {
4040
this._header = new Widget();
4141
this._header.addClass(COLLAPSE_HEADER_CLASS);
4242
this._header.node.addEventListener('click', this);
43+
// Fontawesome icon for caret
44+
const icon = document.createElement('i');
45+
icon.classList.add('fa', 'fa-fw', 'fa-caret-right');
46+
this._header.node.appendChild(icon);
47+
// Label content
48+
this._header.node.appendChild(document.createElement('span'));
49+
4350
this._content = new Panel();
4451
this._content.addClass(COLLAPSE_CONTENTS_CLASS);
4552

@@ -111,14 +118,19 @@ export class Collapse extends Widget {
111118
this._content.hide();
112119
}
113120
this.removeClass(COLLAPSE_CLASS_OPEN);
121+
this._header.node.children[0].classList.add('fa-caret-right');
122+
this._header.node.children[0].classList.remove('fa-caret-down');
114123
this._collapseChanged.emit(void 0);
115124
}
125+
116126
private _uncollapse(): void {
117127
this._collapsed = false;
118128
if (this._content) {
119129
this._content.show();
120130
}
121131
this.addClass(COLLAPSE_CLASS_OPEN);
132+
this._header.node.children[0].classList.add('fa-caret-down');
133+
this._header.node.children[0].classList.remove('fa-caret-right');
122134
this._collapseChanged.emit(void 0);
123135
}
124136

@@ -150,7 +162,7 @@ export class Collapse extends Widget {
150162
* Handle the `changed` signal of a title object.
151163
*/
152164
private _onTitleChanged(sender: Title<Widget>): void {
153-
this._header.node.textContent = this._widget.title.label;
165+
this._header.node.children[1].textContent = this._widget.title.label;
154166
}
155167

156168
private _onChildDisposed(sender: Widget): void {

packages/controls/src/widget_bool.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -306,8 +306,9 @@ export class ValidView extends DescriptionView {
306306
this.el.classList.add('jupyter-widgets');
307307
this.el.classList.add('widget-valid');
308308
this.el.classList.add('widget-inline-hbox');
309-
const icon = document.createElement('i');
310-
this.el.appendChild(icon);
309+
this.icon = document.createElement('i');
310+
this.icon.classList.add('fa', 'fa-fw');
311+
this.el.appendChild(this.icon);
311312
this.readout = document.createElement('span');
312313
this.readout.classList.add('widget-valid-readout');
313314
this.readout.classList.add('widget-readout');
@@ -324,12 +325,17 @@ export class ValidView extends DescriptionView {
324325
update(): void {
325326
this.el.classList.remove('mod-valid');
326327
this.el.classList.remove('mod-invalid');
328+
this.icon.classList.remove('fa-check');
329+
this.icon.classList.remove('fa-times');
327330
this.readout.textContent = this.model.get('readout');
328331
if (this.model.get('value')) {
329332
this.el.classList.add('mod-valid');
333+
this.icon.classList.add('fa-check');
330334
} else {
331335
this.el.classList.add('mod-invalid');
336+
this.icon.classList.add('fa-times');
332337
}
333338
}
334339
readout: HTMLSpanElement;
340+
icon: HTMLElement;
335341
}

0 commit comments

Comments
 (0)