Skip to content

Commit 4311e10

Browse files
authored
Merge pull request #4726 from gnestor/react
Switch from preact to react
2 parents a44a367 + c603077 commit 4311e10

File tree

5 files changed

+25
-30
lines changed

5 files changed

+25
-30
lines changed

bower.json

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
"bootstrap": "bootstrap#~3.4",
77
"bootstrap-tour": "0.9.0",
88
"codemirror": "components/codemirror#~5.37",
9+
"create-react-class": "https://cdn.jsdelivr.net/npm/create-react-class@15.6.3/create-react-class.min.js",
910
"es6-promise": "~1.0",
1011
"font-awesome": "components/font-awesome#~4.7.0",
1112
"google-caja": "5669",
@@ -16,9 +17,7 @@
1617
"marked": "~0.5",
1718
"MathJax": "^2.7.4",
1819
"moment": "~2.19.3",
19-
"preact": "https://unpkg.com/preact@~7.2.0/dist/preact.min.js",
20-
"preact-compat": "https://unpkg.com/preact-compat@~3.14.3/dist/preact-compat.min.js",
21-
"proptypes": "https://unpkg.com/proptypes@~0.14.4/index.js",
20+
"react": "~16.0.0",
2221
"requirejs": "~2.2",
2322
"requirejs-text": "~2.0.15",
2423
"requirejs-plugins": "~1.0.3",

notebook/static/notebook/js/shortcuteditor.js

