Skip to content

Commit

Permalink
Add GitHub workflow and update deps (#309)
Browse files Browse the repository at this point in the history
  • Loading branch information
robmadole authored Dec 6, 2019
1 parent 86989ef commit 0406a6a
Show file tree
Hide file tree
Showing 14 changed files with 9,192 additions and 5,303 deletions.
3 changes: 0 additions & 3 deletions .babelrc

This file was deleted.

37 changes: 37 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: Tests

on: [push]

jobs:
test:
runs-on: ubuntu-latest

strategy:
matrix:
node: [10.14.x]
react: [
16.2.x,
16.3.x,
16.4.x,
16.5.x,
16.6.x,
16.7.x,
16.8.x,
16.9.x,
16.10.x,
16.11.x,
16.12.x
]

steps:
- uses: actions/checkout@v1
- uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node }}
- name: npm install and test
run: |
npm install
npm install react@${{ matrix.react }} react-dom@${{ matrix.react }} react-test-renderer@${{ matrix.react }}
npm list react react-dom react-test-renderer
npm run lint
npm run test
6 changes: 0 additions & 6 deletions .travis.yml

This file was deleted.

3 changes: 3 additions & 0 deletions babel.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = {
presets: ['@babel/preset-env', '@babel/preset-react']
}
64 changes: 42 additions & 22 deletions index.es.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,20 +31,35 @@ function _defineProperty(obj, key, value) {
return obj;
}

function _objectSpread(target) {
function ownKeys(object, enumerableOnly) {
var keys = Object.keys(object);

if (Object.getOwnPropertySymbols) {
var symbols = Object.getOwnPropertySymbols(object);
if (enumerableOnly) symbols = symbols.filter(function (sym) {
return Object.getOwnPropertyDescriptor(object, sym).enumerable;
});
keys.push.apply(keys, symbols);
}

return keys;
}

function _objectSpread2(target) {
for (var i = 1; i < arguments.length; i++) {
var source = arguments[i] != null ? arguments[i] : {};
var ownKeys = Object.keys(source);

if (typeof Object.getOwnPropertySymbols === 'function') {
ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) {
return Object.getOwnPropertyDescriptor(source, sym).enumerable;
}));
if (i % 2) {
ownKeys(Object(source), true).forEach(function (key) {
_defineProperty(target, key, source[key]);
});
} else if (Object.getOwnPropertyDescriptors) {
Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
} else {
ownKeys(Object(source)).forEach(function (key) {
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
});
}

ownKeys.forEach(function (key) {
_defineProperty(target, key, source[key]);
});
}

