added React.JS
we aren’t using jsx (yet, anyway) bring it into a module like anything else: define ['react'], (React) -> There’s also a helper module to make building your UI simpler at `compiled/withReactDOM`. It safely moves everything from `React.DOM` to window during a function call for convenience. Change-Id: Ibf64f0b207411c31b92f30dddc6ce188d9462e11 Reviewed-on: https://gerrit.instructure.com/37376 Reviewed-by: Ryan Shaw <ryan@instructure.com> Tested-by: Jenkins <jenkins@instructure.com> Product-Review: Ryan Florence <ryanf@instructure.com> QA-Review: Ryan Florence <ryanf@instructure.com>
This commit is contained in:
parent
574fb015e8
commit
065093e97c
|
@ -0,0 +1,34 @@
|
|||
define ['react'], (React) ->
|
||||
|
||||
# This moves everything from React.DOM to the window, making non-jsx react
|
||||
# code far more convenient, and even a bit haml-like
|
||||
#
|
||||
# ```coffee
|
||||
# define ['react', 'compiled/withReactDOM'], (React, withDOM) ->
|
||||
# React.createClass
|
||||
# render: withDOM ->
|
||||
# div {className: 'container'},
|
||||
# ul {},
|
||||
# li {className: 'foo'}, 'Foo'
|
||||
# li {className: 'bar'}, 'Bar'
|
||||
# ```
|
||||
|
||||
withReactDOM = (fn) ->
|
||||
|
||||
->
|
||||
old = {}
|
||||
|
||||
# move it all to window
|
||||
for tagName, tag of React.DOM
|
||||
old[tagName] = window[tagName]
|
||||
window[tagName] = tag
|
||||
|
||||
retVal = fn.apply(this, arguments)
|
||||
|
||||
# move it all back, on the same tick so we're guaranteed not to have
|
||||
# screwed up some potential global `i` in other code
|
||||
for tagName, tag of React.DOM
|
||||
window[tagName] = old[tagName]
|
||||
|
||||
retVal
|
||||
|
|
@ -15,6 +15,7 @@
|
|||
"ember-qunit": "~0.1.7",
|
||||
"ic-tabs": "0.1.3",
|
||||
"ic-lazy-list": "0.2.2",
|
||||
"ic-modal": "0.1.1"
|
||||
"ic-modal": "0.1.1",
|
||||
"react": "~0.10.0"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -125,6 +125,9 @@ module Canvas
|
|||
'handlebars': {
|
||||
deps: ['bower/handlebars/handlebars.runtime.amd'],
|
||||
exports: 'Handlebars'
|
||||
},
|
||||
'bower/react/react': {
|
||||
exports: 'React'
|
||||
}
|
||||
}
|
||||
JS
|
||||
|
|
|
@ -0,0 +1,16 @@
|
|||
{
|
||||
"name": "react",
|
||||
"version": "0.10.0",
|
||||
"main": "react.js",
|
||||
"homepage": "https://github.com/facebook/react-bower",
|
||||
"_release": "0.10.0",
|
||||
"_resolution": {
|
||||
"type": "version",
|
||||
"tag": "v0.10.0",
|
||||
"commit": "4862309b39ceef32a65c160cd9987eccdfb29c38"
|
||||
},
|
||||
"_source": "git://github.com/facebook/react-bower.git",
|
||||
"_target": "~0.10.0",
|
||||
"_originalSource": "react",
|
||||
"_direct": true
|
||||
}
|
File diff suppressed because one or more lines are too long
|
@ -0,0 +1,5 @@
|
|||
{
|
||||
"name": "react",
|
||||
"version": "0.10.0",
|
||||
"main": "react.js"
|
||||
}
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because one or more lines are too long
File diff suppressed because it is too large
Load Diff
File diff suppressed because one or more lines are too long
|
@ -0,0 +1,2 @@
|
|||
define(['bower/react/react'], function(React) { return React; });
|
||||
|
Loading…
Reference in New Issue