Coder Social home page Coder Social logo

react-toolbox / react-toolbox Goto Github PK

View Code? Open in Web Editor NEW
8.7K 163.0 976.0 12.79 MB

A set of React components implementing Google's Material Design specification with the power of CSS Modules

Home Page: http://www.react-toolbox.io

License: MIT License

HTML 0.22% CSS 21.17% JavaScript 67.64% TypeScript 10.97%
material-design react ui-kits css-modules

react-toolbox's Introduction

npm version Build Status NPM Status Donate OpenCollective OpenCollective

React Toolbox is a set of React components that implement Google's Material Design specification. It's powered by CSS Modules and harmoniously integrates with your webpack workflow, although you can use any other module bundler. You can take a tour through our documentation website and try the components live!

Note: ⚠️ This source code refers to the future version. To check the source for 1.x go to master branch. There is a migration guide so you can start working with 2.0-beta.x now!

Installation

React Toolbox can be installed as an npm package:

$ npm install --save react-toolbox

Prerequisites

React Toolbox uses CSS Modules by default to import stylesheets written using PostCSS & postcss-preset-env features. In case you want to import the components already bundled with CSS, your module bundler should be able to require these PostCSS modules.

Although we recommend webpack, you are free to use whatever module bundler you want as long as it can compile and require PostCSS files located in your node_modules. If you are experiencing require errors, make sure your configuration satisfies this requirement.

Of course this is a set of React components so you should be familiar with React. If want to customize your components via themes, you may want to take a look to react-css-themr which is used by React Toolbox to make components easily themeable.

Usage in Create React App Projects

Create React App does not allow to change the default configuration, so you need an additional build step to configure react-toolbox in its project.

Follow these instructions to add react-toolbox to a project created with Create React App.

Usage in Webpack Projects (Not Create React App)

npm install postcss-loader --save-dev
npm install postcss postcss-preset-env postcss-calc --save

Configure webpack 1.x loader for .css files to use postcss:

      {
        test: /\.css$/,
        loaders: [
          'style-loader',
          'css-loader?sourceMap&modules&importLoaders=1&localIdentName=[name]__[local]___[hash:base64:5]!postcss?sourceMap&sourceComments',
        ],
      },