Lines changed: 15 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,6 @@ define([
1212
dialog,
1313
marked
1414
) {
15-
var render = preact.render;
16-
var createClass = preactCompat.createClass;
17-
var createElement = preactCompat.createElement;
1815

1916

2017
/**
@@ -33,7 +30,7 @@ var humanize_action_id = function(str) {
3330
* Wether an action have a keybinding or not.
3431
**/
3532

36-
var KeyBinding = createClass({
33+
var KeyBinding = createReactClass({
3734
displayName: 'KeyBindings',
3835
getInitialState: function() {
3936
return {shrt:''};
@@ -53,38 +50,38 @@ var KeyBinding = createClass({
5350
event.preventDefault();
5451
return false;
5552
};
56-
return createElement('form', {className:'jupyter-keybindings',
53+
return React.createElement('form', {className:'jupyter-keybindings',
5754
onSubmit: binding_setter
5855
},
59-
createElement('i', {className: "pull-right fa fa-plus", alt: 'add-keyboard-shortcut',
56+
React.createElement('i', {className: "pull-right fa fa-plus", alt: 'add-keyboard-shortcut',
6057
onClick: binding_setter
6158
}),
62-
createElement('input', {
59+
React.createElement('input', {
6360
type:'text',
6461
placeholder:'add shortcut',
6562
className:'pull-right'+((available||empty)?'':' alert alert-danger'),
6663
value:that.state.shrt,
6764
onChange:that.handleShrtChange
6865
}),
6966
that.props.shortcuts ? that.props.shortcuts.map(function (item, index) {
70-
return createElement('span', {className: 'pull-right'},
71-
createElement('kbd', {}, [
67+
return React.createElement('span', {className: 'pull-right'},
68+
React.createElement('kbd', {}, [
7269
item.h,
73-
createElement('i', {className: "fa fa-times", alt: 'remove '+item.h,
70+
React.createElement('i', {className: "fa fa-times", alt: 'remove '+item.h,
7471
onClick:function () {
7572
that.props.unbind(item.raw);
7673
}
7774
})
7875
])
7976
);
8077
}): null,
81-
createElement('div', {title: '(' + that.props.ckey + ')' ,
78+
React.createElement('div', {title: '(' + that.props.ckey + ')' ,
8279
className:'jupyter-keybindings-text'}, that.props.display )
8380
);
8481
}
8582
});
8683

87-
var KeyBindingList = createClass({
84+
var KeyBindingList = createReactClass({
8885
displayName: 'KeyBindingList',
8986
getInitialState: function(){
9087
return {data:[]};
@@ -95,7 +92,7 @@ var KeyBindingList = createClass({
9592
render: function() {
9693
var that = this;
9794
var children = this.state.data.map(function (binding) {
98-
return createElement(KeyBinding, Object.assign({}, binding, {
95+
return React.createElement(KeyBinding, Object.assign({}, binding, {
9996
onAddBindings: function (shortcut, action) {
10097
that.props.bind(shortcut, action);
10198
that.setState({data:that.props.callback()});
@@ -107,7 +104,7 @@ var KeyBindingList = createClass({
107104
}
108105
}));
109106
});
110-
children.unshift(createElement('div', {className:'well', key:'disclamer', id:'short-key-binding-intro', dangerouslySetInnerHTML:
107+
children.unshift(React.createElement('div', {className:'well', key:'disclamer', id:'short-key-binding-intro', dangerouslySetInnerHTML:
111108
{__html:
112109
marked(
113110

@@ -116,7 +113,7 @@ var KeyBindingList = createClass({
116113
"See more [**details of defining keyboard shortcuts**](#long-key-binding-intro) below."
117114
)}
118115
}));
119-
children.push(createElement('div', {className:'well', key:'disclamer', id:'long-key-binding-intro', dangerouslySetInnerHTML:
116+
children.push(React.createElement('div', {className:'well', key:'disclamer', id:'long-key-binding-intro', dangerouslySetInnerHTML:
120117
{__html:
121118
marked(
122119

@@ -165,7 +162,7 @@ var KeyBindingList = createClass({
165162
"Changing the keybindings of edit mode is not currently available."
166163
)}
167164
}));
168-
return createElement('div',{}, children);
165+
return React.createElement('div',{}, children);
169166
}
170167
});
171168

@@ -217,8 +214,8 @@ var ShortcutEditor = function(notebook) {
217214
mod.addClass("modal_stretch");
218215

219216
mod.modal('show');
220-
render(
221-
createElement(KeyBindingList, {
217+
ReactDOM.render(
218+
React.createElement(KeyBindingList, {
222219
callback: function () { return get_shortcuts_data(notebook);},
223220
bind: function (shortcut, command) {
224221
return notebook.keyboard_manager.command_shortcuts._persist_shortcut(shortcut, command);

notebook/templates/page.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@
1616
{% endblock %}
1717
<link rel="stylesheet" href="{{ base_url }}custom/custom.css" type="text/css" />
1818
<script src="{{static_url("components/es6-promise/promise.min.js")}}" type="text/javascript" charset="utf-8"></script>
19-
<script src="{{static_url('components/preact/index.js')}}" type="text/javascript"></script>
20-
<script src="{{static_url('components/proptypes/index.js')}}" type="text/javascript"></script>
21-
<script src="{{static_url('components/preact-compat/index.js')}}" type="text/javascript"></script>
19+
<script src="{{static_url('components/react/react.production.min.js')}}" type="text/javascript"></script>
20+
<script src="{{static_url('components/react/react-dom.production.min.js')}}" type="text/javascript"></script>
21+
<script src="{{static_url('components/create-react-class/index.js')}}" type="text/javascript"></script>
2222
<script src="{{static_url('components/requirejs/require.js') }}" type="text/javascript" charset="utf-8"></script>
2323
<script>
2424
require.config({

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,10 @@
1414
"build:watch": "set -e; while true; do npm run build; sleep 3; done"
1515
},
1616
"devDependencies": {
17-
"bower": "*",
17+
"bower": "^1.8.8",
1818
"less": "~2",
19-
"requirejs": "^2.1.17",
20-
"po2json": "^0.4.5"
19+
"po2json": "^0.4.5",
20+
"requirejs": "^2.3.6"
2121
},
2222
"dependencies": {}
2323
}

setupbase.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,7 @@ def find_package_data():
136136
pjoin(components, "bootstrap", "dist", "js", "bootstrap.min.js"),
137137
pjoin(components, "bootstrap-tour", "build", "css", "bootstrap-tour.min.css"),
138138
pjoin(components, "bootstrap-tour", "build", "js", "bootstrap-tour.min.js"),
139+
pjoin(components, "create-react-class", "index.js"),
139140
pjoin(components, "font-awesome", "css", "*.css"),
140141
pjoin(components, "es6-promise", "*.js"),
141142
pjoin(components, "font-awesome", "fonts", "*.*"),
@@ -148,9 +149,7 @@ def find_package_data():
148149
pjoin(components, "jquery-ui", "themes", "smoothness", "jquery-ui.min.css"),
149150
pjoin(components, "jquery-ui", "themes", "smoothness", "images", "*"),
150151
pjoin(components, "marked", "lib", "marked.js"),
151-
pjoin(components, "preact", "index.js"),
152-
pjoin(components, "preact-compat", "index.js"),
153-
pjoin(components, "proptypes", "index.js"),
152+
pjoin(components, "react", "react.production.min.js"),
154153
pjoin(components, "requirejs", "require.js"),
155154
pjoin(components, "requirejs-plugins", "src", "json.js"),
156155
pjoin(components, "requirejs-text", "text.js"),

0 commit comments

Comments
 (0)