Skip to content

Commit

Permalink
Refactoring to use React
Browse files Browse the repository at this point in the history
Summary:
React (http://facebook.github.io/react/) is a new library that Facebook
released last week and it seems awesome. It's designed for defining
components declaratively and helps out with a lot of the stuff that we
were doing by hand before, like only updating the DOM when necessary.

I converted everything except interactive-graph (which I just haven't
gotten to yet).

This is 350 lines shorter (not counting React itself) and much much more
responsive (on my computer, rerendering when editing a hint takes around 2ms
per keypress instead of 60ms previously (!) because lots of DOM manipulation
and other recalculation is avoided).

Test Plan:
Used test.html. Added hints. Removed hints. Added widgets to the
question.  Modified widget properties (e.g., input-number width) and saw
the preview update. Added radio choices.

Used testrender.html. Called zk.scoreInput() in the JS console and got
results appropriate for the radio choices I selected. Called
zk.showHint() and hints appeared.

Reviewers: eater, alex

Reviewed By: alex

CC: joel, jakesandlund

Differential Revision: http://phabricator.khanacademy.org/D2510
  • Loading branch information
sophiebits committed Jun 5, 2013
1 parent 9db4737 commit 8aafc8a
Show file tree
Hide file tree
Showing 18 changed files with 19,817 additions and 1,562 deletions.
34 changes: 20 additions & 14 deletions Gruntfile.js
Original file line number Diff line number Diff line change
@@ -1,23 +1,28 @@
module.exports = function(grunt) {

var srcFiles = [
"src/core.js",
"src/util.js",
"src/expressiontools/parser.js",
"src/expressiontools/nodes.js",
"src/expressiontools/compare.js",
"src/widgets.js",
"src/widgets/input-number.js",
"src/widgets/interactive-graph.js",
"src/widgets/radio.js",
"src/widgets/expression.js",
"src/renderer.js",
"src/editor.js",
"src/item-renderer.js"
"build/src/core.js",
"build/src/util.js",
"build/src/expressiontools/parser.js",
"build/src/expressiontools/nodes.js",
"build/src/expressiontools/compare.js",
"build/src/widgets.js",
"build/src/widgets/input-number.js",
"build/src/widgets/interactive-graph.js",
"build/src/widgets/radio.js",
"build/src/widgets/expression.js",
"build/src/renderer.js",
"build/src/editor.js",
"build/src/item-renderer.js"
];

grunt.initConfig({
pkg: grunt.file.readJSON("package.json"),
shell: {
jsx: {
command: "jsx src/ build/src/"
}
},
concat: {
options: {
banner: "/*! Perseus | http://github.com/Khan/perseus */\n",
Expand All @@ -41,7 +46,8 @@ grunt.initConfig({

grunt.loadNpmTasks("grunt-contrib-concat");
grunt.loadNpmTasks("grunt-contrib-uglify");
grunt.loadNpmTasks("grunt-shell");

grunt.registerTask("default", ["concat", "uglify"]);
grunt.registerTask("default", ["shell:jsx", "concat", "uglify"]);

};
Loading

0 comments on commit 8aafc8a

Please sign in to comment.