Declare plugins to be used by postcss (as part of webpack's config object):

  // webpack.config.js
  postcss: () => {
    return [
      /* eslint-disable global-require */
      require('postcss-preset-env')({
        stage: 0, // required to get all features that were from cssnext without enabling them one by one
        features: {
          'custom-properties': {
            preserve: false, // required to output values instead of variables
          },
          'color-mod-function': true, // required to use color-mod()
        }
      }),
      require('postcss-calc'), // required as postcss-preset-env doesn't have a reduce calc() funtion that cssnext did
      /* eslint-enable global-require */
    ];
  },

Configure webpack 2.x or 3.x loader for .css files to use postcss:

  // webpack.config.js
  {
    test: /\.css$/,
    use: [
      "style-loader",
      {
        loader: "css-loader",
        options: {
          modules: true, // default is false
          sourceMap: true,
          importLoaders: 1,
          localIdentName: "[name]--[local]--[hash:base64:8]"
        }
      },
      "postcss-loader"
    ]
  }

Basic usage

In this minimal example, we import a Button with styles already bundled:

import React from 'react';
import ReactDOM from 'react-dom';
import { Button } from 'react-toolbox/lib/button';

ReactDOM.render(
  <Button label="Hello World!" />,
  document.getElementById('app')
);

Note: if you use it with Create React App, you need to make this additional change:

- import {Button} from 'react-toolbox/lib/button';
+ import Button from 'react-toolbox/lib/button/Button';

Take into account that any required style will be included in the final CSS so your final CSS would include Button styles in this case. It's more efficient to import components this way (from 'react-toolbox/lib/button') (or with raw imports) because if you require from the project root (i.e. from 'react-toolbox'), every stylesheet of React Toolbox will be included, even if you don't use it.

Importing components

First let's take a look on how the components are structured in the project. The components folder contains a folder for each component or set of related components. For example, the app_bar:

 |- /app_bar
 |---- AppBar.js
 |---- config.css
 |---- index.js
 |---- readme.md
 |---- theme.css

As you can see in the previous block, each folder includes: a Javascript file for each component/subcomponent; a README with documentation, an index Javascript file that imports and injects styles and dependencies for you, a default theme PostCSS/preset-env stylesheet and a config.css with configuration variables (CSS Custom Properties). Depending on whether you want the styles to be directly bundled or not, you can import components in two different ways.

Bundled component

If you import from the index file, the imported component comes with all dependencies and themes already required and injected for you. This means that the CSS for each dependency will be bundled in your final CSS automatically and the component markup includes the classnames to be styled. For example:

import { AppBar } from 'react-toolbox/lib/app_bar';

Raw component

If you import from the component definition, the imported component is bundled with its dependencies, but it does not include any styles. This means no CSS will be bundled, and the component markup will not include any classname. It's your responsibility to provide a theme to the component to be properly styled. You can do so via properties or context. For example:

import { AppBar } from 'react-toolbox/lib/app_bar/AppBar.js';

Customizing components

Every component accepts a theme property intended to provide a CSS Module import object that will be used by the component to assign local classnames to its DOM nodes. Therefore, each one implements a documented classname API. So if you want to customize a component, you just need to provide a theme object with the appropriate classname mapping.

If the component already has a theme injected, the properties you pass will be merged with the injected theme. In this way, you can add classnames to the nodes of a specific component and use them to add or to override styles. For example, if you want to customize the AppBar to be purple:

import React from 'react';
import { AppBar } from 'react-toolbox/lib/app_bar';
import theme from './PurpleAppBar.css';

const PurpleAppBar = (props) => (
  <AppBar {...props} theme={theme} />
);

export default PurpleAppBar;
.appBar {
  background-color: #800080;
}

In this case we are adding styles to a specific instance of an AppBar component that already has its default styles injected. It works because the component background by default has the same priority as the one we added. There will be cases where the original rule is more restrictive. For those cases you would need to boost priority using the same restrictions as in the original stylesheet. Feel free to take a look into the default theme.css files or just check the selectors you want to override in DevTools.

If the component has no styles injected, you should provide a theme object implementing the full API. You are free to require the CSS Module you want but take into account that every classname is there for a reason. You can either provide a theme via prop or via context as described in the next section.

Customizing all instances of a component type

Install react-css-themr with npm install react-css-themr --save

Create a CSS Module theme style file for each component type, for example for Button:

# /css/button.css

.button {
  text-transform: uppercase;
}

Create a theme file that imports each component's custom theme style under the special theme key listed in that widgets's documentation, i.e.:

# theme.js

import RTButton from './css/button.css';
import RTDatePicker from './css/datepicker.css';

export default {
  RTButton, RTDatePicker,
};

Wrap your component tree with ThemeProvider at the desired level in your component hierarchy. You can maintain different themes, each importing differently styled css files (i.e. import RTButton from './css/adminAreaButton.css') and can provide each one at different points in the tree.

import React from 'react';
import { ThemeProvider } from 'react-css-themr';
import theme from './theme';

class App extends React.Component {
  render() {
    return (
      <ThemeProvider theme={theme}>
        <div>
          ...
        </div>
      </ThemeProvider>
    );
  }
}
export default App;

Theming (configuration variables)

You can apply theming in multiple ways. First of all, you have to understand that React Toolbox stylesheets are written using PostCSS with postcss-preset-env features and use CSS Custom Properties from the config files we saw earlier. In addition, there are some global CSS Properties imported by each component: colors and variables. You can override both the global and component-specific variables to get the results you want using one of the methods below.

Settings configuration variables in JavaScript

You can override both the global and component-specific CSS Custom Properties at build-time by supplying an object with these variable names and your desired values to the PostCSS custom-properties plugin. i.e. if using postcss-preset-env in webpack:

// This can also be stored in a separate file:
const reactToolboxVariables = { 
  'color-text': '#444548',
  /* Note that you can use global colors and variables */
  'color-primary': 'var(--palette-blue-500)',
  'button-height': '30px',
};

// webpack's config object: (webpack.config.js)
const config = {
...
    postcss: () => {
    return [
      /* eslint-disable global-require */
      require('postcss-preset-env')({
        stage: 0, // required to get all features that were from cssnext without enabling them one by one
        features: {
          'custom-properties': {
            preserve: false, // required to output values instead of variables
            importFrom: reactToolboxVariables, // see postcss-preset-env for config options
          },
          'color-mod-function': true, // required to use color-mod()
        }
      }),
      require('postcss-calc'), // required as postcss-preset-env doesn't have a reduce calc() funtion that cssnext did
      /* optional - see next section */
      require('postcss-modules-values'),
      /* eslint-enable global-require */
    ];
  },
}

Settings configuration variables using CSS Module Values

Instead of using a JavaScript object for variables, you can use CSS Module Values (npm install postcss-modules-values --save) and the modules-values-extract utility to declare these variables in component-specific theme .css files, where you would typically store additional style overrides.

CSS Module Values also offer the advantage that importing a css file with @value declarations makes these values properties of the imported style object, i.e.:

# variables.css

@value buttonPrimaryBackgroundColor: #9c3990;
import styleVariables from './css/variables.css';

styleVariables.buttonPrimaryBackgroundColor

In this demo project, modules-values-extract utility is used to extract all @values with dashes in their name from all css files in the /css folder and to feed them to customProperties in webpack. In the demo project, variables that are not specific to a particular component are in variables.css and button-specific variables are in button.css. Note that button.css also imports certain values from variables.css just to demonstrate this capability (the import can also be used in a @value declaration) and it uses CSS overrides instead of color variables that exist in the React-Toolbox Button component to show an alternative method if the variables are not sufficient.

IMPORTANT: Changes to the module values do not take effect immediately with Webpack Hot-Module-Reload - webpack / webpack-dev-server must be restarted!

Roboto Font and Material Design Icons

React Toolbox assumes that you are importing Roboto Font and Material Design Icons.

In order to import the fonts for you, we'd need to include them in the CSS which is considered a bad practice. If you are not including them in your app, go to the linked sites and follow the instructions.

Server Side Rendering

The only requirement for SSR is to be able to require ES6 and CSS Modules in the backend. To make it possible you can check projects like CSS Modules register hook or Webpack Isomorphic tools. Also, make sure you can import from node_modules.

Examples

For now we have a repository example demonstrating configuration and some basic customization. For now it's not using SSR rendering but it shouldn't be difficult to implement an example so it will come soon. Feel free to PR your example project or to add some use cases to the repository:

Another 2.x demo project is https://github.com/alexhisen/mobx-forms-demo

TypeScript

TypeScript external module definition files are included, and should not require any manual steps to utilize. They will be picked up by the TypeScript compiler when importing from the npm package.

Note that to comply with the official recommendation for npm typings, a triple-slash reference to react.d.ts is NOT included. You will need to reference react.d.ts somewhere in your project.

Authors and Contributors

The project is being initially developed and maintained by Javier Velasco and Javier Jiménez and the contribution scene is just getting warm. We want to create reference components so any contribution is very welcome.

To work in the project you'd need a node version supporting ES6 syntax. Although the project is built using Babel we use some ES6 features in the development server. Also, the package has been tested with node 4.2.1. Consider using nvm or n to handle different node versions!

To start the documentation site locally, you'll need to install the dependencies from both the main package and the docs subproject:

$ git clone https://github.com/react-toolbox/react-toolbox.git
$ cd react-toolbox/
$ npm install
$ cd docs/
$ npm install
$ npm start

Local documentation will then be available at http://localhost:8081/.

Extensions

We don't officially support components that are not covered by Google Material Design. If you want to implement some complementary component feel free to open a PR adding your a link in this section:

on github: react-toolbox-additions and on npm: react-toolbox-additions.

Form generation and validation using React-Toolbox form widgets - mobx-schema-form

Support

Backers

Support us with a monthly donation and help us continue our activities. [Become a backer]

Sponsors

Become a sponsor and get your logo on our README on Github with a link to your site. [Become a sponsor]

License

This project is licensed under the terms of the MIT license.

react-toolbox's People

Contributors

acornejo avatar adamhenson avatar apaatsio avatar bartekus avatar borela avatar craigcartmell avatar doff3n avatar felipeleusin avatar hsrobflavorus avatar javivelasco avatar juanperi avatar kagux avatar kerenchandran avatar kikobeats avatar laucheukhim avatar lucaas avatar mgcrea avatar nathanmarks avatar nogsmpls avatar normano64 avatar olegstepura avatar ro-savage avatar rrott avatar rubenmoya avatar simonselg avatar soyjavi avatar that1matt avatar tuckerconnelly avatar unculture avatar ustccjw avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

react-toolbox's Issues

Adding classnames package for class name manipulation

Hi!
First of all I wanted to say that this project looks very promising, great job done so far!
After taking a look to some of the code I've seen that it's handling class names like this:

className  = "#{localCSS.root} #{@props.className}"
className += " #{@props.type}"  if @props.type
className += ' focus'           if @state.focus

Is there a performance reason or something like that to do it this way instead of using something like classnames so it would look something similar to:

className = classnames
  "#{localCSS.root} #{@props.className}": true
  "#{@props.type}": @props.type
  focus: @state.focus

Thanks in advance :)

