Skip to content

Commit 84e21e2

Browse files
committed
init
0 parents  commit 84e21e2

21 files changed

+8002
-0
lines changed

.babelrc

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"presets": [
3+
"react",
4+
"flow",
5+
"stage-0"
6+
]
7+
}

.editorconfig

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
2+
# EditorConfig is awesome: http://EditorConfig.org
3+
4+
# top-most EditorConfig file
5+
root = true
6+
7+
# Unix-style newlines with a newline ending every file
8+
[*]
9+
end_of_line = lf
10+
insert_final_newline = true
11+
12+
# Matches multiple files with brace expansion notation
13+
# Set default charset
14+
[*.{js}]
15+
charset = utf-8
16+
indent_style = space
17+
indent_size = 2

.eslintignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
docs/static

.eslintrc.js

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
module.exports = {
2+
extends: [
3+
"eslint:recommended",
4+
"plugin:react/recommended",
5+
"plugin:flowtype/recommended"
6+
],
7+
parser: "babel-eslint",
8+
env: {
9+
browser: true,
10+
node: true
11+
},
12+
plugins: [
13+
"react",
14+
"flowtype"
15+
],
16+
rules: {
17+
"react/prop-types": 0,
18+
"no-implicit-coercion": 0,
19+
"max-len": 0
20+
}
21+
};

.flowconfig

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
2+
[ignore]
3+
4+
[include]
5+
6+
[libs]
7+
8+
[lints]
9+
10+
[options]
11+
12+
[strict]

.gitattributes

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
* text=auto

.gitignore

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
node_modules
2+
coverage
3+
npm-debug.log
4+
lib
5+
.DS_Store
6+
_gh-pages
7+
yarn-error.log

.vscode/settings.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"eslint.enable": true,
3+
"flow.useNPMPackagedFlow": true,
4+
"javascript.validate.enable": false
5+
}

.yo-rc.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"generator-canner-react": {
3+
"promptValues": {
4+
"authorName": "chilijung",
5+
"authorEmail": "chilijung@canner.io",
6+
"authorUrl": "",
7+
"webpackExample": true
8+
}
9+
}
10+
}

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
The MIT License (MIT)
2+
3+
Copyright (c) 2018 chilijung <chilijung@canner.io>
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
13+
all 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
21+
THE SOFTWARE.

README.md

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# react-imgloader [![NPM version][npm-image]][npm-url] [![Dependency Status][daviddm-image]][daviddm-url]
2+
> A react image loader component
3+
4+
## Installation
5+
6+
```sh
7+
$ npm install --save react-imgloader
8+
```
9+
10+
## Usage
11+
12+
```js
13+
var reactImgloader = require('react-imgloader');
14+
15+
reactImgloader('Rainbow');
16+
```
17+
18+
## Start example server
19+
20+
```
21+
npm start
22+
```
23+
24+
## generate demo
25+
26+
```js
27+
npm run gh-pages
28+
```
29+
30+
## License
31+
32+
MIT © [chilijung]()
33+
34+
35+
[npm-image]: https://badge.fury.io/js/react-imgloader.svg
36+
[npm-url]: https://npmjs.org/package/react-imgloader
37+
[travis-image]: https://travis-ci.org/Canner/react-imgloader.svg?branch=master
38+
[travis-url]: https://travis-ci.org/Canner/react-imgloader
39+
[daviddm-image]: https://david-dm.org/Canner/react-imgloader.svg?theme=shields.io
40+
[daviddm-url]: https://david-dm.org/Canner/react-imgloader

__test__/.eslintrc

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"env": {
3+
"mocha": true
4+
}
5+
}

__test__/react-imgloader.test.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
2+
describe('PackageName', function() {
3+
it('should have unit test!', function() {
4+
expect(true).toBe(true);
5+
});
6+
});

docs/index.html

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<!doctype html>
2+
<html>
3+
<head>
4+
<title>example</title>
5+
</head>
6+
<body>
7+
<div id="root"></div>
8+
<script src="https://cdnjs.cloudflare.com/ajax/libs/react/16.2.0/react.min.js"></script>
9+
<script src="https://cdnjs.cloudflare.com/ajax/libs/react/16.2.0/react-dom.min.js"></script>
10+
<script src="./static/bundle.js"></script>
11+
</body>
12+
</html>

docs/index.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import React from 'react';
2+
import ReactDOM from 'react-dom';
3+
4+
ReactDOM.render(
5+
<div/>
6+
, document.getElementById('root'));

