Welcome to OStack Knowledge Sharing 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 Answer

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...