Input floating label collides with browser place holders

It looks like the floating label on input fields doesn't work right when there are placeholders automatically added by the browser (eg date, time, color, week)

Example input

import Input from 'react-toolbox/lib/input';
<Input type='time' label='Duration' icon='phone'/>
<Input type='date' label='Date' icon='phone' />

Example output
image

I encountered this issue by cloning down react-toolbox-example and adding the above javascript.

I observed this in Chrome 46 on Windows 10.

JSPM

Hi,
right now there's only support for webpack.
using your great library with jspm is very inconvenient because you need to build the library all the time instead of using it raw.
Can you please add support for jspm

Project scope

Slightly confused...
Any advantages over callemall/material-ui that looks more mature and battle-tested?

[docs] npm start hangs forever in webpack build [Windows]

Repo has some issues with wepack alias + sass loader on Windows machines at least.

See following sass-loader issues:

webpack-contrib/sass-loader#149

webpack-contrib/sass-loader#173

When running npm run build, I get file unreadable errors because of the alias not working correctly in sass-loader.

When running npm run start, the bundler never finishes. I can only get npm run start to work, if I remove alias in webpack. But then, obviously, the alias imports in sass don't work.

Just bringing awareness that There is a broken dependency currently in the project.

Error: Cannot resolve module with react-hot-boilerplate

