Skip to content

Change phosphor to Lumino #2681

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jan 7, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions examples/web1/manager.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
var base = require('@jupyter-widgets/base');
var controls = require('@jupyter-widgets/controls');
var PhosphorWidget = require('@lumino/widgets').Widget;
var LuminoWidget = require('@lumino/widgets').Widget;

class WidgetManager extends base.ManagerBase {
constructor(el) {
Expand Down Expand Up @@ -38,7 +38,7 @@ class WidgetManager extends base.ManagerBase {
display_view(msg, view, options) {
var that = this;
return Promise.resolve(view).then(function(view) {
PhosphorWidget.attach(view.pWidget, that.el);
LuminoWidget.attach(view.pWidget, that.el);
view.on('remove', function() {
console.log('View removed', view);
});
Expand Down
4 changes: 2 additions & 2 deletions examples/web2/manager.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
var base = require('@jupyter-widgets/base');
var controls = require('@jupyter-widgets/controls');
var PhosphorWidget = require('@lumino/widgets').Widget;
var LuminoWidget = require('@lumino/widgets').Widget;

class WidgetManager extends base.ManagerBase {
constructor(el) {
Expand Down Expand Up @@ -38,7 +38,7 @@ class WidgetManager extends base.ManagerBase {
display_view(msg, view, options) {
var that = this;
return Promise.resolve(view).then(function(view) {
PhosphorWidget.attach(view.pWidget, that.el);
LuminoWidget.attach(view.pWidget, that.el);
view.on('remove', function() {
console.log('View removed', view);
});
Expand Down
28 changes: 14 additions & 14 deletions packages/base/src/widget.ts
Original file line number Diff line number Diff line change
Expand Up @@ -717,16 +717,16 @@ export namespace WidgetView {
}

export
namespace JupyterPhosphorWidget {
namespace JupyterLuminoWidget {
export
interface IOptions {
view: DOMWidgetView;
}
}

export
class JupyterPhosphorWidget extends Widget {
constructor(options: Widget.IOptions & JupyterPhosphorWidget.IOptions) {
class JupyterLuminoWidget extends Widget {
constructor(options: Widget.IOptions & JupyterLuminoWidget.IOptions) {
let view = options.view;
delete options.view;
super(options);
Expand All @@ -750,37 +750,37 @@ class JupyterPhosphorWidget extends Widget {
}

/**
* Process the phosphor message.
* Process the Lumino message.
*
* Any custom phosphor widget used inside a Jupyter widget should override
* Any custom Lumino widget used inside a Jupyter widget should override
* the processMessage function like this.
*/
processMessage(msg: Message) {
super.processMessage(msg);
this._view.processPhosphorMessage(msg);
this._view.processLuminoMessage(msg);
}

private _view: DOMWidgetView;
}

export
class JupyterPhosphorPanelWidget extends Panel {
constructor(options: JupyterPhosphorWidget.IOptions & Panel.IOptions) {
class JupyterLuminoPanelWidget extends Panel {
constructor(options: JupyterLuminoWidget.IOptions & Panel.IOptions) {
let view = options.view;
delete options.view;
super(options);
this._view = view;
}

/**
* Process the phosphor message.
* Process the Lumino message.
*
* Any custom phosphor widget used inside a Jupyter widget should override
* Any custom Lumino widget used inside a Jupyter widget should override
* the processMessage function like this.
*/
processMessage(msg: Message) {
super.processMessage(msg);
this._view.processPhosphorMessage(msg);
this._view.processLuminoMessage(msg);
}

/**
Expand Down Expand Up @@ -877,7 +877,7 @@ class DOMWidgetView extends WidgetView {
return this.displayed.then(() => {
view.trigger('displayed');
// Unlike for the layout attribute, style changes don't
// trigger phosphor resize messages.
// trigger Lumino resize messages.
return view;
});
}).catch(utils.reject('Could not add styleView to DOMWidgetView', true));
Expand Down Expand Up @@ -954,7 +954,7 @@ class DOMWidgetView extends WidgetView {

this.$el = el instanceof $ ? el : $(el);
this.el = this.$el[0];
this.pWidget = new JupyterPhosphorWidget({
this.pWidget = new JupyterLuminoWidget({
node: el,
view: this
});
Expand All @@ -967,7 +967,7 @@ class DOMWidgetView extends WidgetView {
return super.remove();
}

processPhosphorMessage(msg: Message) {
processLuminoMessage(msg: Message) {
// tslint:disable-next-line:switch-default
switch (msg.type) {
case 'after-attach':
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,33 @@
/* This file has code derived from PhosphorJS CSS files, as noted below. The license for this PhosphorJS code is:
/* This file has code derived from Lumino CSS files, as noted below. The license for this Lumino code is:

Copyright (c) 2019 Project Jupyter Contributors
All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:

1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.

2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.

3. Neither the name of the copyright holder nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.


Copyright (c) 2014-2017, PhosphorJS Contributors
All rights reserved.
Expand Down Expand Up @@ -27,11 +56,10 @@ SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

*/

/*
* The following section is derived from https://github.com/phosphorjs/phosphor/blob/23b9d075ebc5b73ab148b6ebfc20af97f85714c4/packages/widgets/style/tabbar.css
* The following section is derived from https://github.com/jupyterlab/lumino/blob/23b9d075ebc5b73ab148b6ebfc20af97f85714c4/packages/widgets/style/tabbar.css
* We've scoped the rules so that they are consistent with exactly our code.
*/

Expand Down
2 changes: 1 addition & 1 deletion packages/controls/css/widgets-base.css
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
* have been defined.
*/

@import "./phosphor.css";
@import "./lumino.css";

:root {
--jp-widgets-color: var(--jp-content-font-color1);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,33 @@
/* This file has code derived from PhosphorJS. The license for this PhosphorJS code is:
/* This file has code derived from Lumino. The license for this Lumino code is:

Copyright (c) 2019 Project Jupyter Contributors
All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:

1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.

2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.

3. Neither the name of the copyright holder nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.


Copyright (c) 2014-2017, PhosphorJS Contributors
All rights reserved.
Expand Down Expand Up @@ -27,7 +56,6 @@ SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

*/

import {
Expand Down Expand Up @@ -149,7 +177,7 @@ class TabPanel extends Widget {
*/
get currentIndex(): number | null {
const currentIndex = this.tabBar.currentIndex;
// Phosphor tab bars have an index of -1 if no tab is selected
// Lumino tab bars have an index of -1 if no tab is selected
return (currentIndex === -1 ? null : currentIndex);
}

Expand Down
6 changes: 3 additions & 3 deletions packages/controls/src/widget_box.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Distributed under the terms of the Modified BSD License.

import {
DOMWidgetView, unpack_models, ViewList, JupyterPhosphorPanelWidget, WidgetModel
DOMWidgetView, unpack_models, ViewList, JupyterLuminoPanelWidget, WidgetModel
} from '@jupyter-widgets/base';

import {
Expand Down Expand Up @@ -69,7 +69,7 @@ export
class BoxView extends DOMWidgetView {

_createElement(tagName: string) {
this.pWidget = new JupyterPhosphorPanelWidget({ view: this });
this.pWidget = new JupyterLuminoPanelWidget({ view: this });
return this.pWidget.node;
}

Expand Down Expand Up @@ -138,7 +138,7 @@ class BoxView extends DOMWidgetView {
}

children_views: ViewList<DOMWidgetView>;
pWidget: JupyterPhosphorPanelWidget;
pWidget: JupyterLuminoPanelWidget;

static class_map = {
success: ['alert', 'alert-success'],
Expand Down
6 changes: 3 additions & 3 deletions packages/controls/src/widget_controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
} from './widget_core';

import {
DOMWidgetView, unpack_models, ViewList, JupyterPhosphorPanelWidget
DOMWidgetView, unpack_models, ViewList, JupyterLuminoPanelWidget
} from '@jupyter-widgets/base';

import {
Expand Down Expand Up @@ -325,7 +325,7 @@ export
class ControllerView extends DOMWidgetView {

_createElement(tagName: string) {
this.pWidget = new JupyterPhosphorPanelWidget({ view: this });
this.pWidget = new JupyterLuminoPanelWidget({ view: this });
return this.pWidget.node;
}

Expand Down Expand Up @@ -421,5 +421,5 @@ class ControllerView extends DOMWidgetView {
axis_box: Panel;
button_box: Panel;
model: ControllerModel;
pWidget: JupyterPhosphorPanelWidget;
pWidget: JupyterLuminoPanelWidget;
}
2 changes: 1 addition & 1 deletion packages/controls/src/widget_selection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ class DropdownModel extends SelectionModel {
}
}

// TODO: Make a phosphor dropdown control, wrapped in DropdownView. Also, fix
// TODO: Make a Lumino dropdown control, wrapped in DropdownView. Also, fix
// bugs in keyboard handling. See
// https://github.com/jupyter-widgets/ipywidgets/issues/1055 and
// https://github.com/jupyter-widgets/ipywidgets/issues/1049
Expand Down
28 changes: 14 additions & 14 deletions packages/controls/src/widget_selectioncontainer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Distributed under the terms of the Modified BSD License.

import {
DOMWidgetView, ViewList, JupyterPhosphorWidget, WidgetModel
DOMWidgetView, ViewList, JupyterLuminoWidget, WidgetModel
} from '@jupyter-widgets/base';

import {
Expand All @@ -15,11 +15,11 @@ import {

import {
TabPanel
} from './phosphor/tabpanel';
} from './lumino/tabpanel';

import {
Accordion
} from './phosphor/accordion';
} from './lumino/accordion';

import {
Widget
Expand Down Expand Up @@ -62,23 +62,23 @@ class AccordionModel extends SelectionContainerModel {
// positioning BoxLayout, but we want a more an html/css-based Panel layout.

export
class JupyterPhosphorAccordionWidget extends Accordion {
constructor(options: JupyterPhosphorWidget.IOptions & Accordion.IOptions) {
class JupyterLuminoAccordionWidget extends Accordion {
constructor(options: JupyterLuminoWidget.IOptions & Accordion.IOptions) {
let view = options.view;
delete options.view;
super(options);
this._view = view;
}

/**
* Process the phosphor message.
* Process the Lumino message.
*
* Any custom phosphor widget used inside a Jupyter widget should override
* Any custom Lumino widget used inside a Jupyter widget should override
* the processMessage function like this.
*/
processMessage(msg: Message) {
super.processMessage(msg);
this._view.processPhosphorMessage(msg);
this._view.processLuminoMessage(msg);
}

/**
Expand All @@ -105,7 +105,7 @@ export
class AccordionView extends DOMWidgetView {

_createElement(tagName: string) {
this.pWidget = new JupyterPhosphorAccordionWidget({ view: this });
this.pWidget = new JupyterLuminoAccordionWidget({ view: this });
return this.pWidget.node;
}

Expand Down Expand Up @@ -233,8 +233,8 @@ class TabModel extends SelectionContainerModel {
// positioning BoxLayout, but we want a more an html/css-based Panel layout.

export
class JupyterPhosphorTabPanelWidget extends TabPanel {
constructor(options: JupyterPhosphorWidget.IOptions & TabPanel.IOptions) {
class JupyterLuminoTabPanelWidget extends TabPanel {
constructor(options: JupyterLuminoWidget.IOptions & TabPanel.IOptions) {
let view = options.view;
delete options.view;
super(options);
Expand All @@ -245,7 +245,7 @@ class JupyterPhosphorTabPanelWidget extends TabPanel {
// There may be times when we want the view's handler to be called
// *after* the message has been processed by the widget, in which
// case we'll need to revisit using a message hook.
this._view.processPhosphorMessage(msg);
this._view.processLuminoMessage(msg);
return true;
});
}
Expand Down Expand Up @@ -276,7 +276,7 @@ export
class TabView extends DOMWidgetView {

_createElement(tagName: string) {
this.pWidget = new JupyterPhosphorTabPanelWidget({
this.pWidget = new JupyterLuminoTabPanelWidget({
view: this,
});
return this.pWidget.node;
Expand Down Expand Up @@ -426,5 +426,5 @@ class TabView extends DOMWidgetView {

updatingTabs: boolean = false;
childrenViews: ViewList<DOMWidgetView>;
pWidget: JupyterPhosphorTabPanelWidget;
pWidget: JupyterLuminoTabPanelWidget;
}
2 changes: 1 addition & 1 deletion packages/controls/test/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@

import './widget_date_test';
import './widget_string_test';
import './phosphor/currentselection_test';
import './lumino/currentselection_test';
Loading