You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Have you thought about using a helper for icon delivery? We're using something like this and it's really fast. 🚀
Maybe this addon could break apart the two tasks of:
Retrieving icons from NPM etc. and subsetting
Delivery of icon into template/code. Could be left to the user, or could provide both helper and component as base (but I wouldn't go overboard with the component, easier to let people subclass the component if they need special stuff, aria, etc)
import{helperasbuildHelper}from'@ember/component/helper';import{htmlSafe}from'@ember/template';constICON_CLASS='icon';constTYPE_CLASS={brand: 'fab',light: 'fal',regular: 'far',solid: 'fas',duotone: 'fad',};constFALLBACK_TYPE='solid';constICON_PREFIX='fa-';constSIZE_PREFIX='fa-';// Simple icon helper// `{{icon 'file-alt' type='regular' size='4x'}}` outputs `<i class='far fa-file-alt fa-4x'></i>`// (do not rely on the `fa-` class names, consider them internal to this component)exportdefaultbuildHelper(function(args,options){letname=args[0];lettype=options.type||FALLBACK_TYPE;if(!Object.keys(TYPE_CLASS).includes(type)){thrownewError(`Icon font type '${type}' not supported`);}lettypeKlass=TYPE_CLASS[type];letklass=`${ICON_CLASS}${typeKlass}${ICON_PREFIX}${name}`;if(options.size){klass+=` ${SIZE_PREFIX}${options.size}`;}if(options.class){klass+=` ${options.class}`;}returnhtmlSafe(`<i class='${klass}'></i>`);});
The text was updated successfully, but these errors were encountered:
Awesome addon! 🏅
Have you thought about using a helper for icon delivery? We're using something like this and it's really fast. 🚀
Maybe this addon could break apart the two tasks of:
The text was updated successfully, but these errors were encountered: