Skip to content
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

Change react to preact #145

Merged
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
11 changes: 5 additions & 6 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@ define(function (require, exports, module) {
var WorkspaceManager = brackets.getModule('view/WorkspaceManager');
var AppInit = brackets.getModule('utils/AppInit');
var ExtensionUtils = brackets.getModule('utils/ExtensionUtils');
var React = brackets.getModule('thirdparty/react');
var ReactDOM = brackets.getModule('thirdparty/react-dom');
var Preact = brackets.getModule('preact-compat');

// Extension modules.
var App = require('modules/App');
Expand Down Expand Up @@ -56,20 +55,20 @@ define(function (require, exports, module) {
function registerHandlers () {
// Subscribe to all changes to comments.
Events.subscribe('todos:updated', function () {
rootElement = React.createElement('div',
rootElement = Preact.createElement('div',
{
className: Settings.get().search.scope
},
React.createElement(ToolbarComponent, {
Preact.createElement(ToolbarComponent, {
tags: Tags.get()
}),
React.createElement(ResultsTableComponent, {
Preact.createElement(ResultsTableComponent, {
files: Files.get()
})
);

// Render content of panel.
ReactDOM.render(rootElement, document.getElementById('brackets-todo-container'));
Preact.render(rootElement, document.getElementById('brackets-todo-container'));
});
}

Expand Down
6 changes: 3 additions & 3 deletions modules/components/CloseButton.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@ define(function (require) {
'use strict';

// Get dependencies.
var React = brackets.getModule('thirdparty/react');
var Preact = brackets.getModule('preact-compat');

// Extension modules.
var App = require('modules/App');

// Return component.
return React.createClass({
return Preact.createClass({
render: function () {
return (
React.createElement('a', {
Preact.createElement('a', {
className: 'close',
onClick: function () {
App.enable(false);
Expand Down
6 changes: 3 additions & 3 deletions modules/components/CollapseIcon.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ define(function (require) {
'use strict';

// Get dependencies.
var React = brackets.getModule('thirdparty/react');
var Preact = brackets.getModule('preact-compat');

// Extension modules.
var Files = require('modules/Files');
Expand All @@ -12,10 +12,10 @@ define(function (require) {
var iconCollapse = require('text!images/folder.svg');

// Return component.
return React.createClass({
return Preact.createClass({
render: function () {
return (
React.createElement('a', {
Preact.createElement('a', {
className: 'collapse',
title: Strings.COLLAPSE_ALL,
dangerouslySetInnerHTML: {__html: iconCollapse},
Expand Down
6 changes: 3 additions & 3 deletions modules/components/ExpandIcon.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ define(function (require) {
'use strict';

// Get dependencies.
var React = brackets.getModule('thirdparty/react');
var Preact = brackets.getModule('preact-compat');

// Extension modules.
var Files = require('modules/Files');
Expand All @@ -12,10 +12,10 @@ define(function (require) {
var iconExpand = require('text!images/folder-open.svg');

// Return component.
return React.createClass({
return Preact.createClass({
render: function () {
return (
React.createElement('a', {
Preact.createElement('a', {
className: 'expand',
title: Strings.EXPAND_ALL,
dangerouslySetInnerHTML: {__html: iconExpand},
Expand Down
17 changes: 8 additions & 9 deletions modules/components/File.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@ define(function (require) {
'use strict';

// Get dependencies.
var React = brackets.getModule('thirdparty/react');
var ReactDOM = brackets.getModule('thirdparty/react-dom');
var Preact = brackets.getModule('preact-compat');

// Extension modules.
var Files = require('modules/Files');
Expand All @@ -16,10 +15,10 @@ define(function (require) {
var lastScroll;

// Return component.
return React.createClass({
return Preact.createClass({
componentDidUpdate: function () {
if (this.props.autoopened && lastScroll !== this.props.path) {
var node = ReactDOM.findDOMNode(this);
var node = Preact.findDOMNode(this);
node.scrollIntoView();

lastScroll = this.props.path;
Expand All @@ -32,20 +31,20 @@ define(function (require) {

render: function () {
return (
React.createElement('tr',
Preact.createElement('tr',
{
className: 'file ' + (Settings.get().search.scope !== 'project' || this.props.autoopened || this.props.expanded ? 'expanded' : 'collapsed')
},
React.createElement('td', null,
React.createElement('div',
Preact.createElement('td', null,
Preact.createElement('div',
{
className: 'file-name',
onClick: this.clickHandler
},
React.createElement('span', {className: 'jstree-sprite disclosure-triangle'}),
Preact.createElement('span', {className: 'jstree-sprite disclosure-triangle'}),
this.props.name
),
React.createElement(TodoList, {todos: this.props.todos})
Preact.createElement(TodoList, {todos: this.props.todos})
)
)
);
Expand Down
8 changes: 4 additions & 4 deletions modules/components/FileList.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@ define(function (require) {
'use strict';

// Get dependencies.
var React = brackets.getModule('thirdparty/react');
var Preact = brackets.getModule('preact-compat');

// Components.
var File = require('modules/components/File');

// Return component.
return React.createClass({
return Preact.createClass({
getDefaultProps: function () {
return {
files: []
Expand All @@ -17,11 +17,11 @@ define(function (require) {

render: function () {
var fileElements = function (fileItem) {
return React.createElement(File, fileItem);
return Preact.createElement(File, fileItem);
};

return (
React.createElement('tbody', null,
Preact.createElement('tbody', null,
this.props.files.map(fileElements)
)
);
Expand Down
12 changes: 6 additions & 6 deletions modules/components/Icons.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,21 @@ define(function (require) {
'use strict';

// Get dependencies.
var React = brackets.getModule('thirdparty/react');
var Preact = brackets.getModule('preact-compat');

// Components.
var CollapseIcon = require('modules/components/CollapseIcon');
var ExpandIcon = require('modules/components/ExpandIcon');
var SettingsIcon = require('modules/components/SettingsIcon');

// Return component.
return React.createClass({
return Preact.createClass({
render: function () {
return (
React.createElement('div', {className: 'icons'},
React.createElement(CollapseIcon),
React.createElement(ExpandIcon),
React.createElement(SettingsIcon)
Preact.createElement('div', {className: 'icons'},
Preact.createElement(CollapseIcon),
Preact.createElement(ExpandIcon),
Preact.createElement(SettingsIcon)
)
);
}
Expand Down
10 changes: 5 additions & 5 deletions modules/components/ResultsTable.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,18 @@ define(function (require) {
'use strict';

// Get dependencies.
var React = brackets.getModule('thirdparty/react');
var Preact = brackets.getModule('preact-compat');

// Components.
var FileList = require('modules/components/FileList');

// Return component.
return React.createClass({
return Preact.createClass({
render: function () {
return (
React.createElement('div', {className: 'table-container resizable-content'},
React.createElement('table', {className: 'table table-condensed table-striped'},
React.createElement(FileList, {files: this.props.files})
Preact.createElement('div', {className: 'table-container resizable-content'},
Preact.createElement('table', {className: 'table table-condensed table-striped'},
Preact.createElement(FileList, {files: this.props.files})
)
)
);
Expand Down
6 changes: 3 additions & 3 deletions modules/components/SettingsIcon.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ define(function (require) {
var Commands = brackets.getModule('command/Commands');
var FileSystem = brackets.getModule('filesystem/FileSystem');
var MainViewManager = brackets.getModule('view/MainViewManager');
var React = brackets.getModule('thirdparty/react');
var Preact = brackets.getModule('preact-compat');

// Extension modules.
var Paths = require('modules/Paths');
Expand All @@ -17,10 +17,10 @@ define(function (require) {
var iconCog = require('text!images/cog.svg');

// Return component.
return React.createClass({
return Preact.createClass({
render: function () {
return (
React.createElement('a', {
Preact.createElement('a', {
className: 'indicator',
title: Strings.CONFIGURE,
dangerouslySetInnerHTML: {__html: iconCog},
Expand Down
8 changes: 4 additions & 4 deletions modules/components/Tag.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,27 @@ define(function (require) {
'use strict';

// Get dependencies.
var React = brackets.getModule('thirdparty/react');
var Preact = brackets.getModule('preact-compat');

// Extension modules.
var Strings = require('modules/Strings');
var Tags = require('modules/Tags');

// Return component.
return React.createClass({
return Preact.createClass({
clickHandler: function () {
Tags.toggle(this.props.name);
},

render: function () {
return (
React.createElement('a', {
Preact.createElement('a', {
className: this.props.visible ? 'visible' : '',
title: Strings.SHOW_OR_HIDE + ' ' + this.props.name,
onClick: this.clickHandler
},
this.props.name,
React.createElement('span', {className: 'count'}, '(', this.props.count, ')')
Preact.createElement('span', {className: 'count'}, '(', this.props.count, ')')
)
);
}
Expand Down
8 changes: 4 additions & 4 deletions modules/components/TagList.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@ define(function (require) {
'use strict';

// Get dependencies.
var React = brackets.getModule('thirdparty/react');
var Preact = brackets.getModule('preact-compat');

// Components.
var Tag = require('modules/components/Tag');

// Return component.
return React.createClass({
return Preact.createClass({
getDefaultProps: function () {
return {
tags: []
Expand All @@ -17,11 +17,11 @@ define(function (require) {

render: function () {
var tagElements = function (tagItem) {
return React.createElement(Tag, tagItem);
return Preact.createElement(Tag, tagItem);
};

return (
React.createElement('div', {
Preact.createElement('div', {
className: 'tags'
},
this.props.tags.map(tagElements)
Expand Down
14 changes: 7 additions & 7 deletions modules/components/Todo.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ define(function () {
var Commands = brackets.getModule('command/Commands');
var EditorManager = brackets.getModule('editor/EditorManager');
var MainViewManager = brackets.getModule('view/MainViewManager');
var React = brackets.getModule('thirdparty/react');
var Preact = brackets.getModule('preact-compat');

// Return component.
return React.createClass({
return Preact.createClass({
clickHandler: function (e) {
var todo = this;

Expand All @@ -28,15 +28,15 @@ define(function () {

render: function () {
return (
React.createElement('tr', {
Preact.createElement('tr', {
className: 'comment ' + (this.props.done ? 'done' : ''),
onClick: this.clickHandler
},
React.createElement('td', {className: 'line'},
Preact.createElement('td', {className: 'line'},
this.props.line
),
React.createElement('td', {className: 'tag'},
React.createElement('span', {
Preact.createElement('td', {className: 'tag'},
Preact.createElement('span', {
className: this.props.tag,
style: {
backgroundColor: this.props.color
Expand All @@ -45,7 +45,7 @@ define(function () {
this.props.tag
)
),
React.createElement('td', {className: 'message'},
Preact.createElement('td', {className: 'message'},
this.props.comment
)
)
Expand Down
10 changes: 5 additions & 5 deletions modules/components/TodoList.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ define(function (require) {
'use strict';

// Get dependencies.
var React = brackets.getModule('thirdparty/react');
var Preact = brackets.getModule('preact-compat');

// Extension modules.
var Tags = require('modules/Tags');
Expand All @@ -11,7 +11,7 @@ define(function (require) {
var Todo = require('modules/components/Todo');

// Return component.
return React.createClass({
return Preact.createClass({
getDefaultProps: function () {
return {
todos: []
Expand All @@ -29,13 +29,13 @@ define(function (require) {
var todoElements = function (todoItem) {
// Only render todos with visible tags.
if (visibleTags.indexOf(todoItem.tag) > -1) {
return React.createElement(Todo, todoItem);
return Preact.createElement(Todo, todoItem);
}
};

return (
React.createElement('table', {className: 'table-striped todos'},
React.createElement('tbody', null,
Preact.createElement('table', {className: 'table-striped todos'},
Preact.createElement('tbody', null,
this.props.todos.map(todoElements)
)
)
Expand Down
Loading