zefirka / teatime-components

React components + CSS Modules

Home Page:http://sullenor.github.io/teatime-components/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

teatime-components

React Components + CSS Modules ❤️

Philosophy

  • What can be done with styles, should be done with styles.
  • No global dependencies neither in JS nor in CSS.

Features

  • Universal components. Unlikely BEM there is a possibility to provide same styles to the different components.
  • Possibility to mix particular styles without CSS Modules using className property (see React CSS Modules for the details).
  • Predictability.

Requirements

Webpack Configuration Example

// webpack.config.js
const { resolve } = require('path');
const ExtractTextPlugin = require('extract-text-webpack-plugin');
const NpmInstallPlugin = require('npm-install-webpack-plugin');

module.exports = {
  entry: '...',
  output: {
    filename: '[name].js',
    path: resolve('dist'),
  },

  module: {
    loaders: [
      {
        test: /\.css$/i,
        loader: ExtractTextPlugin.extract('style',
          'css?modules&localIdentName=[name]--[local]&importLoaders=1!postcss'),
      },
    ],
  },

  plugins: [
    new ExtractTextPlugin('styles.css'),
    new NpmInstallPlugin({
      cacheMin: 999999,
      save: true,
      saveDev: true,
    }),
  ],

  postcss: [
    require('postcss-url')({url: 'inline'}),
    require('autoprefixer')({browsers: ['last 2 versions']}),
  ],
};

In order to remove various test helpers, which you don't need in your production environment, you should add the Webpack DefinePlugin. It will also decrease the bundle size and provide some performance. Configuration example:

plugins: [
  // ...
  new webpack.DefinePlugin({
    'process.env': {
      'NODE_ENV': JSON.stringify('production')
    }
  })
],

Development

Start Webpack dev server:

$ npm start

Build preview:

$ npm run demo

Run tests:

$ npm test

Reference Guides

License

The MIT License

About

React components + CSS Modules

http://sullenor.github.io/teatime-components/

License:MIT License


Languages

Language:JavaScript 64.6%Language:CSS 35.1%Language:HTML 0.3%