1 | # Watson Developer Cloud React Components
|
2 |
|
3 | [![Build Status](https://travis-ci.org/watson-developer-cloud/react-components.svg?branch=master)](https://travis-ci.org/watson-developer-cloud/react-components)
|
4 | [![npm-version](https://img.shields.io/npm/v/watson-react-components.svg)](https://www.npmjs.com/package/watson-react-components)
|
5 |
|
6 |
|
7 | A collection of [React](https://facebook.github.io/react/) components to write web applications using the Watson APIs.
|
8 |
|
9 | Documentation: https://watson-developer-cloud.github.io/react-components/
|
10 |
|
11 | ## Getting Started
|
12 |
|
13 | 1. Install the library
|
14 |
|
15 | ```
|
16 | npm install --save watson-react-components
|
17 | ```
|
18 |
|
19 | 2. Add components to your React file where needed:
|
20 |
|
21 | Example:
|
22 | ```js
|
23 | import { Header, Footer, /*...*/} from 'watson-react-components';
|
24 | ```
|
25 |
|
26 | 3. Make the assets public. For a Node.js/Express server, the following code should work:
|
27 |
|
28 | ```js
|
29 | app.use(express.static('./node_modules/watson-react-components/dist/'));
|
30 | ```
|
31 |
|
32 | For other environments, check out the code and run `npm install; npm run build` and then copy the contents of the `dist/` directory into your static folder.
|
33 |
|
34 | 4. Add a reference to the stylesheet.
|
35 |
|
36 | ```html
|
37 | <link rel="stylesheet" type="text/css" href="/css/watson-react-components.min.css">
|
38 | ```
|
39 |
|
40 | Adjust the `href` as necessary if a different location was chosen in step 3
|
41 |
|
42 |
|
43 | ## How to Contribute
|
44 |
|
45 | 1. Install Dependencies
|
46 |
|
47 | ```
|
48 | npm install
|
49 | ```
|
50 |
|
51 | 2. Start the development server
|
52 |
|
53 | ```
|
54 | npm run dev
|
55 | ```
|
56 | Changes will refresh the page thanks to [browsersync](https://www.browsersync.io).
|
57 |
|
58 |
|
59 | 3. Run the build command before pushing merge request:
|
60 |
|
61 | ```
|
62 | npm run build
|
63 | ```
|
64 |
|
65 | ### Directory structure
|
66 |
|
67 | ```
|
68 | .
|
69 | ├── README.md
|
70 | ├── dist
|
71 | │ ├── components // ES5 react components
|
72 | │ ├── css
|
73 | │ ├── images
|
74 | │ ├── js
|
75 | │ └── scss
|
76 | ├── example
|
77 | │ ├── build
|
78 | │ ├── index.html
|
79 | │ └── src
|
80 | ├── gh-pages
|
81 | │ ├── build
|
82 | │ ├── images
|
83 | │ ├── index.html
|
84 | │ └── src
|
85 | ├── gulpfile.js
|
86 | ├── package.json
|
87 | ├── src
|
88 | │ ├── components // React components
|
89 | │ └── stylesheets // Sass files
|
90 | └── static // static files
|
91 | └── images // images
|
92 | ```
|
93 | ## License
|
94 |
|
95 | This sample code is licensed under Apache 2.0.
|
96 |
|
97 | ## Contributing
|
98 |
|
99 | See [CONTRIBUTING](.github/CONTRIBUTING.md).
|
100 |
|
101 | ## Open Source @ IBM
|
102 | Find more open source projects on the [IBM Github Page](http://ibm.github.io/)
|
103 |
|
\ | No newline at end of file |