The library for web and native user interfaces.
Removing the grunt task generated live edit JS files since we're holding off on the inline edit feature for now
Connor McSheffrey committed
Oct 29, 2013 at 10:02 UTC
33effd31d5e6292540df34528686856850c83b57
9 files changed
+17
-147
docs/Gruntfile.js
+17
-15
@@ -33,7 +33,7 @@ module.exports = function(grunt) {
33
componentName,
34
componentNameCamelCase,
35
componentNameUpperCase,
36
- liveEditJS;
36
+ liveEditJS = '';
37
38
// File has no code sample
39
if (matchedJS === null) {
@@ -41,29 +41,31 @@ module.exports = function(grunt) {
41
};
42
43
// Here we should iterate over matched code samples
44
- matchedJS = matchedJS[0];
44
46
- // Remove markdown syntax
47
- matchedJS = matchedJS.slice(5, -3);
45
+ for( var i = 0; i < matchedJS.length; i++) {
46
49
- // remove file extension
50
- componentName = filename.slice(0, -3);
47
48
+ // Remove markdown syntax
49
+ matchedJS = matchedJS[i].slice(5, -3);
50
53
- componentNameCamelCase = componentName;
51
+ // remove file extension
52
+ componentName = filename.slice(0, -3) + i;
53
+
54
+ // Uppercase with underscores (FOO_COMPONENT)
55
+ componentNameUpperCase = componentName.toUpperCase().replace(/[\. ,:-]+/g, "_").slice(6);
56
55
- componentNameUpperCase = componentName.toUpperCase().replace(/[\. ,:-]+/g, "_").slice(6);
57
+ // Camelcase (fooExample)
58
+ componentNameCamelCase = componentName.replace(/-([a-z])/g, function (g) { return g[1].toUpperCase() }).slice(5);
59
60
+ // Add code sample to live edit
61
+ liveEditJS += '/**\n * @jsx React.DOM\n */\n\n var ' + componentNameUpperCase + '_COMPONENT = "' + matchedJS + '";\n React.renderComponent(\n ReactPlayground( {codeText:' + componentNameUpperCase + '_COMPONENT} ),\n document.getElementById("' + componentNameCamelCase + '")\n );'
62
+
63
+ writeToLiveSampleJS(liveEditJS, componentName);
64
58
-
59
- componentNameCamelCase = componentNameCamelCase.replace(/-([a-z])/g, function (g) { return g[1].toUpperCase() }).slice(5);
60
-
61
- // Add code sample to live edit
62
- liveEditJS = '/**\n * @jsx React.DOM\n */\n\n var ' + componentNameUpperCase + '_COMPONENT = "' + matchedJS + '";\n React.renderComponent(\n ReactPlayground( {codeText:' + componentNameUpperCase + '_COMPONENT} ),\n document.getElementById("' + componentNameCamelCase + '")\n );'
63
- console.log(componentName);
65
+ }
66
65
- writeToLiveSampleJS(liveEditJS, componentName);
67
68
+
69
// writeToHTML(markdown, componentName);
70
}
71
docs/js/cookbook/cb-02-inline-styles tip.js
deleted
-19
@@ -1,19 +0,0 @@
1
-/**
2
- * @jsx React.DOM
3
- */
4
-
5
- var INLINE_STYLES_TIP_COMPONENT = "
6
-/** @jsx React.DOM */
7
-
8
-var divStyle = {
9
- color: 'white',
10
- backgroundImage: 'url(' + imgUrl + ')',
11
- WebkitTransition: 'all' // note the capital 'W' here
12
-};
13
-
14
-React.renderComponent(<div style={divStyle}>Hello World!</div>, mountNode);
15
-";
16
- React.renderComponent(
17
- ReactPlayground( {codeText:INLINE_STYLES_TIP_COMPONENT} ),
18
- document.getElementById("InlineStyles tip")
19
- );
\ No newline at end of file
docs/js/cookbook/cb-02-inline-styles.js
deleted
-19
@@ -1,19 +0,0 @@
1
-/**
2
- * @jsx React.DOM
3
- */
4
-
5
- var INLINE_STYLES_COMPONENT = "
6
-/** @jsx React.DOM */
7
-
8
-var divStyle = {
9
- color: 'white',
10
- backgroundImage: 'url(' + imgUrl + ')',
11
- WebkitTransition: 'all' // note the capital 'W' here
12
-};
13
-
14
-React.renderComponent(<div style={divStyle}>Hello World!</div>, mountNode);
15
-";
16
- React.renderComponent(
17
- ReactPlayground( {codeText:INLINE_STYLES_COMPONENT} ),
18
- document.getElementById("InlineStyles")
19
- );
\ No newline at end of file
docs/js/cookbook/cb-03-if-else-in-JSX tip.js
deleted
-16
@@ -1,16 +0,0 @@
1
-/**
2
- * @jsx React.DOM
3
- */
4
-
5
- var IF_ELSE_IN_JSX_TIP_COMPONENT = "
6
-/** @jsx React.DOM */
7
-
8
-// this
9
-React.renderComponent(<div id="msg">Hello World!</div>, mountNode);
10
-// is the same as this
11
-React.renderComponent(React.DOM.div({id:"msg"}, "Hello World!"), mountNode);
12
-";
13
- React.renderComponent(
14
- ReactPlayground( {codeText:IF_ELSE_IN_JSX_TIP_COMPONENT} ),
15
- document.getElementById("IfElseIn-JSX tip")
16
- );
\ No newline at end of file
docs/js/cookbook/cb-03-if-else-in-JSX.js
deleted
-16
@@ -1,16 +0,0 @@
1
-/**
2
- * @jsx React.DOM
3
- */
4
-
5
- var IF_ELSE_IN_JSX_COMPONENT = "
6
-/** @jsx React.DOM */
7
-
8
-// this
9
-React.renderComponent(<div id="msg">Hello World!</div>, mountNode);
10
-// is the same as this
11
-React.renderComponent(React.DOM.div({id:"msg"}, "Hello World!"), mountNode);
12
-";
13
- React.renderComponent(
14
- ReactPlayground( {codeText:IF_ELSE_IN_JSX_COMPONENT} ),
15
- document.getElementById("IfElseIn-JSX")
16
- );
\ No newline at end of file
docs/js/cookbook/cb-06-style-prop-value-px tip.js
deleted
-14
@@ -1,14 +0,0 @@
1
-/**
2
- * @jsx React.DOM
3
- */
4
-
5
- var STYLE_PROP_VALUE_PX_TIP_COMPONENT = "
6
-/** @jsx React.DOM */
7
-
8
-var divStyle = {height: 10}; // rendered as "height:10px"
9
-React.renderComponent(<div style={divStyle}>Hello World!</div>, mountNode);
10
-";
11
- React.renderComponent(
12
- ReactPlayground( {codeText:STYLE_PROP_VALUE_PX_TIP_COMPONENT} ),
13
- document.getElementById("StylePropValuePx tip")
14
- );
\ No newline at end of file
docs/js/cookbook/cb-06-style-prop-value-px.js
deleted
-14
@@ -1,14 +0,0 @@
1
-/**
2
- * @jsx React.DOM
3
- */
4
-
5
- var STYLE_PROP_VALUE_PX_COMPONENT = "
6
-/** @jsx React.DOM */
7
-
8
-var divStyle = {height: 10}; // rendered as "height:10px"
9
-React.renderComponent(<div style={divStyle}>Hello World!</div>, mountNode);
10
-";
11
- React.renderComponent(
12
- ReactPlayground( {codeText:STYLE_PROP_VALUE_PX_COMPONENT} ),
13
- document.getElementById("StylePropValuePx")
14
- );
\ No newline at end of file
docs/js/cookbook/cb-08-controlled-input-null-value tip.js
deleted
-17
@@ -1,17 +0,0 @@
1
-/**
2
- * @jsx React.DOM
3
- */
4
-
5
- var CONTROLLED_INPUT_NULL_VALUE_TIP_COMPONENT = "
6
-/** @jsx React.DOM */
7
-
8
-React.renderComponent(<input value="hi" />, mountNode);
9
-
10
-setTimeout(function() {
11
- React.renderComponent(<input value={null} />, mountNode);
12
-}, 2000);
13
-";
14
- React.renderComponent(
15
- ReactPlayground( {codeText:CONTROLLED_INPUT_NULL_VALUE_TIP_COMPONENT} ),
16
- document.getElementById("ControlledInputNullValue tip")
17
- );
\ No newline at end of file
docs/js/cookbook/cb-08-controlled-input-null-value.js
deleted
-17
@@ -1,17 +0,0 @@
1
-/**
2
- * @jsx React.DOM
3
- */
4
-
5
- var CONTROLLED_INPUT_NULL_VALUE_COMPONENT = "
6
-/** @jsx React.DOM */
7
-
8
-React.renderComponent(<input value="hi" />, mountNode);
9
-
10
-setTimeout(function() {
11
- React.renderComponent(<input value={null} />, mountNode);
12
-}, 2000);
13
-";
14
- React.renderComponent(
15
- ReactPlayground( {codeText:CONTROLLED_INPUT_NULL_VALUE_COMPONENT} ),
16
- document.getElementById("ControlledInputNullValue")
17
- );
\ No newline at end of file