Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
naoufal committed Sep 7, 2015
0 parents commit ac9618f
Show file tree
Hide file tree
Showing 22 changed files with 506 additions and 0 deletions.
4 changes: 4 additions & 0 deletions .codeclimate.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
exclude_paths:
- "examples/*"
- "lib/*"
- "test/*"
Empty file added .eslint
Empty file.
4 changes: 4 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
examples
lib
node_modules
test
62 changes: 62 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
{
"env": {
"browser": true,
"mocha": true,
"node": true,
"es6": true
},
"ecmaFeatures": {
"modules": true,
"jsx": true
},
"rules": {
"array-bracket-spacing": [2, "never"],
"brace-style": [2, "1tbs"],
"comma-dangle": [2, "never"],
"comma-spacing": [2, {
"before": false,
"after": true
}],
"comma-style": [2, "last"],
"eol-last": 2,
"func-names": 2,
"func-style": [2, "expression"],
"indent": [2, 2],
"key-spacing": [2, {
"beforeColon": false,
"afterColon": true
}],
"linebreak-style": [2, "unix"],
"max-nested-callbacks": [2, 2],
"new-parens": 2,
"no-nested-ternary": 2,
"no-new-object": 2,
"no-spaced-func": 2,
"no-trailing-spaces": 2,
"no-unneeded-ternary": 2,
"object-curly-spacing": [2, "always"],
"padded-blocks": [2, "never"],
"quote-props": [2, "as-needed"],
"quotes": [2, "double"],
"semi": [2, "always"],
"semi-spacing": [2, {
"before": false,
"after": true
}],
"space-after-keywords": [2, "always"],
"space-before-blocks": [2, "always"],
"space-before-function-paren": [2, "never"],
"space-in-parens": [2, "never"],
"space-infix-ops": 2,
"space-return-throw-case": 2,
"space-unary-ops": [2, {
"words": true,
"nonwords": false
}],
"spaced-comment": [2, "always"],
"wrap-regex": 2
},
"plugins": [
"react"
]
}
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
*.log
.DS_Store
lib
node_modules
3 changes: 3 additions & 0 deletions .jshintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"esnext": true
}
5 changes: 5 additions & 0 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
*.log
.DS_Store
examples
src
test
5 changes: 5 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
language: node_js
node_js:
- "iojs"
script:
- npm test
65 changes: 65 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
# React Progress HUD
[![npm](https://img.shields.io/npm/v/react-progress-hud.svg?style=flat-square)](https://www.npmjs.com/package/react-progress-hud)
[![npm downloads](https://img.shields.io/npm/dm/react-progress-hud.svg?style=flat-square)](https://www.npmjs.com/package/react-progress-hud)
[![Travis](https://img.shields.io/travis/naoufal/react-progress-hud.svg?style=flat-square)](https://travis-ci.org/naoufal/react-native-progress-hu://travis-ci.org/naoufal/react-progress-hud)
[![Code Climate](https://img.shields.io/codeclimate/github/naoufal/react-progress-hud.svg?style=flat-square)](https://codeclimate.com/github/naoufal/react-progress-hud)

React Progress HUD is a [React](https://facebook.github.io/react) port of the popular [`SVProgressHUD`](https://github.com/TransitApp/SVProgressHUD). It is a clean and easy-to-use HUD meant to display the progress of an ongoing task.

## Install
```shell
npm i --save react-progress-hud
```

## Usage
Using the HUD in your app will usually look like this:
```js
import React, { Component } from "react";
import { ProgressHUD, Wrapper } from "react-progress-hud";

class YourComponent extends Component {
render() {
return (
<div>
<button onClick={this.props.showProgressHUD>Show Progress HUD</button>
<ProgressHUD
isVisible={this.props.isVisible}
clickHandler={this.props.dismissProgressHUD}
overlayColor="rgba(0, 0, 0, 0.11)"
/>
</div>
);
}
}

export default Wrapper(App);
```
### Showing the HUD
You can display the HUD by calling:
```js
this.props.showProgressHUD();
```
### Dismissing the HUD
It can be dismissed by calling:
```js
this.props.dismissProgressHUD();
```
## Props
The following props can be used to modify the HUD's style and/or behaviour:
| Prop | Type | Opt/Required | Default | Note |
|---|---|---|---|---|
|__`isVisible`__|_Boolean_|Required|`N/A`|Displays the HUD when set to true.
|__`clickHandler`__|_Function_|Optional|`() => {}`|Sets a clickHandler on the `ProgressHUD`.
|__`overlayColor`__|_String_|Optional|`rgba(0, 0, 0, 0)`|Sets the color of the overlay.
|__`color`__|_String_|Optional|`#000`|Sets the color of the spinner.
## License
Copyright (c) 2015, [Naoufal Kadhom](http://naoufal.com)
Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
2 changes: 2 additions & 0 deletions examples/simple/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
node_modules
*.log
30 changes: 30 additions & 0 deletions examples/simple/components/App.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import React, { Component } from "react";
import { ProgressHUD, Wrapper } from "../../../lib/index";

let App = React.createClass({
_renderButton() {
return (
<button onClick={this._clickHandler}>Show Progress HUD</button>
);
},

_clickHandler() {
this.props.showProgressHUD();
},

render() {
return (
<div>
<h1>Progress HUD</h1>
{this._renderButton()}
<ProgressHUD
isVisible={this.props.isVisible}
overlayColor="rgba(0, 0, 0, 0.11)"
clickHandler={this.props.dismissProgressHUD}
/>
</div>
);
}
});

export default Wrapper(App);
10 changes: 10 additions & 0 deletions examples/simple/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<html>
<head>
<title>react-progress-hud-demo</title>
</head>
<body>
<div id="root">
</div>
<script src="/static/bundle.js"></script>
</body>
</html>
7 changes: 7 additions & 0 deletions examples/simple/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import React from 'react';
import App from './components/App';

React.render(
<App />,
document.getElementById('root')
);
27 changes: 27 additions & 0 deletions examples/simple/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"name": "react-progress-hud-example",
"version": "1.0.0",
"description": "react-progress-hud-example demo",
"main": "server.js",
"scripts": {
"start": "node server.js"
},
"repository": {
"type": "git",
"url": "https://github.com/naoufal/react-progress-hud.git"
},
"license": "ISC",
"bugs": {
"url": "https://github.com/naoufal/react-progress-hud/issues"
},
"homepage": "https://github.com/naoufal/react-progress-hud",
"devDependencies": {
"babel-core": "5.8.23",
"babel-loader": "5.1.4",
"node-libs-browser": "0.5.2",
"react": "0.13.3",
"react-hot-loader": "1.2.7",
"webpack": "1.9.11",
"webpack-dev-server": "1.9.0"
}
}
18 changes: 18 additions & 0 deletions examples/simple/server.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
var webpack = require('webpack');
var WebpackDevServer = require('webpack-dev-server');
var config = require('./webpack.config');

new WebpackDevServer(webpack(config), {
publicPath: config.output.publicPath,
hot: true,
historyApiFallback: true,
stats: {
colors: true
}
}).listen(3000, 'localhost', function (err) {
if (err) {
console.log(err);
}

console.log('Listening at localhost:3000');
});
45 changes: 45 additions & 0 deletions examples/simple/webpack.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
var path = require('path');
var webpack = require('webpack');

module.exports = {
devtool: 'eval',
entry: [
'webpack-dev-server/client?http://localhost:3000',
'webpack/hot/only-dev-server',
'./index'
],

output: {
path: path.join(__dirname, 'dist'),
filename: 'bundle.js',
publicPath: '/static/'
},

plugins: [
new webpack.HotModuleReplacementPlugin(),
new webpack.NoErrorsPlugin(),
],

resolve: {
alias: {
'react-progress-hud': path.join(__dirname, '..', '..', 'src')
},
extensions: ['', '.js']
},

module: {
loaders: [
{
test: /\.(js|jsx)$/,
loaders: ['react-hot', 'babel'],
exclude: /node_modules/,
include: __dirname
},
{
test: /\.(js|jsx)$/,
loaders: ['babel'],
include: path.join(__dirname, '..', '..', 'src')
}
]
}
};
40 changes: 40 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
{
"name": "react-progress-hud",
"version": "0.1.0",
"description": "A clean and lightweight progress HUD for your React app",
"main": "lib/index.js",
"scripts": {
"build": "./node_modules/.bin/babel --optional runtime src --out-dir lib",
"build:watch": "./node_modules/.bin/babel --optional runtime src --watch --out-dir lib",
"lint": "./node_modules/.bin/eslint .",
"test": "npm run lint"
},
"repository": {
"type": "git",
"url": "https://github.com/naoufal/react-progress-hud"
},
"keywords": [
"react",
"progress",
"hud",
"popup",
"loader",
"loading",
"react-component"
],
"author": "Naoufal Kadhom",
"license": "ISC",
"bugs": {
"url": "https://github.com/naoufal/react-progress-hud/issues"
},
"homepage": "https://github.com/naoufal/react-progress-hud",
"devDependencies": {
"babel": "5.8.23",
"babel-eslint": "4.1.1",
"babel-runtime": "5.8.20",
"eslint": "1.3.1",
"eslint-plugin-react": "3.3.1",
"react": "0.13.3",
"react-motion": "0.2.7"
}
}
Loading

0 comments on commit ac9618f

Please sign in to comment.