package.json

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
{
2+
"name": "react-imgloader",
3+
"version": "0.0.0",
4+
"description": "A react image loader component",
5+
"homepage": "",
6+
"author": {
7+
"name": "chilijung",
8+
"email": "chilijung@canner.io",
9+
"url": ""
10+
},
11+
"files": [
12+
"lib"
13+
],
14+
"main": "lib/index.js",
15+
"keywords": [
16+
""
17+
],
18+
"devDependencies": {
19+
"flow-bin": "^0.66.0",
20+
"flow-copy-source": "^1.3.0",
21+
"eslint": "^4.18.2",
22+
"eslint-plugin-flowtype": "^2.46.1",
23+
"eslint-plugin-react": "^6.2.0",
24+
"babel-eslint": "^8.2.2",
25+
"precommit-hook-eslint": "^3.0.0",
26+
"babel-cli": "^6.14.0",
27+
"babel-core": "^6.14.0",
28+
"babel-loader": "^7.1.3",
29+
"babel-preset-flow": "^6.23.0",
30+
"babel-preset-react": "^6.24.1",
31+
"babel-preset-stage-0": "^6.24.1",
32+
"babel-runtime": "^6.11.6",
33+
"cross-env": "^5.1.3",
34+
"rimraf": "^2.5.4",
35+
"jest": "^22.4.2",
36+
"react-addons-test-utils": "^15.6.0",
37+
"enzyme": "^2.4.1",
38+
"mocha": "^3.2.0",
39+
"react": "^16.2.0",
40+
"react-dom": "^16.2.0",
41+
"webpack": "^4.0.1",
42+
"webpack-cli": "^2.0.10",
43+
"webpack-dev-server": "^3.1.0",
44+
"git-directory-deploy": "^1.5.1",
45+
"ncp": "^2.0.0"
46+
},
47+
"scripts": {
48+
"build:flow": "flow-copy-source -v -i '**/test/**' src lib",
49+
"lint": "eslint src test docs",
50+
"clean": "rimraf lib dist",
51+
"build:commonjs": "cross-env BABEL_ENV=commonjs babel src --out-dir lib",
52+
"build": "npm run build:commonjs && npm run build:flow",
53+
"prepublish": "npm run clean && npm run check:src && npm run build",
54+
"check:src": "npm run lint && npm run test",
55+
"test": "jest",
56+
"test:watch": "jest --watch",
57+
"start": "./node_modules/.bin/webpack-dev-server --config webpack.config.dev.js --mode development",
58+
"gh-pages:clean": "rimraf _gh-pages && ncp ./docs ./_gh-pages",
59+
"gh-pages:build": "cross-env BABEL_ENV=production ./node_modules/.bin/webpack --config webpack.config.ghPage.js",
60+
"gh-pages:publish": "git-directory-deploy --directory _gh-pages",
61+
"gh-pages": "npm run gh-pages:clean && npm run gh-pages:build && npm run gh-pages:publish",
62+
"validate": "npm ls"
63+
},
64+
"pre-commit": [
65+
"lint"
66+
],
67+
"repository": "Canner/react-imgloader",
68+
"peerDependencies": {
69+
"react": "^0.14.0 || ^15.0.0 || 16.x",
70+
"react-dom": "^0.14.0 || ^15.0.0 || 16.x"
71+
},
72+
"license": "MIT"
73+
}

src/index.js

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
// @flow
2+
import React from 'react';
3+
import Spinner from './Spinner';
4+
5+
export default class ImageLoader extends React.Component {
6+
constructor(props) {
7+
super(props);
8+
9+
this.state = {
10+
isLoading: true,
11+
src: ''
12+
}
13+
}
14+
15+
componentDidMount() {
16+
const image = new Image();
17+
image.src = this.props.src;
18+
image.onload = () => {
19+
this.setState({
20+
src: image.src,
21+
isLoading: false
22+
});
23+
if (this.props.onLoad) {
24+
this.props.onLoad(image);
25+
}
26+
};
27+
image.onerror = (err) => {
28+
this.setState({
29+
src: '',
30+
isLoading: false
31+
});
32+
if (this.props.onError) {
33+
this.props.onError(err);
34+
}
35+
}
36+
}
37+
38+
render() {
39+
if (this.state.isLoading) {
40+
return (
41+
<Spinner src={this.props.spinnerSrc}/>
42+
);
43+
} else {
44+
return (
45+
<img className='ril--image' src={this.state.src} alt={this.props.alt} {...this.props}/>
46+
);
47+
}
48+
}
49+
}

webpack.config.dev.js

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
const path = require('path');
2+
3+
module.exports = {
4+
entry: './docs/index.js',
5+
output: {
6+
path: path.join(__dirname, 'dist'),
7+
filename: 'bundle.js',
8+
publicPath: '/docs/static/'
9+
},
10+
resolve: {
11+
extensions: ['.js']
12+
},
13+
resolveLoader: {
14+
moduleExtensions: ['-loader']
15+
},
16+
module: {
17+
rules: [
18+
{
19+
test: /\.js$/,
20+
use: 'babel',
21+
exclude: path.resolve(__dirname, "node_modules")
22+
}
23+
]
24+
}
25+
};

webpack.config.ghPages.js

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
const path = require('path');
2+
3+
module.exports = {
4+
entry: './_gh-pages/index.js',
5+
output: {
6+
path: path.join(__dirname, '_gh-pages/static'),
7+
filename: 'bundle.js',
8+
libraryTarget: 'var'
9+
},
10+
externals: {
11+
'react': "React",
12+
'react-dom': "ReactDOM"
13+
},
14+
resolve: {
15+
extensions: ['.js']
16+
},
17+
resolveLoader: {
18+
moduleExtensions: ['-loader']
19+
},
20+
module: {
21+
rules: [
22+
{
23+
test: /\.js$/,
24+
use: 'babel',
25+
exclude: path.resolve(__dirname, "node_modules")
26+
}
27+
]
28+
}
29+
};

webpack.config.prod.js

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
const path = require('path');
2+
3+
module.exports = {
4+
entry: './docs/index.js',
5+
output: {
6+
path: path.join(__dirname, 'docs/static'),
7+
filename: 'bundle.js',
8+
libraryTarget: 'var'
9+
},
10+
externals: {
11+
'react': "React",
12+
'react-dom': "ReactDOM"
13+
},
14+
resolve: {
15+
extensions: ['.js']
16+
},
17+
resolveLoader: {
18+
moduleExtensions: ['-loader']
19+
},
20+
module: {
21+
rules: [
22+
{
23+
test: /\.js$/,
24+
use: 'babel',
25+
exclude: path.resolve(__dirname, "node_modules")
26+
}
27+
]
28+
}
29+
};

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy