Skip to content

one-react/sample

Repository files navigation

One React Component: sample

logo

TravisCI Build CircieCI Build Coverage Version Chat License: MIT JavaScript Style Guide Greenkeeper badge

Installation

// with npm
npm install or-sample

// with yarn
yarn add or-sample

Usage

  • Config webpack sass-loader if you are using webpack.
// webpack.config.js
{
  test: /\.scss$/,
  use: [
    'style-loader',
    'css-loader',
    'sass-loader'
  ],
  include: [
    /node_modules\/or\-\w+/ //include or-components
  ]
}

Basic Example

API

interface Props {
  
}

Customize Theme

Customize in webpack

The following variables in or-sample can be overridden:

$or-btn-primary-color: $or-primary-color !default;
...

For more variables, see here.

Alternatively, you can override variables from or-theme to keep all or-components in a unified theme style.

First you should create a theme.scss file to declare the variables you want to override.

Then use the data option provided by sass-loader to override the default values of the variables.

We take a typical webpack.config.js file as example to customize it's sass-loader options.

// webpack.config.js
{
  test: /\.scss$/,
  use: [
    'style-loader',
    'css-loader',
    {
      loader: 'sass-loader',
      options: {
        data: fs.readFileSync(path.resolve(__dirname, 'theme.scss')) // pass theme.scss to sass-loader
      }
    }
  ],
  include: [
    /node_modules\/or\-\w+/ //include or-components
  ]
}

Demos and Docs

powered by storybook

Click Here

License

MIT © foryuki