react-toolbox/README.md

75 lines
4.3 KiB
Markdown
Raw Normal View History

2015-11-01 20:25:29 +03:00
# React Toolbox
2015-06-19 12:21:46 +03:00
2015-11-08 14:44:58 +03:00
![Last version](https://img.shields.io/github/tag/react-toolbox/react-toolbox.svg?style=flat-square)
[![Build Status](http://img.shields.io/travis/react-toolbox/react-toolbox/master.svg?style=flat-square)](https://travis-ci.org/react-toolbox/react-toolbox)
[![NPM Status](http://img.shields.io/npm/dm/react-toolbox.svg?style=flat-square)](https://www.npmjs.org/package/react-toolbox)
2015-11-03 10:32:46 +03:00
[![Donate](https://img.shields.io/badge/donate-paypal-blue.svg?style=flat-square)](https://paypal.me/javivelasco)
2015-11-08 14:44:58 +03:00
[![Gitter](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/react-toolbox/react-toolbox?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=body_badge)
2015-11-01 19:52:07 +03:00
2015-11-02 13:15:19 +03:00
React Toolbox is a set of [React](http://facebook.github.io/react/) components that implement [Google's Material Design specification](https://www.google.com/design/spec/material-design/introduction.html). It's powered by [CSS Modules](https://github.com/css-modules/css-modules) and harmoniously integrates with your [Webpack](http://webpack.github.io/) workflow. You can take a tour through our documentation website and try the components live!
2015-11-01 19:52:07 +03:00
## Installation
2015-11-06 13:08:22 +03:00
React Toolbox can be installed as an [npm package](https://www.npmjs.org/package/react-toolbox);
2015-11-01 19:52:07 +03:00
```
npm install --save react-toolbox
```
## Usage
Although there are other ways to use React Toolbox, the recommended way is to create a Webpack workflow with [Babel Loader](https://github.com/babel/babel-loader), [CSS Loader](https://github.com/webpack/css-loader) and [SASS Loader](https://github.com/jtangelder/sass-loader). A good starting point is [React Hot Webpack Boilerplate](https://github.com/gaearon/react-hot-boilerplate).
Once you have the workflow ready, you can just require and use the components:
```jsx
import React from 'react';
import Button from 'react-toolbox/lib/button';
2015-11-01 19:52:07 +03:00
2015-11-01 19:53:46 +03:00
const CustomButton = () => (
2015-11-01 19:52:07 +03:00
<Button label="Hello world" kind="raised" accent />
);
2015-11-01 19:53:46 +03:00
export default CustomButton;
2015-11-01 19:52:07 +03:00
```
2015-11-02 04:30:39 +03:00
The previous code creates a React button component based on React toolbox button. It's important to notice that requiring a module from the exposed root of the package will import the **SASS** of the component.
2015-11-01 19:52:07 +03:00
We encourage you to work with webpack but if you want to use React Toolbox in an old fashioned way you must generate a build with all the css and javascript and include it in your `index.html`. Then you can use the components exposed in the `window` object.
## Customization
Since React Toolbox styles are written in CSS it's pretty easy to customize your components. We have several ways:
2015-11-03 11:49:35 +03:00
### Via React Toolbox Loader
2015-11-01 19:52:07 +03:00
2015-11-03 11:49:35 +03:00
Thanks to the power of SASS, all components in React Toolbox are configured from a variables file. The best way to customize your build is to create a custom configuration SASS file overriding configuration variables like colors or sizes.
2015-11-01 19:52:07 +03:00
2015-11-03 11:49:35 +03:00
With [toolbox-loader](https://github.com/react-toolbox/toolbox-loader) you can tell webpack where your configuration file is and it will prepend your config to each SASS build. This will result in your customized CSS for React Toolbox Components. For now you can browse the configuration files and override what you want.
2015-11-01 19:52:07 +03:00
### Via `className` property
Generally each component will have a `className` prop so you can tell the class name you want to keep in the root node of the resulting markup. All markup is style with the lowest specificity level so you can just nest one level in your CSS and the result will be applied. Consider this example:
```jsx
const CustomButton = () => (
<Button className='customized' label='Custom button' />
);
```
If you browse the resulting markup you will see *data attributes* like `data-role="label"` so you can avoid styling directly tag names. You can now write your CSS:
```css
.customized > [data-role="label"] {
color: green;
font-weight: bold;
}
```
## Authors and Contributors
2015-11-01 19:56:04 +03:00
The project is being initially developed and maintained by [Javier Velasco](http://javivelasco.com) and [Javier Jiménez](http://soyjavi.com) and the [contribution scene](https://github.com/react-toolbox/react-toolbox/graphs/contributors) is just getting warm. We want to create reference components so any contribution is very welcome.
2015-11-01 19:52:07 +03:00
## License
This project is licensed under the terms of the [MIT license](https://github.com/react-toolbox/react-toolbox/blob/master/LICENSE).