Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.3k views
in Technique[技术] by (71.8m points)

spartacus storefront - how to configure new fontawesome icon to use it with ICON_TYPE enum


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

You can configure the icon type with the ConfigModule. There are various ways to do so, I'm showing you an example with a so-called provider, but you can also use the ConfigModule or StorefrontModule to so.

providers: [
  provideConfig({
    icon: { symbols: { MIC: 'fas fa-microphone' } }
  } as IconConfig)
]

Please not that I'm using the fontawesome version that has already been imported in Spartacus. If you switch to an alternative resource you must register the resource. You can read more about this at the documentation: https://sap.github.io/spartacus-docs/icon-library/

You can then use the new icon type in a component:

<cx-icon type="MIC"></cx-icon>

or as a directive:

<button cxIcon="MIC">I LIKE IT LOUD</button>

In order to use the icon directive, you need to import the IconModule in the Angular module that host your component.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...