I made simple sample with react-hot-boilerplate
I pass below code into src/index.js of react-hot-boilerplate

import Button from 'react-toolbox/Button';

const CustomButton = () => (
  <Button label="Hello world" kind="raised" accent />
);

I get this error

ERROR in ./src/index.js
Module not found: Error: Cannot resolve module 'react-toolbox/Button' in /Users/nvcken/x.Sample/learn_react_webpack/react-hot-boilerplate/src
 @ ./src/index.js 19:26-57

Help, I am new of React

How to setup minimal app using react-toolbox

Hi, I'm struggling with preparing env (webpack, ...) to make react-toolbox work with minimal app.

I've cloned React Hot Webpack Boilerplate repo.
Installed react-toolbox via npm.
Added resolve into webpack.config.js.

var path = require('path');
var webpack = require('webpack');

module.exports = {
  devtool: 'eval',
  entry: [
    'webpack-dev-server/client?http://localhost:3000',
    'webpack/hot/only-dev-server',
    './src/index'
  ],
  output: {
    path: path.join(__dirname, 'dist'),
    filename: 'bundle.js',
    publicPath: '/static/'
  },
  plugins: [
    new webpack.HotModuleReplacementPlugin()
  ],
  resolve: {
    extensions: ['', '.jsx', '.scss', '.js', '.json', '.md'],
    alias: {
      'react-toolbox': path.resolve(__dirname, './node_modules/react-toolbox/components')
    },
    modulesDirectories: [
      'node_modules',
      path.resolve(__dirname, './node_modules'),
      path.resolve(__dirname, './../node_modules'),
      path.resolve(__dirname, './../components')
    ]
  },
  module: {
    loaders: [{
      test: /(\.js|\.jsx)$/,
      loaders: ['babel'],
      include: path.join(__dirname, 'src')
    }]
  }
};

My App.js

import React, { Component } from 'react';
import Button from 'react-toolbox/button';

export default class App extends Component {
  render() {
    return (
      <h1>Hello, world.</h1>
      <Button label="Hello world" kind="raised" accent />
    );
  }
}

But webpack dev server is reporting error:

ERROR in ./~/react-toolbox/components/button/index.jsx
Module parse failed: /Users/finch/dev/react-toolbox-sample/node_modules/react-toolbox/components/button/index.jsx Line 1: Unexpected token
You may need an appropriate loader to handle this file type.
| import React from 'react';
| import FontIcon from '../font_icon';
| import Ripple from '../ripple';
 @ ./src/App.js 13:14-45
webpack: bundle is now VALID.

What I'm missing here?

How are you verifying expectations?

I noticed that your tests don't have any assertions. You only seem to be rendering the tested component at a Root component. I'm curious about the rationale for writing the tests for this way rather than using assertions.

Linux machine support - no lib folder, different package.json

I've found an interesting issue with installation that occurs only on linux OSes (so far tested on Mint 17.2, Ubuntu 14.04, two Mac OS X El Capitan laptops and a Win 8.1 machine) - [email protected] has no lib directory, and the package.json is different on linux than in other systems:

linux systems

