1 | ![Dev Build Status](https://img.shields.io/circleci/project/github/topcoder-platform/topcoder-react-utils/develop.svg?label=develop)
|
2 | ![Master Build Status](https://img.shields.io/circleci/project/github/topcoder-platform/topcoder-react-utils/master.svg?label=master)
|
3 | ![Latest NPM Release](https://img.shields.io/npm/v/topcoder-react-utils.svg)
|
4 | ![NPM Downloads](https://img.shields.io/npm/dm/topcoder-react-utils.svg)
|
5 |
|
6 | # Topcoder React Utils
|
7 | The [Topcoder](https://www.topcoder.com) collection of generic ReactJS
|
8 | configurations, components and utilities to be shared between all internal and
|
9 | external ReactJS projects developed by the Topcoder community.
|
10 |
|
11 | ## Content
|
12 | - [Installation](#installation)
|
13 | - [Reference](#reference)
|
14 | - [Configurations](#configurations)
|
15 | - [Components](#components)
|
16 | - [NodeJS Scripts](#nodejs-scripts)
|
17 | - [Redux Templates](#redux-templates)
|
18 | - [Utilities](#utilities)
|
19 | - [Development](#development)
|
20 | - [License](#license)
|
21 |
|
22 | ## Installation
|
23 | Install the package as
|
24 | ```bash
|
25 | $ npm install --save topcoder-react-utils
|
26 | $ ./node_modules/.bin/topcoder-lib-setup
|
27 | ```
|
28 | Then import the global stylesheet into the root ReactJS component of your app:
|
29 | ```jsx
|
30 | /* eslint-disable global-require */
|
31 | if (process.env.NODE_ENV === 'production') {
|
32 | require('topcoder-react-utils/dist/prod/style.css');
|
33 | } else {
|
34 | require('topcoder-react-utils/dist/dev/style.css');
|
35 | }
|
36 | /* eslint-enable global-require */
|
37 | ```
|
38 |
|
39 | To upgrade this library to the latest version just execute again
|
40 | ```bash
|
41 | $ ./node_modules/.bin/topcoder-lib-setup
|
42 | ```
|
43 |
|
44 | ## Reference
|
45 | ### Configurations
|
46 | - [**Babel Configurations**](docs/babel-config.md) — Standard
|
47 | configurations for [Babel](https://babeljs.io/);
|
48 | - [**ESLint Configurations**](docs/eslint-config.md) — Standard
|
49 | configurations for [ESLint](https://eslint.org/);
|
50 | - [**Jest Configurations**](docs/jest-config.md) — Standard configurations
|
51 | for [Jest](https://facebook.github.io/jest/);
|
52 | - [**Stylelint Configurations**](docs/stylelint-config.md) — Standard
|
53 | configurations for [Stylelint](https://stylelint.io)
|
54 | - [**Webpack Configurations**](docs/webpack-config.md) — Standard
|
55 | configurations for [Webpack](https://webpack.js.org/).
|
56 |
|
57 | ### Components
|
58 | - [**`Avatar`**](docs/avatar.md) — The standard component for user avatars;
|
59 | - [**`Button`**](docs/button.md) — Handles buttons and button-like links
|
60 | (components that look like regular buttons, but behave as links) in the same
|
61 | uniform manner;
|
62 | - [**`Link` and `NavLink`**](docs/link-and-navlink.md) — Auxiliary wrappers
|
63 | around [React Router](https://github.com/ReactTraining/react-router)'s `<Link>`
|
64 | and `<NavLink>` components; they help to handle external and internal links in
|
65 | the same uniform manner;
|
66 | - [**`ScalableRect`**](docs/scalable-rect.md) — Container that keeps
|
67 | the specified aspect ratio regardless the width you set.
|
68 |
|
69 | ### NodeJS Scripts
|
70 | - [**topcoder-lib-setup**](docs/topcoder-lib-setup-script.md) — Helps to
|
71 | install and upgrade **topcoder-react-utils** and other similar libraries.
|
72 |
|
73 | ### Redux Templates
|
74 | - [**Item**](docs/redux-item.md) — An async piece of data in Redux store.
|
75 |
|
76 | ### Utilities
|
77 | - [**Client**](docs/client.md) — Client-side initialization code.
|
78 | - [**Config**](docs/config.md) — Isomorphic app config;
|
79 | - [**Global Styles**](docs/global-styles.md) — Global styles necessary for
|
80 | a generic application;
|
81 | - [**Isomorphy**](docs/isomorphy-utils.md) — Collection of helpers to deal
|
82 | with isomorphic aspects of the code;
|
83 | - [**Jest utils**](docs/jest-utils.md) — Collection of helpers to be used
|
84 | in Jest tests code;
|
85 | - [**Redux utils**](docs/redux-utils.md) — *TO BE DOCUMENTED*
|
86 | - [**SCSS Mixins**](docs/scss-mixins.md) — Collection of useful style
|
87 | mixins;
|
88 | - [**Server**](docs/server.md) — Easy creation and launch of web-server
|
89 | with standard configuration, that serves a ReactJS application with or without
|
90 | server-side rendering, supports development tools (Hop Module Reloading), and
|
91 | can be further configured for the needs of specific projects.
|
92 | - [**Webpack**](docs/webpack-utils.md) — Various utils related to the
|
93 | Webpack bundling process.
|
94 |
|
95 | ## Development
|
96 | For convenient development you can link this package into your host package:
|
97 | 1. Clone [`topcoder-react-utils`](https://github.com/topcoder-platform/topcoder-react-utils)
|
98 | to your machine, and checkout the branch you are going to work with;
|
99 | 2. Inside `topcoder-react-utils` folder:
|
100 | - Install dependencies with `$ npm install`;
|
101 | - Locate `node_modules/extract-css-chunks-webpack-plugin/index.js` and
|
102 | inside the `isChunk(..)` function (line #358) add `return true;` statement,
|
103 | so that this function always returns *true*. This step is necessary at
|
104 | the moment, because the check `chunk instanceof Chunk` check inside this
|
105 | function does not work as expected when Webpack config is spread across
|
106 | multiple inter-linked packages.
|
107 | - Run the dev build `$ npm run build:dev`. It will compile the package, and
|
108 | also will watch for the file changes to automatically re-compile it as
|
109 | necessary.
|
110 | 3. Inside the host package execute
|
111 | `$ npm link PATH_TO_TOPCODER_REACT_UTILS_FOLDER`. It will create a symlink
|
112 | from `HOST_PACKAGE/node_modules/topcoder-react-utils` to your local copy of
|
113 | the `topcoder-react-utils` package, so that any changes you do there become
|
114 | automatically available to the host package.
|
115 |
|
116 | CI/CD is set up with CircleCI 2.0 for this repo. A commit to any branch, beside
|
117 | `master` will trigger testing of the commited code (it will run `$ npm test` and
|
118 | ensures that it does not fail). A commit to the protected `master` branch (only
|
119 | organization members and repo admins can commit to `master`) will trigger the
|
120 | testing, and, if successful, release of the updated package to the NPM registry.
|
121 |
|
122 | For successful release to NPM you should bump the package version in the
|
123 | `package.json`. To do it conveniently you can use `$ npm version UPDATE_TYPE`
|
124 | command, where `UPDATE_TYPE` stays for one of `patch`/`minor`/`major` to bump up
|
125 | `2`, `1`, or `0` in a sample version number `v0.1.2`. This command will update
|
126 | `package.json` and `package-lock.json`, and create a new commit and tag in the
|
127 | checked-out Git branch. Mind that `patch` updates should not introduce
|
128 | any breaking changes into the codebase! Breaking changes should be done via
|
129 | `minor` or `major` update, and they should be documented in
|
130 | the [CHANGELOG](CHANGELOG.md).
|
131 |
|
132 | ## License
|
133 | Topcoder React Utils is [MIT Licensed](LICENSE.md)
|