1 | import * as React from 'react';
|
2 | import { VDomModel, VDomRenderer } from '@jupyterlab/apputils';
|
3 | import '../style/license.css';
|
4 | const WRAPPER_CLASS = 'jp-LicenseViewer-wrapper';
|
5 | const LICENSE_CLASS = 'jp-LicenseViewer';
|
6 | export class LicenseViewer extends VDomRenderer {
|
7 | constructor(options) {
|
8 | super(new LicenseViewer.Model(options));
|
9 | }
|
10 | render() {
|
11 | this.addClass(WRAPPER_CLASS);
|
12 | let m = this.model;
|
13 |
|
14 | if (!m) {
|
15 | return React.createElement(React.Fragment, null);
|
16 | }
|
17 | const text = m.licenseText ? React.createElement("pre", null, m.licenseText) : React.createElement(React.Fragment, null);
|
18 | return (React.createElement("div", { className: LICENSE_CLASS },
|
19 | React.createElement("h1", null, m.font.name),
|
20 | React.createElement("h2", null, m.font.license.name),
|
21 | text));
|
22 | }
|
23 | }
|
24 | (function (LicenseViewer) {
|
25 | class Model extends VDomModel {
|
26 | constructor(options) {
|
27 | super();
|
28 | this.font = options.font;
|
29 | console.log(this._font);
|
30 | }
|
31 | get font() {
|
32 | return this._font;
|
33 | }
|
34 | set font(font) {
|
35 | this._font = font;
|
36 | this.stateChanged.emit(void 0);
|
37 | this._licenseTextPromise = new Promise(async (resolve, reject) => {
|
38 | console.log('awaiting');
|
39 | this._licenseText = await this._font.license.text();
|
40 | console.log('resolved');
|
41 | this.stateChanged.emit(void 0);
|
42 | resolve(this._licenseText);
|
43 | });
|
44 | }
|
45 | get licenseText() {
|
46 | return this._licenseText;
|
47 | }
|
48 | get licenseTextPromise() {
|
49 | return this._licenseTextPromise;
|
50 | }
|
51 | }
|
52 | LicenseViewer.Model = Model;
|
53 | })(LicenseViewer || (LicenseViewer = {}));
|
54 |
|
\ | No newline at end of file |