{
  "name": "react-toolbox",
  "version": "0.11.4",
  "description": "A set of complementary tools to ReactJS.",
  "author": {
    "name": "React Toolbox Team",
    "url": "http://github.com/react-toolbox"
  },
  "contributors": [
    {
      "name": "Javi Jimenez Villar",
      "email": "[email protected]",
      "url": "http://soyjavi.com/"
    },
    {
      "name": "Javi Velasco Arjona",
      "email": "[email protected]",
      "url": "http://javivelasco.com/"
    }
  ],
  "main": "./lib",
  "scripts": {
    "start": "node ./server",
    "lint": "eslint ./ --ext .js,.jsx",
    "babel": "babel ./components --out-dir ./lib",
    "sass": "cpx './components/**/*.scss' ./lib",
    "build": "NODE_ENV=production npm run babel && npm run sass",
    "clean": "rimraf ./lib",
    "prebuild": "npm run clean",
    "prepublish": "npm run build",
    "test": "NODE_ENV=test karma start",
    "test:watch": "NODE_ENV=test karma start --no-single-run"
  },
  "bugs": {
    "url": "https://github.com/react-toolbox/react-toolbox/issues",
    "email": "[email protected]"
  },
  "keywords": [
    "react",
    "react-component",
    "material design",
    "toolkit",
    "components"
  ],
  "license": "MIT",
  "peerDependencies": {
    "react": "^0.14",
    "react-dom": "^0.14.0",
    "react-addons-css-transition-group": "^0.14.0",
    "normalize.css": "^3.0.3"
  },
  "devDependencies": {
    "autoprefixer": "^6.0.3",
    "babel": "^5.8.23",
    "babel-core": "^5.8.23",
    "babel-eslint": "^4.1.3",
    "babel-loader": "^5.3.2",
    "babel-plugin-react-transform": "^1.1.1",
    "cpx": "^1.2.1",
    "css-loader": "^0.21.0",
    "eslint": "^1.7.3",
    "eslint-plugin-react": "^3.3.1",
    "expect": "^1.8.0",
    "express": "^4.13.3",
    "extract-text-webpack-plugin": "^0.8.2",
    "karma": "^0.13.3",
    "karma-chrome-launcher": "^0.2.0",
    "karma-cli": "^0.1.0",
    "karma-mocha": "^0.2.0",
    "karma-phantomjs-launcher": "~0.2",
    "karma-webpack": "^1.7.0",
    "mocha": "^2.3.3",
    "node-sass": "^3.3.3",
    "normalize.css": "^3.0.3",
    "phantomjs": "^1.9.18",
    "phantomjs-polyfill": "0.0.1",
    "postcss-loader": "^0.7.0",
    "react": "^0.14",
    "react-addons-css-transition-group": "^0.14.0",
    "react-addons-test-utils": "^0.14.0",
    "react-dom": "^0.14.0",
    "react-transform-catch-errors": "^1.0.0",
    "react-transform-hmr": "^1.0.1",
    "redbox-react": "^1.1.1",
    "rimraf": "^2.4.3",
    "sass-loader": "^3.0.0",
    "sinon": "git://github.com/cjohansen/Sinon.JS.git#sinon-2.0",
    "style-loader": "^0.13.0",
    "toolbox-loader": "0.0.2",
    "webpack": "^1.12.0",
    "webpack-dev-middleware": "^1.2.0",
    "webpack-hot-middleware": "^2.4.1"
  },
  "repository": {
    "type": "git",
    "url": "git+https://github.com/react-toolbox/react-toolbox.git"
  },
  "readme": "# React Toolbox\n\n[![Build Status](https://travis-ci.org/react-toolbox/react-toolbox.svg?branch=master)](https://travis-ci.org/react-toolbox/react-toolbox) \n[![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)\n[![Donate](https://img.shields.io/badge/donate-paypal-blue.svg?style=flat-square)](https://paypal.me/javivelasco)\n\n*Current version: [0.11.3](https://github.com/react-toolbox/react-toolbox/releases/tag/0.11.3)*\n\nReact 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!\n\n## Installation\n\nReact Toolbox can be installed as an [npm package](https://www.npmjs.org/package/react-toolbox);\n\n```\nnpm install --save react-toolbox\n```\n\n## Usage\n\nAlthough 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).\n\nOnce you have the workflow ready, you can just require and use the components:\n\n```jsx\nimport React from 'react';\nimport Button from 'react-toolbox/button';\n\nconst CustomButton = () => (\n  <Button label=\"Hello world\" kind=\"raised\" accent />\n);\n\nexport default CustomButton;\n```\n\nThe 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. \n\nWe 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.\n\n## Customization\n\nSince React Toolbox styles are written in CSS it's pretty easy to customize your components. We have several ways:\n\n### Via React Toolbox Loader\n\nThanks 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.\n\nWith [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. \n\n### Via `className` property\n\nGenerally 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:\n\n```jsx\nconst CustomButton = () => (\n  <Button className='customized' label='Custom button' />\n);\n```\n\nIf 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:\n\n```css\n.customized > [data-role=\"label\"] {\n  color: green;\n  font-weight: bold;\n}\n```\n\n## Authors and Contributors\n\nThe 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.\n\n## License \nThis project is licensed under the terms of the [MIT license](https://github.com/react-toolbox/react-toolbox/blob/master/LICENSE).\n",
  "readmeFilename": "README.md",
  "homepage": "https://github.com/react-toolbox/react-toolbox#readme",
  "_id": "[email protected]",
  "_from": "[email protected]"
}

