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

one-icon

v1.2.3

Published

one-icon 是由阿里数据技术及产品部新能源前端团队开发的辅助 ifont 使用的工具。

Downloads

5

Readme

one-icon

one-icon 是由阿里数据技术及产品部新能源前端团队开发的辅助 ifont 使用的工具。

npm version npm downloads Gitter

one-icon 提供如下功能:

  1. 自动检测更新并一键生成项目中需要的最新 css、js 代码
  2. 采用了 Iconfont 的 font-class 和 symbol 方案,同时支持单色和多色 icon;
  3. 提供可视化展示界面,一键复制代码。

安装

下载安装 one-icon 工具:

yarn:

yarn global add one-icon

npm:

npm add -g one-icon

安装 one-icon React 组件

yarn:

yarn add one-icon

npm:

npm i -S one-icon

使用

在项目根目录下建立oneicon-config.json文件,配置需要的项目参数:

// 示例代码
{
  "projectList": [
    {
      "id": "11111",  // Iconfont中的项目id列表
      "cssOutputPath": "src/styles/iconfont.scss", // 输出css文件的目录
      "iconCode": "<i class='iconfont icon-{fontName} {extraClasses}'></i>", // 展示界面复制Iconfont的模板,其中{fontName}表示字体类名,{extraClasses}表示样式类名,会自动替换
      "classNameList": ["cssClassName"] // 额外添加的CSS样式类
    },
    {
      "id": "222",
      "jsOutputPath": "src/styles/qbi-svg-icon.js", // 输出js文件的目录
      "svgIconCode": "<svg class='svg-icon {extraClasses}' aria-hidden='true'><use xlink:href='#icon-{fontName}'></use></svg>",  // 展示界面复制SVG的模板
      "svgClassNameList": ["svgClassName"]  // 额外添加的SVG样式类
    },
    ,
    {
      "id": "333",
      "jsOutputPath": "src/styles/fbi-svg-icon.js", // 输出js文件的目录
      "uniqueId": "fbi", // 多项目svg id重合时加上的id
      "svgIconCode": "<svg class='svg-icon {extraClasses}' aria-hidden='true'><use xlink:href='#icon-fbi-{fontName}'></use></svg>",  // 展示界面复制SVG的模板,需要加上uniqueId
      "svgClassNameList": ["svgClassName"]  // 额外添加的SVG样式类
    }
  ]
}

在终端运行icon开启服务,one-icon 将自动生成相关的 css、js 代码到相应的文件夹中。

此时打开 127.0.0.1:3000 可以看到可视化的界面,界面上提供复制代码、自动检测、自动更新的功能。

代码每隔 10 分钟检查一次是否是最新的样式代码,若不是则会自动更新,重新下载样式文件。

常见问题

  • 运行 npm run icon 出错

请仔细阅读报错信息,很有可能是配置出错;请确保你的 projectId 正确,你的路径存在。

  • 服务启动之后,代码并没有自动更新?

由于更新代码需要获取登录授权,而自动打开的授权弹窗可能由于你的浏览器设置而被阻止;此时你需要点击展示页面的【手动更新】按钮进行更新。

  • 我手动更新了,项目中还是没生效?

请确保项目中引入了生成的 css、js 文件,并确认项目中的代码是否需要手动刷新之后才生效。