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

@datlas/design

v1.66.7

Published

MDT Design | React组件库

Downloads

42

Readme

pipeline status coverage report

MDT DESIGN

Install

npm install @datlas/design
yarn add @datlas/design

Usage

import { loadTheme } from '@datlas/design/esm/components/style/themes';
import { ThemeEnum } from '@datlas/design/esm/components/style/context';
import Button from '@datlas/design/esm/components/button';

loadTheme(ThemeEnum.dark);

export default () => {
  <Button type="primary">button</Button>
}

可以添加 webpack alias 使引用路径变短

addWebpackAlias({ ["@@"]: path.resolve('./node_modules/@datlas/design/esm') })

tsconfig:

{
  "compilerOptions": {
  "baseUrl": ".",
  "paths": {
    "@/*": ["src/*"],
    "@@/*": ["./node_modules/@datlas/design/esm/*"]
  }
}

使用时

import Button from '@@/components/button';

可能遇到的问题

  1. d.ts 报错,请添加 ignore-loader

    config.module.rules.push({
      test: /\.d\.ts$/,
      loader: 'ignore-loader'
    });
    
  2. react 多实例问题 https://github.com/facebook/react/issues/13991

    
    addWebpackAlias({ react: path.resolve('./node_modules/react')})
    
  3. dayjs使用报错: Uncaught TypeError: xxxx is not a function

    由于组件库项目中使用到 dayjs 做一些轻量级的时间计算,所以外层在将引入 dayjs 时会有版本不同而造成方法缺失的问题,组件库提供的解决方案如下:

    1. 请将本地的 dayjs 保持和组件库版本一致

    2. 不方便改版本的话,可以使用dayjs提供的插件支持,将缺失的自行extend到本地项目中,使用方法详见

    例如:

      import isoWeek from 'dayjs/plugin/isoWeek';
    
      dayjs.extend(isoWeek);

本地开发

  1. storybook开发,编写story

    yarn start
  2. link到项目开发,在组件项目执行

    yarn dev
    yarn link

    在项目中执行 yarn link "@datlas/design"

  3. 快速生成组件

    yarn gc 组件名

框架推荐工具及插件

基于 Storybook V6.2

样式规范

定义color,zindex变量, 后续放开stylelint检查

"sh-waqar/declaration-use-variable": [
  [
    "/color/",
    "z-index"
  ]
]

开发规范

  • 引用路径使用 import from '.' 替换为 import from './index', babel plugin bug
  • 测试文件放在 __tests__ 目录
  • storybook示例放在 __stories__ 目录
  • 组件 tsx 文件使用首字母大写
  • 文件夹小写,中划线间隔
  • 在某些情况下,您可能希望导出故事和非故事的混合体。例如,导出故事中使用的数据可能会很有用。为此,您可以在默认导出中使用可选字段includeStories和excludeStories配置字段,可以将其设置为字符串数组或正则表达式。按大写字母开头导出故事书, 小写字母开头导出数据。
    // MyComponent.stories.js
    
    import React from 'react';
    
    import MyComponent from './MyComponent';
    
    import someData from './data.json';
    
    export default {
      title: 'MyComponent',
      component: MyComponent,
      includeStories: /.*Story$/, // 👈 Storybook loads these stories
      excludeStories: /.*Data$/, // 👈 Storybook ignores anything that contains Data
    };
    
    export const simpleData = { foo: 1, bar: 'baz' };
    export const complexData = { foo: 1, foobar: { bar: 'baz', baz: someData } };
    
    export const SimpleStory = () => <MyComponent data={simpleData} />;
    export const ComplexStory = () => <MyComponent data={complexData} />;
    

Features

  • [x] storybook
  • [x] eslint
  • [x] jest
  • [x] commit lint
  • [x] build svg to React Component
  • [x] build less to css
  • [x] build ts to es6
  • [x] build ts to commonjs
  • [x] minify css
  • [x] watch build
  • [x] auto publish
  • [x] ci build
  • [ ] umd/iife