vs windows and mac

{
  "name": "react-toolbox",
  "version": "0.11.4",
  "description": "A set of complementary tools to ReactJS.",
  "author": {
    "name": "React Toolbox Team",
    "url": "http://github.com/react-toolbox"
  },
  "contributors": [
    {
      "name": "Javi Jimenez Villar",
      "email": "[email protected]",
      "url": "http://soyjavi.com/"
    },
    {
      "name": "Javi Velasco Arjona",
      "email": "[email protected]",
      "url": "http://javivelasco.com/"
    }
  ],
  "main": "./lib",
  "scripts": {
    "start": "node ./server",
    "lint": "eslint ./ --ext .js,.jsx",
    "babel": "babel ./components --out-dir ./lib",
    "sass": "cpx './components/**/*.scss' ./lib",
    "build": "NODE_ENV=production npm run babel && npm run sass",
    "clean": "rimraf ./lib",
    "prebuild": "npm run clean",
    "prepublish": "npm run build",
    "test": "NODE_ENV=test karma start",
    "test:watch": "NODE_ENV=test karma start --no-single-run"
  },
  "bugs": {
    "url": "https://github.com/react-toolbox/react-toolbox/issues",
    "email": "[email protected]"
  },
  "keywords": [
    "react",
    "react-component",
    "material design",
    "toolkit",
    "components"
  ],
  "license": "MIT",
  "peerDependencies": {
    "react": "^0.14",
    "react-dom": "^0.14.0",
    "react-addons-css-transition-group": "^0.14.0",
    "normalize.css": "^3.0.3"
  },
  "devDependencies": {
    "autoprefixer": "^6.0.3",
    "babel": "^5.8.23",
    "babel-core": "^5.8.23",
    "babel-eslint": "^4.1.3",
    "babel-loader": "^5.3.2",
    "babel-plugin-react-transform": "^1.1.1",
    "cpx": "^1.2.1",
    "css-loader": "^0.21.0",
    "eslint": "^1.7.3",
    "eslint-plugin-react": "^3.3.1",
    "expect": "^1.8.0",
    "express": "^4.13.3",
    "extract-text-webpack-plugin": "^0.8.2",
    "karma": "^0.13.3",
    "karma-chrome-launcher": "^0.2.0",
    "karma-cli": "^0.1.0",
    "karma-mocha": "^0.2.0",
    "karma-phantomjs-launcher": "~0.2",
    "karma-webpack": "^1.7.0",
    "mocha": "^2.3.3",
    "node-sass": "^3.3.3",
    "normalize.css": "^3.0.3",
    "phantomjs": "^1.9.18",
    "phantomjs-polyfill": "0.0.1",
    "postcss-loader": "^0.7.0",
    "react": "^0.14",
    "react-addons-css-transition-group": "^0.14.0",
    "react-addons-test-utils": "^0.14.0",
    "react-dom": "^0.14.0",
    "react-transform-catch-errors": "^1.0.0",
    "react-transform-hmr": "^1.0.1",
    "redbox-react": "^1.1.1",
    "rimraf": "^2.4.3",
    "sass-loader": "^3.0.0",
    "sinon": "git://github.com/cjohansen/Sinon.JS.git#sinon-2.0",
    "style-loader": "^0.13.0",
    "toolbox-loader": "0.0.2",
    "webpack": "^1.12.0",
    "webpack-dev-middleware": "^1.2.0",
    "webpack-hot-middleware": "^2.4.1"
  },
  "repository": {
    "type": "git",
    "url": "git+https://github.com/react-toolbox/react-toolbox.git"
  },
  "gitHead": "a412d2237dbc8d386d080d65e333e7656822ece8",
  "homepage": "https://github.com/react-toolbox/react-toolbox#readme",
  "_id": "[email protected]",
  "_shasum": "481380968df7c3c183766cbf2a2b6c20b793387f",
  "_from": "react-toolbox@>=0.11.3 <0.12.0",
  "_npmVersion": "2.14.7",
  "_nodeVersion": "4.2.1",
  "_npmUser": {
    "name": "javivelasco",
    "email": "[email protected]"
  },
  "maintainers": [
    {
      "name": "javivelasco",
      "email": "[email protected]"
    },
    {
      "name": "soyjavi",
      "email": "[email protected]"
    }
  ],
  "dist": {
    "shasum": "481380968df7c3c183766cbf2a2b6c20b793387f",
    "tarball": "http://registry.npmjs.org/react-toolbox/-/react-toolbox-0.11.4.tgz"
  },
  "directories": {},
  "_resolved": "https://registry.npmjs.org/react-toolbox/-/react-toolbox-0.11.4.tgz",
  "readme": "ERROR: No README data found!"
}

