Giter Site home page Giter Site logo

Comments (2)

HeskeyBaozi avatar HeskeyBaozi commented on July 27, 2024

dynamic-icon自定义图标的本质是iconfont.cn上托管的字体图标的自定义。
我的思路是在Icon组件上新增静态方法createCustom,并引用自DynamicIcon.create({...})

但现在大多数自定义图标的情况是下列两种:

  1. 用户在自己本地环境拥有.ttf/.eot字体文件,需要自己引入css文件。这种做法实际上和以前完全一致。
  2. 用户自己拥有图标文件(.svg)。用户需要自己将svg标签转换成jsx,如:
const HomeIcon = (props) => (
  <svg {...props}>
    <path d="M10 20v-6h4v6h5v-8h3L12 3 2 12h3v8z" />
  </svg>
);

render(<HomeIcon />, mountedNode);

此库本质上也是一个导出由svg转换成react component的“静态”库。类似于Material Icons

但是最终我觉得还是无法令人满意。目标是向后兼容字体图标、且用户的自定义图标也可以使用。

from ant-design-icons.

afc163 avatar afc163 commented on July 27, 2024
  1. 大多数用户的需求都是用 iconfont.cn,也是我们推荐的方案:https://pro.ant.design/docs/biz-icon-cn
  2. 本地环境 tff eot svg,提供文档帮助即可,目前不太可能提供傻瓜式的方案。

from ant-design-icons.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.