|
1 | | - |
| 1 | + |
2 | 2 |
|
3 | 3 | <p align="center"> |
4 | | - <a href="https://www.npmjs.com/package/react-npm-package-template"> |
5 | | - <img src="https://img.shields.io/npm/v/react-npm-package-template" alt="npm version"> |
| 4 | + <a href="https://www.npmjs.com/package/react-promise-loader"> |
| 5 | + <img src="https://img.shields.io/npm/v/react-promise-loader" alt="npm version"> |
6 | 6 | </a> |
7 | | - <a href="https://travis-ci.org/awibox/react-npm-package-template"> |
8 | | - <img src='https://travis-ci.org/awibox/react-npm-package-template.svg?branch=master' alt='Build' /> |
| 7 | + <a href="https://travis-ci.org/awibox/react-promise-loader"> |
| 8 | + <img src='https://travis-ci.org/awibox/react-promise-loader.svg?branch=master' alt='Build' /> |
9 | 9 | </a> |
10 | | - <a href='https://coveralls.io/github/awibox/react-npm-package-template?branch=master'> |
11 | | - <img src='https://coveralls.io/repos/github/awibox/react-npm-package-template/badge.svg?branch=master' alt='Coverage Status' /> |
| 10 | + <a href='https://coveralls.io/github/awibox/react-promise-loader?branch=master'> |
| 11 | + <img src='https://coveralls.io/repos/github/awibox/react-promise-loader/badge.svg?branch=master' alt='Coverage Status' /> |
12 | 12 | </a> |
13 | | - <a href="https://www.npmjs.com/package/react-npm-package-template"> |
14 | | - <img src="https://img.shields.io/npm/dm/react-npm-package-template" alt="Downloads"> |
| 13 | + <a href="https://www.npmjs.com/package/react-promise-loader"> |
| 14 | + <img src="https://img.shields.io/npm/dm/react-promise-loader" alt="Downloads"> |
15 | 15 | </a> |
16 | | - <img src="https://img.shields.io/github/license/awibox/react-npm-package-template" alt="license"> |
| 16 | + <img src="https://img.shields.io/github/license/awibox/react-promise-loader" alt="license"> |
17 | 17 | </p> |
18 | 18 |
|
19 | 19 | ## Table of contents |
20 | | -* [How to install](#howtoinstall) |
21 | | -* [Initializing the package](#initializing) |
22 | | -* [Rename a component](#rename) |
23 | | -* [Build of the package](#build) |
24 | | -* [Publishing a package](#publish) |
25 | | -* [Travis CI](#travis) |
26 | | -* [Coveralls](#coveralls) |
27 | | -* [Badges in the readme](#badges) |
| 20 | +* [Installation](#installation) |
| 21 | +* [Getting started](#gettingstarted) |
| 22 | +* [The settings of the component](#settings) |
| 23 | +* [Contributing](#contributing) |
28 | 24 |
|
29 | | -<a name="howtoinstall"></a> |
30 | | -## How to install |
31 | | -You can use this project like template. |
32 | | -To do this, you need press button "**Use this template**". |
33 | | - |
34 | | -Or clone repository and go to the project folder. |
35 | | -```bash |
36 | | -git clone https://github.com/awibox/react-redux-app-boilerplate.git ProjectName |
37 | | -cd ProjectName |
38 | | -``` |
39 | | -Then you should install required dependencies. |
| 25 | +<a name="installation"></a> |
| 26 | +## Installation |
| 27 | +You need to install promise loader and promise tracker packages: |
40 | 28 | ```bash |
41 | | -yarn install |
| 29 | +npm install react-promise-loader react-promise-tracker |
42 | 30 | ``` |
43 | | -<a name="initializing"></a> |
44 | | -## Initializing the package |
45 | | -The first step is to initialize your package. You should execute following command: |
| 31 | +You can use yarn: |
46 | 32 | ```bash |
47 | | -npm init |
| 33 | +yarn add react-promise-loader react-promise-tracker |
48 | 34 | ``` |
49 | | -And fill in the required fields (package name, version, license). You can correct the other fields manually in the **package.json**. |
| 35 | +<a name="gettingstarted"></a> |
| 36 | +## Getting started |
| 37 | +Wrap promises that you would like to track as in the following example: |
| 38 | +```diff |
| 39 | ++ import { trackPromise} from 'react-promise-tracker'; |
| 40 | +//... |
50 | 41 |
|
51 | | -<a name="rename"></a> |
52 | | -## Rename a component |
53 | | -The next step is to replace the ```YourComponentName``` in the entire project with the one you need. |
54 | | - |
55 | | -<a name="build"></a> |
56 | | -## Build of the package |
57 | | -After writing the code you need to build the package with the following command: |
58 | | -```bash |
59 | | -yarn build |
| 42 | ++ trackPromise( |
| 43 | + fetchUsers(); // You function that returns a promise |
| 44 | ++ ); |
60 | 45 | ``` |
| 46 | +Then you need to add the Loader component and send data from the react-promise-tracker: |
| 47 | +```diff |
| 48 | ++ import { usePromiseTracker } from 'react-promise-tracker'; |
| 49 | ++ import Loader from 'react-promise-loader'; |
61 | 50 |
|
62 | | -<a name="publish"></a> |
63 | | -## Publishing a package |
64 | | -To publish a package, run the command: |
65 | | -```bash |
66 | | -npm publish |
67 | | -``` |
68 | | -If you are not logged in to npm you should run the command before publishing: |
69 | | -```bash |
70 | | -npm login |
| 51 | +const App = () => ( |
| 52 | + <div className="app"> |
| 53 | + ... |
| 54 | ++ <Loader promiseTracker={usePromiseTracker} color={'#3d5e61'} background={'rgba(255,255,255,.5)'} /> |
| 55 | + </div> |
| 56 | +); |
| 57 | +export default App; |
71 | 58 | ``` |
72 | 59 |
|
73 | | -<a name="travis"></a> |
74 | | -## Travis CI |
75 | | -You need to register on the [Travis CI](https://travis-ci.org/) and connect the repository. |
76 | | - |
77 | | -<a name="coveralls"></a> |
78 | | -## Coveralls |
79 | | -You need to register on the [Coveralls](https://coveralls.io/) and connect the repository. |
| 60 | +<a name="settings"></a> |
| 61 | +## The settings of the component |
| 62 | +|Parameter|Type|Description|Default| |
| 63 | +|--------------------|--------|-----------|-------| |
| 64 | +|**background**|string|Sets the color for the background in any format that supports css|``` rgba(255,255,255,.5) ```| |
| 65 | +|**color**|string|Sets the color of the spinner|``` #000 ```| |
| 66 | +|**promiseTracker**|boolean|You need to set ```usePromiseTracker``` function from the ```react-promise-tracker```|| |
| 67 | +|**loading**|boolean|If you need to run the loader without tracking promises you should set ```true```|``` false ```| |
80 | 68 |
|
81 | | -<a name="badges"></a> |
82 | | -## Badges in the README.md |
83 | | -For **badges** to work you need to change the repository name in the link and image paths. |
| 69 | +<a name="contributing"></a> |
| 70 | +## Contributing |
| 71 | +Please read through our [CONTRIBUTING.md](/.github/CONTRIBUTING.md). |
0 commit comments