Skip to content

ojame/teatime-components

 
 

Repository files navigation

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

Packages

No packages published

Languages

  • JavaScript 64.7%
  • CSS 35.0%
  • HTML 0.3%