return target;
Expand Down Expand Up @@ -191,6 +206,8 @@ function convert(createElement, element) {
var children = (element.children || []).map(function (child) {
return convert(createElement, child);
});
/* eslint-disable dot-notation */

var mixins = Object.keys(element.attributes || {}).reduce(function (acc, key) {
var val = element.attributes[key];

Expand Down Expand Up @@ -222,8 +239,10 @@ function convert(createElement, element) {
existingStyle = _extraProps$style === void 0 ? {} : _extraProps$style,
remaining = _objectWithoutProperties(extraProps, ["style"]);

mixins.attrs['style'] = _objectSpread({}, mixins.attrs['style'], existingStyle);
return createElement.apply(void 0, [element.tag, _objectSpread({}, mixins.attrs, remaining)].concat(_toConsumableArray(children)));
mixins.attrs['style'] = _objectSpread2({}, mixins.attrs['style'], {}, existingStyle);
/* eslint-enable */

return createElement.apply(void 0, [element.tag, _objectSpread2({}, mixins.attrs, {}, remaining)].concat(_toConsumableArray(children)));
}

var PRODUCTION = false;
Expand All @@ -241,31 +260,31 @@ function log () {
}

// Normalize icon arguments
function normalizeIconArgs(icon$$1) {
function normalizeIconArgs(icon) {
// if the icon is null, there's nothing to do
if (icon$$1 === null) {
if (icon === null) {
return null;
} // if the icon is an object and has a prefix and an icon name, return it


if (_typeof(icon$$1) === 'object' && icon$$1.prefix && icon$$1.iconName) {
return icon$$1;
if (_typeof(icon) === 'object' && icon.prefix && icon.iconName) {
return icon;
} // if it's an array with length of two


if (Array.isArray(icon$$1) && icon$$1.length === 2) {
if (Array.isArray(icon) && icon.length === 2) {
// use the first item as prefix, second as icon name
return {
prefix: icon$$1[0],
iconName: icon$$1[1]
prefix: icon[0],
iconName: icon[1]
};
} // if it's a string, use it as the icon name


if (typeof icon$$1 === 'string') {
if (typeof icon === 'string') {
return {
prefix: 'fas',
iconName: icon$$1
iconName: icon
};
}
}
Expand All @@ -291,7 +310,7 @@ function FontAwesomeIcon(props) {
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, _objectSpread({}, classes, transform, mask, {
var renderedIcon = icon(iconLookup, _objectSpread2({}, classes, {}, transform, {}, mask, {
symbol: symbol,
title: title
}));
Expand All @@ -305,6 +324,7 @@ function FontAwesomeIcon(props) {
var extraProps = {};
Object.keys(props).forEach(function (key) {
if (!FontAwesomeIcon.defaultProps.hasOwnProperty(key)) {
// eslint-disable-line no-prototype-builtins
extraProps[key] = props[key];
}
});
Expand Down
50 changes: 35 additions & 15 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@fortawesome/fontawesome-svg-core'), require('prop-types'), require('react')) :
typeof define === 'function' && define.amd ? define(['exports', '@fortawesome/fontawesome-svg-core', 'prop-types', 'react'], factory) :
(global = global || self, factory(global['react-fontawesome'] = {}, global.FontAwesome, global.PropTypes, global.React));
}(this, function (exports, fontawesomeSvgCore, PropTypes, React) { 'use strict';
}(this, (function (exports, fontawesomeSvgCore, PropTypes, React) { 'use strict';

PropTypes = PropTypes && PropTypes.hasOwnProperty('default') ? PropTypes['default'] : PropTypes;
React = React && React.hasOwnProperty('default') ? React['default'] : React;
Expand Down Expand Up @@ -36,20 +36,35 @@
return obj;
}

function _objectSpread(target) {
function ownKeys(object, enumerableOnly) {
var keys = Object.keys(object);

if (Object.getOwnPropertySymbols) {
var symbols = Object.getOwnPropertySymbols(object);
if (enumerableOnly) symbols = symbols.filter(function (sym) {
return Object.getOwnPropertyDescriptor(object, sym).enumerable;
});
keys.push.apply(keys, symbols);
}

return keys;
}

function _objectSpread2(target) {
for (var i = 1; i < arguments.length; i++) {
var source = arguments[i] != null ? arguments[i] : {};
var ownKeys = Object.keys(source);

if (typeof Object.getOwnPropertySymbols === 'function') {
ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) {
return Object.getOwnPropertyDescriptor(source, sym).enumerable;
}));
if (i % 2) {
ownKeys(Object(source), true).forEach(function (key) {
_defineProperty(target, key, source[key]);
});
} else if (Object.getOwnPropertyDescriptors) {
Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
} else {
ownKeys(Object(source)).forEach(function (key) {
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
});
}

ownKeys.forEach(function (key) {
_defineProperty(target, key, source[key]);
});
}

return target;
Expand Down Expand Up @@ -196,6 +211,8 @@
var children = (element.children || []).map(function (child) {
return convert(createElement, child);
});
/* eslint-disable dot-notation */

var mixins = Object.keys(element.attributes || {}).reduce(function (acc, key) {
var val = element.attributes[key];

Expand Down Expand Up @@ -227,8 +244,10 @@
existingStyle = _extraProps$style === void 0 ? {} : _extraProps$style,
remaining = _objectWithoutProperties(extraProps, ["style"]);

mixins.attrs['style'] = _objectSpread({}, mixins.attrs['style'], existingStyle);
return createElement.apply(void 0, [element.tag, _objectSpread({}, mixins.attrs, remaining)].concat(_toConsumableArray(children)));
mixins.attrs['style'] = _objectSpread2({}, mixins.attrs['style'], {}, existingStyle);
/* eslint-enable */

return createElement.apply(void 0, [element.tag, _objectSpread2({}, mixins.attrs, {}, remaining)].concat(_toConsumableArray(children)));
}

var PRODUCTION = false;
Expand Down Expand Up @@ -296,7 +315,7 @@
var classes = objectWithKey('classes', [].concat(_toConsumableArray(classList(props)), _toConsumableArray(className.split(' '))));
var transform = objectWithKey('transform', typeof props.transform === 'string' ? fontawesomeSvgCore.parse.transform(props.transform) : props.transform);
var mask = objectWithKey('mask', normalizeIconArgs(maskArgs));
var renderedIcon = fontawesomeSvgCore.icon(iconLookup, _objectSpread({}, classes, transform, mask, {
var renderedIcon = fontawesomeSvgCore.icon(iconLookup, _objectSpread2({}, classes, {}, transform, {}, mask, {
symbol: symbol,
title: title
}));
Expand All @@ -310,6 +329,7 @@
var extraProps = {};
Object.keys(props).forEach(function (key) {
if (!FontAwesomeIcon.defaultProps.hasOwnProperty(key)) {
// eslint-disable-line no-prototype-builtins
extraProps[key] = props[key];
}
});
Expand Down Expand Up @@ -360,4 +380,4 @@

Object.defineProperty(exports, '__esModule', { value: true });

}));
})));
Loading

0 comments on commit 0406a6a

Please sign in to comment.