Giter Site home page Giter Site logo

ecomfe / san-xui Goto Github PK

View Code? Open in Web Editor NEW
80.0 19.0 9.0 2.37 MB

A Set of SAN UI Components that widely used on Baidu Cloud Console

Home Page: https://ecomfe.github.io/san-xui/

License: MIT License

JavaScript 77.35% CSS 22.38% HTML 0.24% Shell 0.03%
san ui-components baidu cloud console

san-xui's Introduction

san-xui

Codecov Dependency Status npm package NPM downloads Percentage of issues still open

san-xui 是基于 san 开发的一套UI组件库,在百度云的控制台中得到了广泛的应用。

下载

NPM:

npm i --save san-xui

使用

AMD

这里使用的是 esl 作为 AMD Loader,使用之前需要配置一下 paths 和 packages,如下:

<script src="https://cdn.bdstatic.com/ecom/esl/2.2.0-rc.2/esl.js"></script>
<script>
require.config({
  paths: {
    san: "https://cdn.bdstatic.com/san/3.5.1-rc.1/san",
    jquery: "https://unpkg.com/[email protected]/dist/jquery",
    humanize: "https://unpkg.com/[email protected]/humanize",
    lodash: "https://unpkg.com/[email protected]/lodash",
    moment: "https://unpkg.com/[email protected]/moment",
    axios: "https://unpkg.com/[email protected]/dist/axios",
    clipboard: "https://unpkg.com/[email protected]/dist/clipboard",
    "async-validator": "https://cdn.bdstatic.com/console/async-validator/0.0.0/async-validator.bundle",
    "big.js": "https://unpkg.com/[email protected]/big"
  },
  packages: [
    {
      name: "san-xui",
      location: "https://unpkg.com/[email protected]/lib",
      main: "index"
    }
  ]
});
</script>

引入所需要的样式代码:

<link rel="stylesheet" type="text/css" href="https://cdn.bdstatic.com/iconfont/iconfont.css" />
<link rel="stylesheet" type="text/css" href="https://unpkg.com/[email protected]/dist/xui.css" />

最后是应用的代码:

define(function(require) {
  const san = require("san");
  const { Button, alert } = require("san-xui");

  const App = san.defineComponent({
    template: `<template><ui-button on-click="onBtnClick">Hello san-xui</ui-button></template>`,
    components: {
      "ui-button": Button
    },
    onBtnClick() {
      alert("Button clicked");
    }
  });

  function start() {
    const app = new App();
    app.attach(document.getElementById("root"));
  }

  return { start };
});

最终的效果如下:https://codepen.io/leeight/pen/QmMabe

Webpack

通过 named import 导入所需要使用的组件

import 'san-xui/dist/xui.css';
import {defineComponent} from 'san';
import {Button} from 'san-xui';

// 引入单个的组件
import Button from 'san-xui/lib/x/components/Button';

const App = defineComponent({
    template: `<template><ui-button>Hello san-xui</ui-button></template>`,
    components: {
        'ui-button': Button
    }
});
const app = new App();
app.attach(document.body);

webpack.config.js

需要安装必要的一些插件

npm i --save-dev babel-loader css-loader style-loader less-loader less file-loader babel-preset-stage-0 babel-preset-env

然后补充上一些相关的配置

const path = require('path');

function alias(name) {
    return path.dirname(require.resolve(name));
}

module.exports = {
    ...
    resolve: {
        mainFiles: ['index', 'main']
    },
    module: {
        rules: [
            {
                test: /\.(png|gif|jpe?g|svg)$/,
                use: [
                    {
                        loader: 'file-loader',
                        options: {
                            name(file) {
                                return 'assets/images/[hash].[ext]';
                            }
                        }
                    }
                ]
            },
            {
                test: /\.css$/,
                use: ['style-loader', 'css-loader']
            },
            {
                test: /\.less$/,
                use: [
                    {loader: 'style-loader'},
                    {loader: 'css-loader'},
                    {
                        loader: 'less-loader',
                        options: {
                            relativeUrls: true,
                            paths: []
                        }
                    }
                ]
            },
            {
                test: /\.js$/,
                exclude: /(node_modules|dist)/,
                use: {
                    loader: 'babel-loader',
                    options: {
                        presets: ['env', 'stage-0']
                    }
                }
            }
        ]
    },
    ...
}

san-xui's People

Contributors

chendatony31 avatar dafrok avatar hustchenbo avatar leeight avatar liuxiaobleach avatar penglei03 avatar peterpanzh avatar tonyjeffrey avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

san-xui's Issues

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.