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

react-with-addons build #370

Merged
merged 5 commits into from
Oct 8, 2013
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ node_js:
- '0.10'
after_script:
- curl -F "react=@build/react.js" -F "react.min=@build/react.min.js" -F "transformer=@build/JSXTransformer.js"
-F "react-with-addons=@build/react-with-addons.js" -F "react-with-addons.min=@build/react-with-addons.min.js"
-F "commit=$TRAVIS_COMMIT" -F "date=`git log --format='%ct' -1`" -F "pull_request=$TRAVIS_PULL_REQUEST"
-F "token=$SECRET_TOKEN" -F "branch=$TRAVIS_BRANCH" $SERVER
env:
Expand Down
6 changes: 4 additions & 2 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,10 @@ module.exports = function(grunt) {
});

grunt.registerTask('build:basic', ['jsx:debug', 'version-check', 'browserify:basic']);
grunt.registerTask('build:addons', ['jsx:debug', 'browserify:addons']);
grunt.registerTask('build:transformer', ['jsx:debug', 'browserify:transformer']);
grunt.registerTask('build:transitions', ['jsx:debug', 'browserify:transitions']);
grunt.registerTask('build:min', ['jsx:release', 'version-check', 'browserify:min']);
grunt.registerTask('build:addons-min', ['jsx:debug', 'browserify:addonsMin']);
grunt.registerTask('build:test', [
'jsx:jasmine',
'jsx:test',
Expand All @@ -89,9 +90,10 @@ module.exports = function(grunt) {
'version-check',
'browserify:basic',
'browserify:transformer',
'browserify:transitions',
'browserify:addons',
'jsx:release',
'browserify:min',
'browserify:addonsMin',
'copy:react_docs',
'compare_size'
]);
Expand Down
91 changes: 91 additions & 0 deletions examples/transitions/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
<!DOCTYPE html>
<html>
<head>
<meta http-equiv='Content-type' content='text/html; charset=utf-8'>
<title>Basic Example with JSX</title>
<link rel="stylesheet" href="../shared/css/base.css" />
<link rel="stylesheet" href="transition.css" />
</head>
<body>
<h1>Example with Transitions</h1>
<div id="container">
<p>
To install React, follow the instructions on
<a href="http://www.github.com/facebook/react/">GitHub</a>.
</p>
<p>
If you can see this, React is not working right.
If you checked out the source from GitHub make sure to run <code>grunt</code>.
</p>
</div>
<h4>Example Details</h4>
<ul>
<li>
This is built with
<a href="https://github.com/substack/node-browserify">browserify</a>.
</li>
<li>
This is written with JSX and transformed in the browser.
</li>
</ul>
<p>
</p>
<p>
Learn more at
<a href="http://facebook.github.io/react" target="_blank">facebook.github.io/react</a>.
</p>
<script src="../../build/react-with-addons.js"></script>
<script src="../../build/JSXTransformer.js"></script>
<script type="text/jsx">
/**
* @jsx React.DOM
*/
var TransitionGroup = React.addons.TransitionGroup;
var INTERVAL = 2000;

var AnimateDemo = React.createClass({
getInitialState: function() {
return {start: 0};
},

componentDidMount: function() {
this.interval = setInterval(this.tick, INTERVAL);
},

componentWillUnmount: function() {
clearInterval(this.interval);
},

tick: function() {
this.setState({start: this.state.start + 1});
},

render: function() {
var children = [];
var pos = 0;
var colors = ['red', 'gray', 'blue'];
for (var i = this.state.start; i < this.state.start + 3; i++) {
var style = {
left: pos * 128,
background: colors[i % 3]
};
pos++;
children.push(<div key={i} className="animateItem" style={style}>{i}</div>);
}
return (
<TransitionGroup
className="animateExample"
transitionName="example">
{children}
</TransitionGroup>
);
}
});

React.renderComponent(
<AnimateDemo />,
document.getElementById('container')
);
</script>
</body>
</html>
44 changes: 44 additions & 0 deletions examples/transitions/transition.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
.example-enter,
.example-leave {
-webkit-transition: all .25s;
transition: all .25s;
}

.example-enter,
.example-leave.example-leave-active {
opacity: 0.01;
}

.example-leave.example-leave-active {
margin-left: -128px;
}

.example-enter {
margin-left: 128px;
}

.example-enter.example-enter-active,
.example-leave {
margin-left: 0;
opacity: 0.99;
}

.animateExample {
display: block;
height: 128px;
position: relative;
width: 384px;
}

.animateItem {
color: white;
font-size: 36px;
font-weight: bold;
height: 128px;
line-height: 128px;
position: absolute;
text-align: center;
-webkit-transition: all .25s; /* TODO: make this a move animation */
transition: all .25s; /* TODO: make this a move animation */
width: 128px;
}
24 changes: 17 additions & 7 deletions grunt/config/browserify.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,16 @@ function minify(src) {
// TODO: move this out to another build step maybe.
function bannerify(src) {
var version = grunt.config.data.pkg.version;
return LICENSE_TEMPLATE.replace('@PACKAGE@', this.data.standalone)
var packageName = this.data.packageName || this.data.standalone;
return LICENSE_TEMPLATE.replace('@PACKAGE@', packageName)
.replace('@VERSION@', version) +
'\n' + src;
}

function simpleBannerify(src) {
var version = grunt.config.data.pkg.version;
return SIMPLE_TEMPLATE.replace('@PACKAGE@', this.data.standalone)
var packageName = this.data.packageName || this.data.standalone;
return SIMPLE_TEMPLATE.replace('@PACKAGE@', packageName)
.replace('@VERSION@', version) +
'\n' + src;
}
Expand Down Expand Up @@ -76,19 +78,27 @@ var transformer = {
after: [simpleBannerify]
};

var transitions = {
var addons = {
entries: [
'./build/modules/ReactTransitionGroup.js'
'./build/modules/ReactWithAddons.js'
],
outfile: './build/react-transitiongroup.js',
outfile: './build/react-with-addons.js',
debug: false,
standalone: 'ReactTransitionGroup',
standalone: 'React',
packageName: 'React (with addons)',
after: [simpleBannerify]
};

var addonsMin = grunt.util._.merge({}, addons, {
outfile: './build/react-with-addons.min.js',
debug: false,
after: [minify, bannerify]
});

module.exports = {
basic: basic,
min: min,
transformer: transformer,
transitions: transitions
addons: addons,
addonsMin: addonsMin
};
2 changes: 1 addition & 1 deletion grunt/config/jsx/jsx.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ var grunt = require('grunt');

var rootIDs = [
"React",
"ReactTransitionGroup"
"ReactWithAddons"
];

var getDebugConfig = function() {
Expand Down
5 changes: 4 additions & 1 deletion grunt/tasks/release.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@ var grunt = require('grunt');

var BOWER_PATH = '../react-bower/';
var BOWER_GLOB = [BOWER_PATH + '*'];
var BOWER_FILES = ['react.js', 'react.min.js', 'JSXTransformer.js'];
var BOWER_FILES = [
'react.js', 'react.min.js', 'JSXTransformer.js',
'react-with-addons.js', 'react-with-addons.min.js'
];
var GH_PAGES_PATH = '../react-gh-pages/';
var GH_PAGES_GLOB = [GH_PAGES_PATH + '*'];

Expand Down
2 changes: 2 additions & 0 deletions react-source.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ gemspec = Gem::Specification.new do |s|
s.files = Dir[
'build/react.js',
'build/react.min.js',
'build/react-with-addons.js',
'build/react-with-addons.min.js',
'build/JSXTransformer.js',
'lib/react/source.rb'
]
Expand Down
41 changes: 41 additions & 0 deletions src/ReactWithAddons.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/**
* Copyright 2013 Facebook, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* @providesModule ReactWithAddons
*/

/**
* This module exists purely in the open source project, and is meant as a way
* to create a separate standalone build of React. This build has "addons", or
* functionality we've built and think might be useful but doesn't have a good
* place to live inside React core.
*/

"use strict";

var LinkedStateMixin = require('LinkedStateMixin');
var React = require('React');
var ReactTransitionGroup = require('ReactTransitionGroup');

var cx = require('cx');

React.addons = {
classSet: cx,
LinkedStateMixin: LinkedStateMixin,
TransitionGroup: ReactTransitionGroup
};

module.exports = React;