Also, no lib/ folder exists in node_modules/react-toolbox in linux, but on other systems it is present - it makes the library unusable in linux. Everything is working fine in [email protected]. I know there is a high chance that this might be an internal npm bug, but so far this behaviour only happened with your library, but even if so, you may be able to work out some fix on that in future versions if you are aware that the issue exists :) Anyway, thx for this library and keep up the good work :)

AppBar?

Hi. I noticed the AppBar exists inside the repo, but the demo says it's still coming. What's the catch? :D

TypeScript implementation / definitions

I think new typescript react support is cool. Much easier to to build type safe components and maintain the project for long term as well as great IDE support and intelligence. This will also helps generating typescript definitions automatically.

Considering the way this project has developed (ES2015), you can add typescript support by only renaming .jsx files to .tsx and a little web pack setting modifications.

Any plan or thoughts on this?

don't use refs for firing actions

I'm seeing a few components (snackbar, dialog and drawer) that are using refs.show or refs.hide to do toggle visualization.

What do you think about changing that to use props instead? Using refs means that anyone using any flux implementation will have to change the mindset around the component state :(

Create sample project with webpack

I find this project is a PITA to set up properly with webpack. Tried to load the datepicker but css is not being loaded properly. A sample project outside this repo would be great.

Arrow functions in server.js

When running npm run start the process errors out because of arrow functions in server.js:

npm-run-start-arrow-functions

Maybe it's not getting polyfilled correctly? Either way, changing to use the function keyword fixes this. Will have a PR soon.

Installation instructions and dependency instalation

Hi, you wrote a great library, but I had some issues installing it:

I installed react-toolbox via npm and had some trouble running some sample code like buttons or appbar (we are using webpack and sass in our project). I had to install react-transform-hmr, react-transform-catch-errors, redbox-react, extract-text-webpack-plugin, and I also needed to copy your sass configuration from your projects webpack config (the one with ExtractTextPlugin). After those steps, the library started to work properly but the steps to do that felt a bit awkward and unnecessary.

Maybe I missed something in the installation process (I read all about getting the right webpack config), or is it the right way to install the library? If it is, it would be awesome to have some more info about it in the README :)

Anyway, thx for some awesome piece of code! :)

Allow passing components to leftIcon and rightIcon on ListItem

This may well be a recurring theme throughout the lib -- but I have a few use cases whereby I want to pass in more than just a string to an attribute. For example, I have a <ListItem> where on the right hand side, I want a custom <img> tag rather than an icon. I often want something completely custom their as well.

In https://github.com/callemall/material-ui it is possible to simply pass this straight into the prop. I don't particularly like this, but it does solve the use case.

Another option I can think of would be to allow children on this component which would completely override the "utility" attributes caption, legend, leftIcon and rightIcon and just allow you to put anything in the box.

Thinking about it, I think support for both methods might be appropriate? That would allow these components to be as flexible as you want them to be.

Help with NPM - Ayuda con npm

You could place a manual on how to install the dependencies and so to implement the project 100% and I would like to contribute more but work in Linux and gives me some errors when installing the package, thank you very much.

Podría colocar un manual de como poder instalar las dependencias y asi poder ejecutar el proyecto al 100% ya que me gustaría aportar mas pero trabajo en Linux y me da algunos errores al instalar los paquetes, muchas gracias.

NODE_ENV prefix throws error in Windows

> [email protected] build E:\GitHub\react-toolbox
> NODE_ENV=production npm run babel && npm run sass

'NODE_ENV' is not recognized as an internal or external command,
operable program or batch file.

