npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

react-rainie-toolbox

v1.0.7

Published

[![Travis][build-badge]][build] [![npm package][npm-badge]][npm] [![Coveralls][coveralls-badge]][coveralls]

Downloads

25

Readme

react-rainie-toolbox

Travis npm package Coveralls

react-rainie-toolbox 是针对于cqaso产品场景开发的一系列的pc端react组件集。 包括的场景有:后台管理系统,CQASO,TOPASM操作复杂的PC网站。

特性

  • 它由CSS Modules提供动力,并与您的Webpack工作流程和谐融合。
  • 它的样式由Postcss预处理。

安装

npm install react-rainie-toolbox --save

开发环境

  • 需要 CSS Modules的样式开发环境
  • 需要postcss的相关插件配置

例如:

{
    test: /\.css$/,
    include: [
      /node_modules/
    ],
    loaders: ['style', 'css?modules&localIdentName=[name]__[local]___[hash:base64:5]', 'postcss'],
  }
      postcss: function (webpack) {
        return [
          require('postcss-smart-import')({
            addDependencyTo: webpack
          }),
          require('postcss-mixins')({mixins}),
          require('postcss-cssnext')({
            browsers: [
              '>1%',
              'last 4 versions',
              'Firefox ESR',
              'not ie < 9',
            ]
          }),
          require('postcss-nested')(),
        ];
      },

webpack配置请参考这里

用法

下面是简单的例子,以按钮为例:

import React from 'react';
import Button from 'react-rainie-toolbox/lib/button';

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

自定义组件

每个组件接受一个主题theme属性,旨在提供一个CSS模块导入对象,组件将使用该对象将本地类名分配给其DOM节点。所以如果你想自定义组件,你只需要提供一个主题theme对象与适当的类名映射,从而修改默认样式。

如果组件已经注入了一个主题,那么您传递的属性将与注入的属性合并。

这样,您可以向特定组件的节点添加类名,并使用它们来添加或覆盖样式。例如,如果要自定义Input背景为红色:

/* customInput.css */
.input {
  background: red;
}
import React from 'react';

import Input from 'react-rainie-toolbox/lib/input';
import theme from './customInput.css';


const CustomInput = (props) => (
  <Input {...props} theme={theme} />
);

export default CustomInput;

优点:通过类覆盖的方式修改样式更加灵活自如。

为什么选用CSS Modules?

CSS Modules 对CSS中的class名都做了处理,使用对象来保存原class和混淆后的class的对应关系。

  • 所有的样式都是局部化的,解决了命名冲突和全局污染的问题。
  • class名的生成规则配置灵活,可以以此来压缩class名。
  • 只引用组件的JavaScript,就可以搞定组件的javascript和CSS。

参考项目