├── LICENSE
├── README.md
├── components
├── index.js
└── message.js
├── index.html
├── package.json
└── react
├── react-dom.js
└── react.js
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2016 Matthew Roach
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # react-placeholder
2 |
3 | For more details read my blog post about this: [React Placeholder loading state](http://matthewroach.me/react-placeholder-loading-state/)
4 |
--------------------------------------------------------------------------------
/components/index.js:
--------------------------------------------------------------------------------
1 |
2 | var Message = React.createClass({
3 | render: function() {
4 | return (
5 |
6 |
{this.props.title}
7 |
{this.props.created}
8 |
9 | )
10 | }
11 | });
12 |
13 | var Messages = React.createClass({
14 | getInitialState: function() {
15 | return {
16 | loading: true,
17 | data: [
18 | {
19 | title: '',
20 | created: '',
21 | },
22 | {
23 | title: '',
24 | created: '',
25 | }
26 | ]
27 | };
28 | },
29 |
30 | renderMessages() {
31 | return this.state.data.map( (message, index) => {
32 | return (
33 |
34 | );
35 | });
36 | },
37 |
38 | loading() {
39 | return this.state.loading ? 'placeholder' : '';
40 | },
41 |
42 | componentDidMount() {
43 | var self = this;
44 | setTimeout(function() {
45 | self.setState({
46 | loading: false,
47 | data: [
48 | {
49 | title: 'System maintenance between 8am and 9am on Monday 4 October',
50 | created: '9/25/2016',
51 | },
52 | {
53 | title: 'September expenses are now due!',
54 | created: '9/24/2016',
55 | }
56 | ]
57 | })
58 | }, 4000);
59 | },
60 |
61 | render: function() {
62 | return (
63 |
64 |
Messages
65 | {this.renderMessages()}
66 |
67 | );
68 | }
69 | });
70 |
71 | ReactDOM.render(
72 |
73 |
74 |
,
75 | document.getElementById('root')
76 | );
77 |
--------------------------------------------------------------------------------
/components/message.js:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/matthewroach/react-placeholder/92eac944f36e6b6f2534de65c272f4ca808e92ef/components/message.js
--------------------------------------------------------------------------------
/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | React Placeholder
6 |
7 |
8 |
9 |
10 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "react-placeholder",
3 | "version": "0.1.0",
4 | "description": "A demo of a react placeholder content animation",
5 | "main": "index.js",
6 | "scripts": {
7 | "test": "echo \"Error: no test specified\" && exit 1"
8 | },
9 | "repository": {
10 | "type": "git",
11 | "url": "git+https://github.com/matthewroach/react-placeholder.git"
12 | },
13 | "author": "Matthew Roach",
14 | "license": "MIT",
15 | "bugs": {
16 | "url": "https://github.com/matthewroach/react-placeholder/issues"
17 | },
18 | "homepage": "https://github.com/matthewroach/react-placeholder#readme"
19 | }
20 |
--------------------------------------------------------------------------------
/react/react-dom.js:
--------------------------------------------------------------------------------
1 | /**
2 | * ReactDOM v15.3.2
3 | *
4 | * Copyright 2013-present, Facebook, Inc.
5 | * All rights reserved.
6 | *
7 | * This source code is licensed under the BSD-style license found in the
8 | * LICENSE file in the root directory of this source tree. An additional grant
9 | * of patent rights can be found in the PATENTS file in the same directory.
10 | *
11 | */
12 | // Based off https://github.com/ForbesLindesay/umd/blob/master/template.js
13 | ;(function(f) {
14 | // CommonJS
15 | if (typeof exports === "object" && typeof module !== "undefined") {
16 | module.exports = f(require('react'));
17 |
18 | // RequireJS
19 | } else if (typeof define === "function" && define.amd) {
20 | define(['react'], f);
21 |
22 | //