npm ERR! Windows_NT 10.0.10240
npm ERR! argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "run" "build"
npm ERR! node v4.2.2
npm ERR! npm  v3.3.12
npm ERR! code ELIFECYCLE
npm ERR! [email protected] build: `NODE_ENV=production npm run babel && npm run sass`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] build script 'NODE_ENV=production npm run babel && npm run sass'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the react-toolbox package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     NODE_ENV=production npm run babel && npm run sass
npm ERR! You can get their info via:
npm ERR!     npm owner ls react-toolbox
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR!     E:\GitHub\react-toolbox\npm-debug.log

Seems prefixing the environment variable when invoking an NPM script doesn't work in Windows when checking out the project source and running npm install (Note: Getting from NPM as a dependency still works fine)

Server-side rendering

Have anybody tried to use react-toolbox for server-side rendering?
Is it even possible the way it is implemented now because of the close integration with react-transform-hmr?

.babelrc incompatible with Babel 6

the current .babelrc uses the "stage: 2" option which is no longer supported in the latest Babel, which causes it to throw an error if you are using Babel >= 6.0.0.

FontItems with spaces in names do not appear

I am using the font item corner of the playground. When I replace the sample values with, for example, backspace or block, the preview area below reflects them correctly, but when I use multi-word material icons (e.g. add circle outline or font download etc.) either as is with spaces or with underscores instead (add_circle_outline or font_download), they are missing from the preview area. I've also tried Unicode (&#20;), url (%20), slash space (\) and other crazy ideas :-)

Reference to app theme in docs

Hi there!

The Button doc page states:

"A button clearly communicates what action will occur when the user touches it. It consists of text, an image, or both, designed in accordance with your app’s color theme".

It's also evident in the example that the accent buttons get the accent color in what seems to be a "standard" indigo-pink Material Design theme.

Is there any way to define themes? If there's not, how do we set the primary and accented colors? Via style sheets? Or is there a different mechanism to it?

Out of date documentation? Install error and Button import error with react-hot-boilerplate.

http://react-toolbox.com/#/install and the README seem to recommend using react-hot-boilerplate and seem to say I can use Button out of the box.

But I run into two problems:

  • npm install --save react-toolbox complains about missing react-addons-css-transition-group and normalize.css.
  • The react-toolbox/button module can't be found. Installing react-addons-css-transition-group and normalize.css doesn't fix this error.

Full transcript:

$ git clone https://github.com/gaearon/react-hot-boilerplate.git
...
$ cd react-hot-boilerplate/
$ npm install
...
$ npm install --save react-toolbox
...
npm WARN EPEERINVALID [email protected] requires a peer of react-addons-css-transition-group@^0.14.0 but none was installed.
npm WARN EPEERINVALID [email protected] requires a peer of normalize.css@^3.0.3 but none was installed.
...
$ npm start

At this point, accessing http://localhost:3000/ shows "Hello, world."

So I add this line to App.js:

import Button from 'react-toolbox/button';

Hot recompilation fails:

Module not found: Error: Cannot resolve module 'react-toolbox/button' in /Users/tom/src/react-hot-boilerplate/src

Prepare components as reusable lib for npm

Hi, first of all, thanks for a great set of components!

There is one issue with lib, I agree to include in my webpack config sass loaders, but I don't agree to include unnecessary deps in my project (react-transform-catch-errors, etc.).
It would be nice if you prepare components as a really reusable lib.

Table component: Multi select is broken

The table component multi select checkbox is kind of broken. It works when no rows are selected, but will not work for the selected rows.

See the screencast

Ref to ListCheckbox is null

<ListCheckbox 
    ...
    ref={(checkbox) => console.log(checkbox)}
/>

Output:

null

React docs:

The ref attribute can be a callback function, and this callback will be executed immediately after the component is mounted. The referenced component will be passed in as a parameter, and the callback function may use the component immediately

Tried non ES approach too in case it was Babel's fault or something

ref={function(checkbox){console.log(checkbox);}}

still null...

Is there any other way I can keep track of the checkbox statuses in my list? The SyntheticEvent I get when using onChange doesn't seem to give me a simple way to get the checked status either.

With mui I was able to do isChecked() on the ref, and SyntheticEvent.target.isChecked() also if I recall correctly.

import error

hi @javivelasco

i npm install the latest version and can not import it right

import Btn from 'react-toolbox/button'
Module not found: Error: Cannot resolve module 'react-toolbox/button'
.....

Or :

import Btn from 'react-toolbox/lib/button'
Module not found: Error: Cannot resolve 'file' or 'directory' ./style 
....

Can't run npm test

on Windows 7, npm test gives NODE_ENV issue. This can be resolved by changing the scripts section of package.json to:

"test": "karma start"

However, even after that is done, I am getting react-transform-hmr errors:

react-transform-hmr-error

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.