Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
import {library, config} from '@fortawesome/fontawesome-svg-core';
import {fab} from '@fortawesome/free-brands-svg-icons';
import {fas} from '@fortawesome/free-solid-svg-icons';
import {far} from '@fortawesome/free-regular-svg-icons';
import {themr} from '@friendsofreactjs/react-css-themr';
import identifiers from '../identifiers';
import style from './style.css';
import Icon from './icon';
/* eslint-disable no-unused-vars */
import faStyle from '@fortawesome/fontawesome-svg-core/styles.css';
/* eslint-enable no-unused-vars */
config.autoAddCss = false;
config.familyPrefix = 'neos-fa';
config.replacementClass = 'neos-svg-inline--fa';
library.add(fab, fas, far);
const ThemedIcon = themr(identifiers.icon, style)(Icon);
export default ThemedIcon;
build() {
if(this._isBuilt) return
const pack = require(`@fortawesome/${this.options.pack}`)
let selectedIcons;
if(this.options.icons === 'all'){
selectedIcons = Object.keys(pack[pack.prefix])
} else {
const prefix = config.familyPrefix;
//Look for icons which already contain the prefix as eg `faPencil` or `fa-pencil` without catching `fax`
const regexp = new RegExp(`^${prefix}([A-Z]|-)`);
selectedIcons = this.options.icons.map(iconName => {
if (!regexp.test(iconName)) {
iconName = `${prefix}-${iconName}`;
}
return camelCase(iconName);
});
}
const packageContents = `
export {
${ selectedIcons.join(',') }
} from '@fortawesome/${this.options.pack}/index.es.js'
`
render: function render(createElement, context) {
var familyPrefix = config.familyPrefix;
var props = context.props;
var classes = objectWithKey('classes', [].concat(toConsumableArray(props.counter ? [familyPrefix + '-layers-counter'] : []), toConsumableArray(props.position ? [familyPrefix + '-layers-' + props.position] : [])));
var transform = objectWithKey('transform', typeof props.transform === 'string' ? parse.transform(props.transform) : props.transform);
var renderedText = text(props.value.toString(), _extends({}, transform, classes));
var abstract = renderedText.abstract;
if (props.counter) {
abstract[0].attributes.class = abstract[0].attributes.class.replace('fa-layers-text', '');
}
render: function render(createElement, context) {
var familyPrefix = config.familyPrefix;
var staticClass = context.data.staticClass;
var classes = [familyPrefix + '-layers'].concat(toConsumableArray(context.props.fixedWidth ? [familyPrefix + '-fw'] : []));
return createElement('div', _extends({}, context.data, {
staticClass: addStaticClass(staticClass, classes)
}), context.children);
}
};