Skip to content

Commit b5af774

Browse files
committed
Sync changes to upstream
1 parent a5f3b15 commit b5af774

File tree

476 files changed

+2137
-14742
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

476 files changed

+2137
-14742
lines changed

examples/flux-chat/README.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
## Flux Chat Example
2+
3+
This is an example application we've created to show an example of how a Flux
4+
app is structured, and how you might use waitFor to make sure the Stores'
5+
registered callbacks are called in the correct order.
6+
7+
## Running
8+
9+
You must have [npm](https://www.npmjs.org/) installed on your computer.
10+
From the root project directory run these commands from the command line:
11+
12+
`npm install`
13+
14+
This will install all dependencies.
15+
16+
To build the project, first run this command:
17+
18+
`npm start`
19+
20+
This will perform an initial build and start a watcher process that will
21+
update build.js with any changes you wish to make. This watcher is
22+
based on [Browserify](http://browserify.org/) and
23+
[Watchify](https://github.com/substack/watchify), and it transforms
24+
React's JSX syntax into standard JavaScript with
25+
[Reactify](https://github.com/andreypopp/reactify).
26+
27+
After starting the watcher, you can open `index.html` in your browser to
28+
open the app.
29+

examples/flux-chat/css/chatapp.css

Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
/**
2+
* This file is provided by Facebook for testing and evaluation purposes
3+
* only. Facebook reserves all rights not expressly granted.
4+
*
5+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
6+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
7+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
8+
* FACEBOOK BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
9+
* AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
10+
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
11+
*/
12+
13+
.chatapp {
14+
font-family: 'Muli', 'Helvetica Neue', helvetica, arial;
15+
max-width: 760px;
16+
margin: 20px auto;
17+
overflow: hidden;
18+
}
19+
20+
.message-list, .thread-list {
21+
border: 1px solid #ccf;
22+
font-size: 16px;
23+
height: 400px;
24+
margin: 0;
25+
overflow-y: auto;
26+
padding: 0;
27+
}
28+
29+
.message-section {
30+
float: right;
31+
width: 65%;
32+
}
33+
34+
.thread-section {
35+
float: left;
36+
width: 32.5%;
37+
}
38+
39+
.message-thread-heading,
40+
.thread-count {
41+
height: 40px;
42+
margin: 0;
43+
}
44+
45+
.message-list-item, .thread-list-item {
46+
list-style: none;
47+
padding: 12px 14px 14px;
48+
}
49+
50+
.thread-list-item {
51+
border-bottom: 1px solid #ccc;
52+
cursor: pointer;
53+
}
54+
55+
.thread-list:hover .thread-list-item:hover {
56+
background-color: #f8f8ff;
57+
}
58+
59+
.thread-list:hover .thread-list-item {
60+
background-color: #fff;
61+
}
62+
63+
.thread-list-item.active,
64+
.thread-list:hover .thread-list-item.active,
65+
.thread-list:hover .thread-list-item.active:hover {
66+
background-color: #efefff;
67+
cursor: default;
68+
}
69+
70+
.message-author-name,
71+
.thread-name {
72+
color: #66c;
73+
float: left;
74+
font-size: 13px;
75+
margin: 0;
76+
}
77+
78+
.message-time, .thread-time {
79+
color: #aad;
80+
float: right;
81+
font-size: 12px;
82+
}
83+
84+
.message-text, .thread-last-message {
85+
clear: both;
86+
font-size: 14px;
87+
padding-top: 10px;
88+
}
89+
90+
.message-composer {
91+
box-sizing: border-box;
92+
font-family: inherit;
93+
font-size: 14px;
94+
height: 5em;
95+
width: 100%;
96+
margin: 20px 0 0;
97+
padding: 10px;
98+
}

examples/flux-chat/index.html

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<!doctype html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="utf-8">
5+
<title>Flux • Chat</title>
6+
<link href='http://fonts.googleapis.com/css?family=Muli' rel='stylesheet' type='text/css'>
7+
<link rel="stylesheet" href="css/chatapp.css">
8+
</head>
9+
<body>
10+
<section id="react"></section>
11+
<script src="js/bundle.js"></script>
12+
</body>
13+
</html>
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
/**
2+
* This file is provided by Facebook for testing and evaluation purposes
3+
* only. Facebook reserves all rights not expressly granted.
4+
*
5+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
6+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
7+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
8+
* FACEBOOK BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
9+
* AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
10+
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
11+
*
12+
* @flow
13+
*/
14+
15+
module.exports = {
16+
17+
init: function() {
18+
localStorage.clear();
19+
localStorage.setItem('messages', JSON.stringify([
20+
{
21+
id: 'm_1',
22+
threadID: 't_1',
23+
threadName: 'Jing and Bill',
24+
authorName: 'Bill',
25+
text: 'Hey Jing, want to give a Flux talk at ForwardJS?',
26+
timestamp: Date.now() - 99999
27+
},
28+
{
29+
id: 'm_2',
30+
threadID: 't_1',
31+
threadName: 'Jing and Bill',
32+
authorName: 'Bill',
33+
text: 'Seems like a pretty cool conference.',
34+
timestamp: Date.now() - 89999
35+
},
36+
{
37+
id: 'm_3',
38+
threadID: 't_1',
39+
threadName: 'Jing and Bill',
40+
authorName: 'Jing',
41+
text: 'Sounds good. Will they be serving dessert?',
42+
timestamp: Date.now() - 79999
43+
},
44+
{
45+
id: 'm_4',
46+
threadID: 't_2',
47+
threadName: 'Dave and Bill',
48+
authorName: 'Bill',
49+
text: 'Hey Dave, want to get a beer after the conference?',
50+
timestamp: Date.now() - 69999
51+
},
52+
{
53+
id: 'm_5',
54+
threadID: 't_2',
55+
threadName: 'Dave and Bill',
56+
authorName: 'Dave',
57+
text: 'Totally! Meet you at the hotel bar.',
58+
timestamp: Date.now() - 59999
59+
},
60+
{
61+
id: 'm_6',
62+
threadID: 't_3',
63+
threadName: 'Functional Heads',
64+
authorName: 'Bill',
65+
text: 'Hey Brian, are you going to be talking about functional stuff?',
66+
timestamp: Date.now() - 49999
67+
},
68+
{
69+
id: 'm_7',
70+
threadID: 't_3',
71+
threadName: 'Bill and Brian',
72+
authorName: 'Brian',
73+
text: 'At ForwardJS? Yeah, of course. See you there!',
74+
timestamp: Date.now() - 39999
75+
}
76+
]));
77+
}
78+
79+
};
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
/**
2+
* This file is provided by Facebook for testing and evaluation purposes
3+
* only. Facebook reserves all rights not expressly granted.
4+
*
5+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
6+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
7+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
8+
* FACEBOOK BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
9+
* AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
10+
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
11+
*
12+
* @flow
13+
*/
14+
15+
var ChatAppDispatcher = require('../dispatcher/ChatAppDispatcher');
16+
var ChatConstants = require('../constants/ChatConstants');
17+
var ChatWebAPIUtils = require('../utils/ChatWebAPIUtils');
18+
var MessageStore = require('../stores/MessageStore');
19+
20+
var ActionTypes = ChatConstants.ActionTypes;
21+
22+
module.exports = {
23+
24+
createMessage: function(text: string) {
25+
ChatAppDispatcher.handleViewAction({
26+
type: ActionTypes.CREATE_MESSAGE,
27+
text: text
28+
});
29+
var message = MessageStore.getCreatedMessageData(text);
30+
ChatWebAPIUtils.createMessage(message);
31+
}
32+
33+
};
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
/**
2+
* This file is provided by Facebook for testing and evaluation purposes
3+
* only. Facebook reserves all rights not expressly granted.
4+
*
5+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
6+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
7+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
8+
* FACEBOOK BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
9+
* AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
10+
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
11+
*
12+
* @flow
13+
*/
14+
15+
var ChatAppDispatcher = require('../dispatcher/ChatAppDispatcher');
16+
var ChatConstants = require('../constants/ChatConstants');
17+
18+
var ActionTypes = ChatConstants.ActionTypes;
19+
20+
type RawMessage = {
21+
id: string;
22+
threadID: string;
23+
authorName: string;
24+
timestamp: number;
25+
text: string;
26+
};
27+
28+
module.exports = {
29+
30+
receiveAll: function(rawMessages: Array<RawMessage>) {
31+
ChatAppDispatcher.handleServerAction({
32+
type: ActionTypes.RECEIVE_RAW_MESSAGES,
33+
rawMessages: rawMessages
34+
});
35+
},
36+
37+
receiveCreatedMessage: function(createdMessage: RawMessage) {
38+
ChatAppDispatcher.handleServerAction({
39+
type: ActionTypes.RECEIVE_RAW_CREATED_MESSAGE,
40+
rawMessage: createdMessage
41+
});
42+
}
43+
44+
};
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
/**
2+
* This file is provided by Facebook for testing and evaluation purposes
3+
* only. Facebook reserves all rights not expressly granted.
4+
*
5+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
6+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
7+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
8+
* FACEBOOK BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
9+
* AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
10+
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
11+
*
12+
* @flow
13+
*/
14+
15+
var ChatAppDispatcher = require('../dispatcher/ChatAppDispatcher');
16+
var ChatConstants = require('../constants/ChatConstants');
17+
18+
var ActionTypes = ChatConstants.ActionTypes;
19+
20+
module.exports = {
21+
22+
clickThread: function(threadID: string) {
23+
ChatAppDispatcher.handleViewAction({
24+
type: ActionTypes.CLICK_THREAD,
25+
threadID: threadID
26+
});
27+
}
28+
29+
};

examples/flux-chat/js/app.js

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
/**
2+
* This file is provided by Facebook for testing and evaluation purposes
3+
* only. Facebook reserves all rights not expressly granted.
4+
*
5+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
6+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
7+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
8+
* FACEBOOK BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
9+
* AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
10+
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
11+
*
12+
* @flow
13+
*/
14+
15+
// This file bootstraps the entire application.
16+
17+
var ChatApp = require('./components/ChatApp.react');
18+
var ChatExampleData = require('./ChatExampleData');
19+
var ChatWebAPIUtils = require('./utils/ChatWebAPIUtils');
20+
var React = require('react');
21+
window.React = React; // export for http://fb.me/react-devtools
22+
23+
ChatExampleData.init(); // load example data into localstorage
24+
25+
ChatWebAPIUtils.getAllMessages();
26+
27+
React.render(
28+
<ChatApp />,
29+
document.getElementById('react')
30+
);
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
/**
2+
* This file is provided by Facebook for testing and evaluation purposes
3+
* only. Facebook reserves all rights not expressly granted.
4+
*
5+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
6+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
7+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
8+
* FACEBOOK BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
9+
* AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
10+
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
11+
*
12+
* @flow
13+
*/
14+
15+
var MessageSection = require('./MessageSection.react');
16+
var React = require('react');
17+
var ThreadSection = require('./ThreadSection.react');
18+
19+
var ChatApp = React.createClass({
20+
21+
render: function(): any {
22+
return (
23+
<div className="chatapp">
24+
<ThreadSection />
25+
<MessageSection />
26+
</div>
27+
);
28+
}
29+
30+
});
31+
32+
module.exports = ChatApp;

0 commit comments

Comments
 (0)