Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@cosmic-design/san

Package Overview
Dependencies
Maintainers
7
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@cosmic-design/san

一个基于 San 开发的 UI 组件库

  • 0.0.1-alpha.20
  • alpha
  • latest
  • npm
  • Socket score

Version published
Weekly downloads
481
decreased by-30.09%
Maintainers
7
Weekly downloads
 
Created
Source

Cosmic Design Components

一个基于 San 开发的 UI 组件库

Feature

  • 完全开放的组件样式定制能力
  • 支持多端:移动端、PC端
  • 全面拥抱 TypeScript

使用组件

目前组件库提供了多种模块化规范,及全部打包和按需引入分包的编译产物,你可以结合适合的业务场景选择。

编译配置

全局提供 san 的依赖即可,编译选择 vite / rollup 等工具即可,无特别配置,可参考。

example/vite.config.js

引入组件

组件库导出项目
/** package.json */
{
  "exports": {
    "./css/*": "./dist/css/*",
    /** for @cosmic-design/san/css/Button.css  */
    /** for @cosmic-design/san/css/style.css  */
    /** for @cosmic-design/san/css/global.css  */

    "./*": {
      "import": "./dist/esm/*/index.js",
      "require": "./dist/cjs/*/index.js"
    },
    /** for @cosmic-design/san/Button  */

    ".": {
      "import": "./dist/esm/index.js",
      "require": "./dist/cjs/index.js"
    }
    /** for @cosmic-design/san  */
  },
}
/dist
├── css
│   ├── style.css           # 所有样式,适用于全部引入,包括组件和global
|   ├── global.css          # 全局样式,适用于按需引入
|   ├── Button.css          # 组件样式,适用于按需引入
├── esm
│   ├── index.js            # 组件esm bundle,适用于 esm/ts + 全部引入
│   ├── index.d.ts          # 所有组件类型
│   ├── Button
│   │   ├── index.js        # 组件esm, 适用于 esm/ts + 按需引入
│   │   ├── index.d.ts      # 所有组件类型
├── cjs
│   ├── index.js            # 组件commonJS bundle,适用于打包引入
│   ├── index.d.ts          # 所有组件类型
│   ├── Button
│   │   ├── index.js        # 组件commonJS, 适用于按需引入
│   │   ├── index.d.ts      # 组件类型
├── umd
│   ├── index.js            # 组件umd bundle,适用于 umd/amd + 打包引入
│   ├── Button.js           # 分组件umd,适用于 umd/amd + 按需引入

模块化及打包

Demo
ESM
  • 全部引入
import '@cosmic-design/san/css/style.css';
import { Button } from '@cosmic-design/san';
  • 按需引入
import '@cosmic-design/san/css/global.css'; // in global js

import '@cosmic-design/san/css/Button.css';
import Button from '@cosmic-design/san/Button';
CMD
  • 全部引入 略

  • 按需引入

/** CommonJS SSR **/
const Button = require('@cosmic-design/san/Button');
UMD/AMD
  • AMD 配置
require.config({
    packages: [
        {
            name: '@cosmic-design/san',
            location: '/@cosmic-design/san/dist/es5',
            main: 'index.js'
        },
    ]
});
  • 全部引入
<link rel="stylesheet" type="text/css" href="/@cosmic-design/san/dist/css/style.css"/>
require(['@cosmic-design/san', 'san'], function({ Button }, { Component }) {

});
  • 按需引入
<link rel="stylesheet" type="text/css" href="/@cosmic-design/san/dist/css/global.css"/>
<link rel="stylesheet" type="text/css" href="/@cosmic-design/san/dist/css/Button.css"/>
require(['@cosmic-design/san/Button', 'san'], function(Button, { Component }) {

});

组件开发

目录结构

  • 组件代码目录:./packages/components
  • 开发参考Grid/Button组件

组件预览

组件单元测试

使用 san-test-utils 进行单元测试

提交代码

请使用npm run commit,不要使用git commit

FAQs

Package last updated on 05 Sep 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc