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

@td-design/svgicon-cli

v1.7.2

Published

本工具是基于[react-native-iconfont-cli](https://github.com/iconfont-cli/react-native-iconfont-cli)的基础上修改而来。因为 UI 设计师使用`Figma`产出设计稿,所以项目中用到的图标不会使用 iconfont 或者图片,而是直接导出 svg 格式。借助这个工具,就可以很方便地把本地 svg 转成图标组件在项目中使用。为此,精简了原项目中很多不需要的功能(比如拉取 iconfont 图标库、支持导出 js 文件等),以满

Downloads

14

Readme

@td-design/svgicon-cli

本工具是基于react-native-iconfont-cli的基础上修改而来。因为 UI 设计师使用Figma产出设计稿,所以项目中用到的图标不会使用 iconfont 或者图片,而是直接导出 svg 格式。借助这个工具,就可以很方便地把本地 svg 转成图标组件在项目中使用。为此,精简了原项目中很多不需要的功能(比如拉取 iconfont 图标库、支持导出 js 文件等),以满足我们自己的需求。

特性

1、纯组件,不依赖字体,体积小 2、支持渲染多色彩图标,支持自定义颜色 3、支持热更新 4、自动化生成图标组件,默认支持 typescript

Step 1

安装插件

# Yarn
yarn add react-native-svg
yarn add @td-design/svgicon-cli --dev

# Npm
npm install react-native-svg
npm install @td-design/svgicon-cli --save-dev

Step 2

生成配置文件

npx svgicon-init

此时项目根目录会生成一个svgicon.json的文件,内容如下:

{
  "save_dir": "", // 生成图标文件的保存位置,推荐 ./src/components/iconfont
  "trim_icon_prefix": "icon", // 图标文件的统一前缀
  "default_icon_size": 20, // 图标文件的默认大小
  "icon_svg": "./icon-svg", // 图标文件的存放位置
  "for_library": false // 是否为组件库生成图标,默认是false,表示是为项目生成图标
}

Step 3

开始生成 React-Native 标准组件

npx svgicon-create

使用

import { SvgIcon } from 'components';

export const App = () => {
  return (
    <View>
      <SvgIcon name="alipay" size={20} />
      <SvgIcon name="wechat" />
    </View>
  );
};

图标尺寸

根据配置default_icon_size,每个图标都会有一个默认的尺寸,你可以随时覆盖。

<SvgIcon name="alipay" size={20} />

图标单色

单色图标,如果不指定颜色值,图标将渲染原本的颜色。如果你想设置为其他的颜色,那么设置一个你想要的颜色即可。

注意:如果你在 props 传入的 color 是字符串而不是数组,那么即使原本是多色彩的图标,也会变成单色图标。

<SvgIcon name="alipay" color="green" />

图标多色彩

多色彩的图标,如果不指定颜色值,图标将渲染原本的多色彩。如果你想设置为其他的颜色,那么设置一组你想要的颜色即可

<IconFont name="alipay" color={['green', 'orange']} />

颜色组的数量以及排序,需要根据当前图标的信息来确定。您需要进入图标组件中查看并得出结论。

更新图标

icon_svg文件夹下的 svg 文件发生变化时,只需要重新执行下面的命令即可生成最新的图标组件

npx svgicon-rn