Git Product home page Git Product logo

cat-ui's Introduction

cat-ui

喜马拉雅国际版前端基础组件库

Build Status codecov HitCount

NPM

浏览器支持

IE / Edge
IE / Edge
Firefox
Firefox
Chrome
Chrome
Safari
Safari
iOS Safari
iOS Safari
Electron
Electron
IE11, Edge last 2 versions last 2 versions last 2 versions last 2 versions last 2 versions

更新日志

更新日志

安装

npm install @hife/catui

or

yarn add hife-catui

使用

1 在入口中导入 css 文件

// index.js
import '@hife/catui/styles/index.css';

2 使用组件

import { Button } from '@hife/catui';

const App = () => {
  return <Button>Add</Button>;
};

export default App;

3 组件按需加载

  • yarn add babel-plugin-import -D 下载 babel-plugin-import 插件
  • 配置 babel-plugin-import 插件:

webpack.config.js

/**
 * css name covert
 * 1 Button => button
 * 2 ElementSelect => element-select
 * @param {string} name 组件名称
 */
const cssNameConvert = function(name) {
  const len = name.length;
  let ret = '';
  for (let i = 0; i < len; i++) {
    const charCode = name.charCodeAt(i);
    if (charCode >= 65 && charCode <= 90) {
      ret +=
        i === 0
          ? String.fromCharCode(charCode + 32)
          : `-${String.fromCharCode(charCode + 32)}`;
    } else {
      ret += name[i];
    }
  }
  return ret;
};

module.exprots = {
  module: {
    rules: [
      {
        {
          test: /\.(js|mjs|jsx|ts|tsx)$/,
          loader: require.resolve('babel-loader'),
          options: {
            plugins: [
              [
                'import',
                {
                  libraryName: '@hife/catui',
                  libraryDirectory: 'lib/components',
                  "camel2DashComponentName": false,
                  customStyleName: name => {
                    const newName = cssNameConvert(name);
                    return `@hife/catui/styles/${newName}.css`;
                  }
                }
              ]
            ]
          }
        }
      }
    ]
  }
}

开发流程

开发流程

cat-ui's People

Contributors

builderryan avatar dependabot[bot] avatar hileix avatar huangxiangsai avatar sialvsic avatar

Watchers

 avatar

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.