How to use the @fortawesome/fontawesome-svg-core.parse.transform function in @fortawesome/fontawesome-svg-core

To help you get started, we’ve selected a few @fortawesome/fontawesome-svg-core examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github FortAwesome / react-fontawesome / index.es.js View on Github external
function FontAwesomeIcon(props) {
  var iconArgs = props.icon,
      maskArgs = props.mask,
      symbol = props.symbol,
      className = props.className,
      title = props.title;
  var iconLookup = normalizeIconArgs(iconArgs);
  var classes = objectWithKey('classes', [].concat(_toConsumableArray(classList(props)), _toConsumableArray(className.split(' '))));
  var transform = objectWithKey('transform', typeof props.transform === 'string' ? parse.transform(props.transform) : props.transform);
  var mask = objectWithKey('mask', normalizeIconArgs(maskArgs));
  var renderedIcon = icon(iconLookup, _objectSpread2({}, classes, {}, transform, {}, mask, {
    symbol: symbol,
    title: title
  }));

  if (!renderedIcon) {
    log('Could not find icon', iconLookup);
    return null;
  }

  var abstract = renderedIcon.abstract;
  var extraProps = {};
  Object.keys(props).forEach(function (key) {
    if (!FontAwesomeIcon.defaultProps.hasOwnProperty(key)) {
      // eslint-disable-line no-prototype-builtins
github FortAwesome / react-native-fontawesome / src / components / FontAwesomeIcon.js View on Github external
export default function FontAwesomeIcon(props) {
  const { icon: iconArgs, mask: maskArgs, height, width, style, size } = props

  const iconLookup = normalizeIconArgs(iconArgs)
  const transform = objectWithKey(
    'transform',
    typeof props.transform === 'string'
      ? parse.transform(props.transform)
      : props.transform
  )
  const mask = objectWithKey('mask', normalizeIconArgs(maskArgs))
  const renderedIcon = icon(iconLookup, {
    ...transform,
    ...mask
  })

  if (!renderedIcon) {
    log("ERROR: icon not found for icon = ", iconArgs)
    return null
  }

  const { abstract } = renderedIcon

  // This is the color that will be passed to the "fill" prop of the Svg element
github FortAwesome / vue-fontawesome / index.es.js View on Github external
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', '');
    }

    var convertCurry = convert.bind(null, createElement);

    return convertCurry(abstract[0], {}, context.data);
  }
};
github FortAwesome / angular-fontawesome / src / lib / icon / icon.component.ts View on Github external
protected buildParams() {
    const classOpts: FaProps = {
      flip: this.flip,
      spin: this.spin,
      pulse: this.pulse,
      border: this.border,
      inverse: this.inverse,
      size: this.size || null,
      pull: this.pull || null,
      rotate: this.rotate || null,
      fixedWidth: this.fixedWidth,
      stackItemSize: this.stackItem != null ? this.stackItem.stackItemSize : null,
    };

    const parsedTransform = typeof this.transform === 'string' ? parse.transform(this.transform) : this.transform;

    return {
      title: this.title,
      transform: parsedTransform,
      classes: [...faClassList(classOpts), ...this.classes],
      mask: this.mask != null ? this.findIconDefinition(this.mask) : null,
      styles: this.styles != null ? this.styles : {},
      symbol: this.symbol,
      attributes: {
        role: this.a11yRole,
      },
    };
  }
github GSA / sam-ui-elements / src / ui-kit / experimental / icon / fa-icon / fa-icon.component.ts View on Github external
const classOpts: FaProps = {
        flip: this.flip,
        spin: this.spin,
        pulse: this.pulse,
        border: this.border,
        inverse: this.inverse,
        listItem: this.listItem,
        size: this.size || null,
        pull: this.pull || null,
        rotate: this.rotate || null,
        fixedWidth: this.fixedWidth
      };
  
      const classes = objectWithKey('classes', [...faClassList(classOpts), ...this.classes]);
      const mask = objectWithKey('mask', faNormalizeIconSpec(this.mask));
      const parsedTransform = typeof this.transform === 'string' ? parse.transform(this.transform) : this.transform;
      const transform = objectWithKey('transform', parsedTransform);
  
      this.params = {
        title: this.title,
        ...transform,
        ...classes,
        ...mask,
        styles: this.styles,
        symbol: this.symbol
      };
    }
github FortAwesome / ember-fontawesome / addon / components / fa-icon.js View on Github external
function () {
    const iconLookup = normalizeIconArgs(this.get('prefix'), this.get('iconOrPositionalParam'))
    const classes = objectWithKey('classes', [...classList.bind(this)()])
    const transformProp = this.get('transform')
    const transform = objectWithKey('transform', (typeof transformProp === 'string') ? parse.transform(transformProp) : transformProp)
    const mask = objectWithKey('mask', normalizeIconArgs(null, this.get('mask')))
    const symbol = this.getWithDefault('symbol', false)
    let title = this.getWithDefault('title', null)
    if (title) {
      title = `${title}`;
    }

    const o = assign({},
      classes,
      transform,
      mask,
      { symbol, title }
    )

    const renderedIcon = icon(iconLookup, o);
    if (!renderedIcon) {
github FortAwesome / vue-fontawesome / src / components / FontAwesomeIcon.js View on Github external
render (createElement, context) {
    const { props } = context

    const { icon: iconArgs, mask: maskArgs, symbol, title } = props
    const icon = normalizeIconArgs(iconArgs)
    const classes = objectWithKey('classes', classList(props))
    const transform = objectWithKey('transform', (typeof props.transform === 'string') ? faParse.transform(props.transform) : props.transform)
    const mask = objectWithKey('mask', normalizeIconArgs(maskArgs))

    const renderedIcon = faIcon(
      icon,
      { ...classes, ...transform, ...mask, symbol, title }
    )

    if (!renderedIcon) {
      return log('Could not find one or more icon(s)', icon, mask)
    }

    const { abstract } = renderedIcon
    const convertCurry = convert.bind(null, createElement)

    return convertCurry(abstract[0], {}, context.data)
  }
github FortAwesome / angular-fontawesome / src / lib / layers / layers-text.component.ts View on Github external
protected buildParams(): TextParams {
    const classOpts: FaProps = {
      flip: this.flip,
      spin: this.spin,
      pulse: this.pulse,
      border: this.border,
      inverse: this.inverse,
      size: this.size || null,
      pull: this.pull || null,
      rotate: this.rotate || null,
      fixedWidth: this.fixedWidth,
    };

    const parsedTransform = typeof this.transform === 'string' ? parse.transform(this.transform) : this.transform;

    return {
      transform: parsedTransform,
      classes: [...faClassList(classOpts), ...this.classes],
      title: this.title,
      styles: this.styles,
    };
  }