Browse Source

Removing the grunt task generated live edit JS files since we're holding off on the inline edit feature for now

main
Connor McSheffrey 11 years ago
parent
commit
871b6c4252
  1. 32
      Gruntfile.js
  2. 19
      js/cookbook/cb-02-inline-styles tip.js
  3. 19
      js/cookbook/cb-02-inline-styles.js
  4. 16
      js/cookbook/cb-03-if-else-in-JSX tip.js
  5. 16
      js/cookbook/cb-03-if-else-in-JSX.js
  6. 14
      js/cookbook/cb-06-style-prop-value-px tip.js
  7. 14
      js/cookbook/cb-06-style-prop-value-px.js
  8. 17
      js/cookbook/cb-08-controlled-input-null-value tip.js
  9. 17
      js/cookbook/cb-08-controlled-input-null-value.js

32
Gruntfile.js

@ -33,7 +33,7 @@ module.exports = function(grunt) {
componentName,
componentNameCamelCase,
componentNameUpperCase,
liveEditJS;
liveEditJS = '';
// File has no code sample
if (matchedJS === null) {
@ -41,29 +41,31 @@ module.exports = function(grunt) {
};
// Here we should iterate over matched code samples
matchedJS = matchedJS[0];
// Remove markdown syntax
matchedJS = matchedJS.slice(5, -3);
for( var i = 0; i < matchedJS.length; i++) {
// remove file extension
componentName = filename.slice(0, -3);
// Remove markdown syntax
matchedJS = matchedJS[i].slice(5, -3);
componentNameCamelCase = componentName;
// remove file extension
componentName = filename.slice(0, -3) + i;
// Uppercase with underscores (FOO_COMPONENT)
componentNameUpperCase = componentName.toUpperCase().replace(/[\. ,:-]+/g, "_").slice(6);
componentNameUpperCase = componentName.toUpperCase().replace(/[\. ,:-]+/g, "_").slice(6);
// Camelcase (fooExample)
componentNameCamelCase = componentName.replace(/-([a-z])/g, function (g) { return g[1].toUpperCase() }).slice(5);
// Add code sample to live edit
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 );'
writeToLiveSampleJS(liveEditJS, componentName);
componentNameCamelCase = componentNameCamelCase.replace(/-([a-z])/g, function (g) { return g[1].toUpperCase() }).slice(5);
// Add code sample to live edit
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 );'
console.log(componentName);
}
writeToLiveSampleJS(liveEditJS, componentName);
// writeToHTML(markdown, componentName);
}

19
js/cookbook/cb-02-inline-styles tip.js

@ -1,19 +0,0 @@
/**
* @jsx React.DOM
*/
var INLINE_STYLES_TIP_COMPONENT = "
/** @jsx React.DOM */
var divStyle = {
color: 'white',
backgroundImage: 'url(' + imgUrl + ')',
WebkitTransition: 'all' // note the capital 'W' here
};
React.renderComponent(<div style={divStyle}>Hello World!</div>, mountNode);
";
React.renderComponent(
ReactPlayground( {codeText:INLINE_STYLES_TIP_COMPONENT} ),
document.getElementById("InlineStyles tip")
);

19
js/cookbook/cb-02-inline-styles.js

@ -1,19 +0,0 @@
/**
* @jsx React.DOM
*/
var INLINE_STYLES_COMPONENT = "
/** @jsx React.DOM */
var divStyle = {
color: 'white',
backgroundImage: 'url(' + imgUrl + ')',
WebkitTransition: 'all' // note the capital 'W' here
};
React.renderComponent(<div style={divStyle}>Hello World!</div>, mountNode);
";
React.renderComponent(
ReactPlayground( {codeText:INLINE_STYLES_COMPONENT} ),
document.getElementById("InlineStyles")
);

16
js/cookbook/cb-03-if-else-in-JSX tip.js

@ -1,16 +0,0 @@
/**
* @jsx React.DOM
*/
var IF_ELSE_IN_JSX_TIP_COMPONENT = "
/** @jsx React.DOM */
// this
React.renderComponent(<div id="msg">Hello World!</div>, mountNode);
// is the same as this
React.renderComponent(React.DOM.div({id:"msg"}, "Hello World!"), mountNode);
";
React.renderComponent(
ReactPlayground( {codeText:IF_ELSE_IN_JSX_TIP_COMPONENT} ),
document.getElementById("IfElseIn-JSX tip")
);

16
js/cookbook/cb-03-if-else-in-JSX.js

@ -1,16 +0,0 @@
/**
* @jsx React.DOM
*/
var IF_ELSE_IN_JSX_COMPONENT = "
/** @jsx React.DOM */
// this
React.renderComponent(<div id="msg">Hello World!</div>, mountNode);
// is the same as this
React.renderComponent(React.DOM.div({id:"msg"}, "Hello World!"), mountNode);
";
React.renderComponent(
ReactPlayground( {codeText:IF_ELSE_IN_JSX_COMPONENT} ),
document.getElementById("IfElseIn-JSX")
);

14
js/cookbook/cb-06-style-prop-value-px tip.js

@ -1,14 +0,0 @@
/**
* @jsx React.DOM
*/
var STYLE_PROP_VALUE_PX_TIP_COMPONENT = "
/** @jsx React.DOM */
var divStyle = {height: 10}; // rendered as "height:10px"
React.renderComponent(<div style={divStyle}>Hello World!</div>, mountNode);
";
React.renderComponent(
ReactPlayground( {codeText:STYLE_PROP_VALUE_PX_TIP_COMPONENT} ),
document.getElementById("StylePropValuePx tip")
);

14
js/cookbook/cb-06-style-prop-value-px.js

@ -1,14 +0,0 @@
/**
* @jsx React.DOM
*/
var STYLE_PROP_VALUE_PX_COMPONENT = "
/** @jsx React.DOM */
var divStyle = {height: 10}; // rendered as "height:10px"
React.renderComponent(<div style={divStyle}>Hello World!</div>, mountNode);
";
React.renderComponent(
ReactPlayground( {codeText:STYLE_PROP_VALUE_PX_COMPONENT} ),
document.getElementById("StylePropValuePx")
);

17
js/cookbook/cb-08-controlled-input-null-value tip.js

@ -1,17 +0,0 @@
/**
* @jsx React.DOM
*/
var CONTROLLED_INPUT_NULL_VALUE_TIP_COMPONENT = "
/** @jsx React.DOM */
React.renderComponent(<input value="hi" />, mountNode);
setTimeout(function() {
React.renderComponent(<input value={null} />, mountNode);
}, 2000);
";
React.renderComponent(
ReactPlayground( {codeText:CONTROLLED_INPUT_NULL_VALUE_TIP_COMPONENT} ),
document.getElementById("ControlledInputNullValue tip")
);

17
js/cookbook/cb-08-controlled-input-null-value.js

@ -1,17 +0,0 @@
/**
* @jsx React.DOM
*/
var CONTROLLED_INPUT_NULL_VALUE_COMPONENT = "
/** @jsx React.DOM */
React.renderComponent(<input value="hi" />, mountNode);
setTimeout(function() {
React.renderComponent(<input value={null} />, mountNode);
}, 2000);
";
React.renderComponent(
ReactPlayground( {codeText:CONTROLLED_INPUT_NULL_VALUE_COMPONENT} ),
document.getElementById("ControlledInputNullValue")
);
Loading…
Cancel
Save