UNPKG

6.62 kBMarkdownView Raw
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
7The [Topcoder](https://www.topcoder.com) collection of generic ReactJS
8configurations, components and utilities to be shared between all internal and
9external 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
23Install the package as
24```bash
25$ npm install --save topcoder-react-utils
26$ ./node_modules/.bin/topcoder-lib-setup
27```
28Then import the global stylesheet into the root ReactJS component of your app:
29```jsx
30/* eslint-disable global-require */
31if (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
39To 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- [**`Modal`**](docs/modal.md) &ndash; Themeable modal component;
67- [**`ScalableRect`**](docs/scalable-rect.md) &ndash; Container that keeps
68 the specified aspect ratio regardless the width you set.
69
70### NodeJS Scripts
71- [**topcoder-lib-setup**](docs/topcoder-lib-setup-script.md) &ndash; Helps to
72 install and upgrade **topcoder-react-utils** and other similar libraries.
73
74### Redux Templates
75- [**Item**](docs/redux-item.md) &ndash; An async piece of data in Redux store.
76
77### Utilities
78- [**Client**](docs/client.md) &ndash; Client-side initialization code.
79- [**Config**](docs/config.md) &ndash; Isomorphic app config;
80- [**Global Styles**](docs/global-styles.md) &ndash; Global styles necessary for
81 a generic application;
82- [**Isomorphy**](docs/isomorphy-utils.md) &ndash; Collection of helpers to deal
83 with isomorphic aspects of the code;
84- [**Jest utils**](docs/jest-utils.md) &ndash; Collection of helpers to be used
85 in Jest tests code;
86- [**Redux utils**](docs/redux-utils.md) &ndash; *TO BE DOCUMENTED*
87- [**SCSS Mixins**](docs/scss-mixins.md) &ndash; Collection of useful style
88 mixins;
89- [**Server**](docs/server.md) &ndash; Easy creation and launch of web-server
90 with standard configuration, that serves a ReactJS application with or without
91 server-side rendering, supports development tools (Hop Module Reloading), and
92 can be further configured for the needs of specific projects.
93- [**Webpack**](docs/webpack-utils.md) &ndash; Various utils related to the
94 Webpack bundling process.
95
96## Development
97For convenient development you can link this package into your host package:
981. Clone [`topcoder-react-utils`](https://github.com/topcoder-platform/topcoder-react-utils)
99 to your machine, and checkout the branch you are going to work with;
1002. Inside `topcoder-react-utils` folder:
101 - Install dependencies with `$ npm install`;
102 - Locate `node_modules/extract-css-chunks-webpack-plugin/index.js` and
103 inside the `isChunk(..)` function (line #358) add `return true;` statement,
104 so that this function always returns *true*. This step is necessary at
105 the moment, because the check `chunk instanceof Chunk` check inside this
106 function does not work as expected when Webpack config is spread across
107 multiple inter-linked packages.
108 - Run the dev build `$ npm run build:dev`. It will compile the package, and
109 also will watch for the file changes to automatically re-compile it as
110 necessary.
1113. Inside the host package execute
112 `$ npm link PATH_TO_TOPCODER_REACT_UTILS_FOLDER`. It will create a symlink
113 from `HOST_PACKAGE/node_modules/topcoder-react-utils` to your local copy of
114 the `topcoder-react-utils` package, so that any changes you do there become
115 automatically available to the host package.
116
117CI/CD is set up with CircleCI 2.0 for this repo. A commit to any branch, beside
118`master` will trigger testing of the commited code (it will run `$ npm test` and
119ensures that it does not fail). A commit to the protected `master` branch (only
120organization members and repo admins can commit to `master`) will trigger the
121testing, and, if successful, release of the updated package to the NPM registry.
122
123For successful release to NPM you should bump the package version in the
124`package.json`. To do it conveniently you can use `$ npm version UPDATE_TYPE`
125command, where `UPDATE_TYPE` stays for one of `patch`/`minor`/`major` to bump up
126`2`, `1`, or `0` in a sample version number `v0.1.2`. This command will update
127`package.json` and `package-lock.json`, and create a new commit and tag in the
128checked-out Git branch. Mind that `patch` updates should not introduce
129any breaking changes into the codebase! Breaking changes should be done via
130`minor` or `major` update, and they should be documented in
131the [CHANGELOG](CHANGELOG.md).
132
133## License
134Topcoder React Utils is [MIT Licensed](LICENSE.md)