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

@tomoeed/j-icon

v4.0.7

Published

A SVG icon component for Vue

Downloads

18

Readme

j-icon

Vue 3.0 SVG图标组件

该组件仅渲染<svg>元素. 你必须通过icon prop 传入图标对象或在安装插件时传入需要使用的图标

使用 CLI 批量创建图标

安装

npm install @tomoeed/j-icon --save

使用

通过插件安装

import {createApp} from 'vue';
import {plugin} from '@tomoeed/j-icon';

createApp({}).use(plugin, {name: 'j-icon', classes: [], prefix: true, icons: []});
<template>
    <j-icon icon=""/>
</template>

直接使用组件

<template>
    <j-icon icon="alert"/>
</template>

<script setup>
import JIcon from '@tomoeed/j-icon';
import {alert} from '< icon_file >';
</script>

// OR
<script>
import JIcon from '@tomoeed/j-icon';
import {alert} from '< icon_file >';

export default {
    component: { JIcon },
    setup() {
        return { alert };
    }
}
</script>

插件可选的选项对象

  • name: 组件名称
app.use(JIcon, {name: 'v-icon'});

<v-icon icon=""/>
  • icons: 所有图标对象. 安装插件时传入的图标在使用组件时可以直接使用该图标的名称
app.use(JIcon, {icons: {x:{}}});
app.use(JIcon, {icons: [{name: 'x'}]});

<j-icon icon="x"/>
  • classes: 渲染<svg>元素时,默认添加的class
app.use(JIcon, {classes: ['icon']});

<svg class="icon">...</svg>
  • prefix: 图标名称class前缀
    • 如果为false, 则不会添加具有图标名称的class
    • 如果为true, 则添加icon-前缀
    • 如果是字符串, 将会与图标名称拼接
app.use(JIcon, {prefix: 'j-icon-'});

<j-icon icon="x"/>

<svg class="icon j-icon-x">...</svg>

组件 props

  • icon: 需要渲染的图标的名称或该图标对象
  • width: SVG 元素宽度
  • height: SVG 元素高度
  • tabindex SVG 元素是否可以聚焦
  • title: 为 SVG 元素提供一个描述性字符串, 用来提升 SVG 文档的可访问性
  • aria-label: HTML aria-label 属性
  • desc: 为 SVG 元素提供一个长文本描述, 用来提升 SVG 文档的可访问性
  • aria-description: HTML aria-description 属性

titlearia-label 属性不要同时使用, 若同时为这两个属性提供值, 则优先使用 title 属性. descaria-description 属性同理

<j-icon icon="x" title="title" aria-label="aria-label"/>

<svg aria-labelledby="0123456789">
    <title id="0123456789">title</title>
    ...
</svg>

创建图标对象

图标对象属性查看 Icon

import {h as createElement} from 'vue';
const book = {
    name: 'book',
    viewBox: [0, 0, 16, 16],
    size: [16, 16],
    render: () => createElement('path', {d: ''})
};

CLI

使用

j-icon --input <input-path> --output <dist>

选项

  • -i, --input 文件或文件夹路径, 支持输入多个路径
  • -o, --output 文件输出目录
  • -f, --format 输出文件格式, 支持格式: esm, umd, ts, type (默认值: esm type)
  • -n, --name 输出文件名称 (默认值: index)

License

Apache-2.0