@fortawesome/react-native-fontawesome 0.2.7 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -6,7 +6,7 @@
6
6
 
7
7
  [![npm](https://img.shields.io/npm/v/@fortawesome/react-native-fontawesome.svg?style=flat-square)](https://www.npmjs.com/package/@fortawesome/react-native-fontawesome)
8
8
 
9
- > Font Awesome 5 React Native component using SVG with JS
9
+ > Font Awesome React Native component using SVG with JS
10
10
 
11
11
  <!-- toc -->
12
12
 
@@ -21,13 +21,13 @@
21
21
  * [Explicit Import](#explicit-import)
22
22
  * [Build a Library to Reference Icons Throughout Your App More Conveniently](#build-a-library-to-reference-icons-throughout-your-app-more-conveniently)
23
23
  * [Color](#color)
24
- + [Color Prop](#color-prop)
24
+ + [Color Prop](#color-prop)
25
25
  + [Change Color with a StyleSheet](#color-stylesheet-property)
26
- * [Size](#size)
26
+ * [Size](#size)
27
27
  - [Features](#features)
28
28
  * [Duotone](#duotone)
29
29
  * [Masking](#masking)
30
- * [Power Transforms](#power-transforms)
30
+ * [Power Transforms](#power-transforms)
31
31
  - [Frequent questions](#frequent-questions)
32
32
  * [How do I import the same icon from two different styles?](#how-do-i-import-the-same-icon-from-two-different-styles)
33
33
  * [I don't think tree-shaking is working; got any advice?](#i-dont-think-tree-shaking-is-working-got-any-advice)
@@ -42,24 +42,24 @@ Hey there! We're glad you're here...
42
42
 
43
43
  #### Upgrading Font Awesome?
44
44
 
45
- If you've used Font Awesome in the past (version 4 or older) there are some
45
+ If you've used Font Awesome in the past (version 5 or older) there are some
46
46
  things that you should learn before you dive in.
47
47
 
48
- > https://fontawesome.com/how-to-use/on-the-web/setup/upgrading-from-version-4
48
+ > https://fontawesome.com/v6/docs/web/setup/upgrade/
49
49
 
50
50
  #### Get started
51
51
 
52
52
  This package is for integrating with React Native. If you aren't using React Native then it's
53
53
  not going to help you. Head over to our "Get Started" page for some guidance.
54
54
 
55
- > https://fontawesome.com/how-to-use/on-the-web/setup/getting-started
55
+ > https://fontawesome.com/v6/docs/web/setup/quick-start
56
56
 
57
57
  #### Learn about our new SVG implementation
58
58
 
59
59
  This package, under the hood, uses SVG with JS and the `@fortawesome/fontawesome-svg-core` library. This implementation differs drastically from
60
60
  the web fonts implementation that was used in version 4 and older of Font Awesome. You might head over there to learn about how it works.
61
61
 
62
- > https://fontawesome.com/how-to-use/on-the-web/advanced/svg-javascript-core
62
+ > https://fontawesome.com/v6/docs/web/dig-deeper/svg-core
63
63
 
64
64
  ## Installation
65
65
 
@@ -92,7 +92,7 @@ $ npm i --save @fortawesome/free-brands-svg-icons
92
92
  $ npm i --save @fortawesome/free-regular-svg-icons
93
93
  ```
94
94
 
95
- If you are a [Font Awesome Pro](https://fontawesome.com/pro) subscriber you can install Pro packages; this requires [additional configuration](https://fontawesome.com/how-to-use/on-the-web/setup/using-package-managers).
95
+ If you are a [Font Awesome Pro](https://fontawesome.com/pro) subscriber you can install Pro packages; this requires [additional configuration](https://fontawesome.com/v6/docs/web/setup/packages).
96
96
 
97
97
  ```
98
98
  $ npm i --save @fortawesome/pro-solid-svg-icons
@@ -120,13 +120,13 @@ $ yarn add @fortawesome/react-native-fontawesome
120
120
  You can use Font Awesome icons in your React Native components as simply as this:
121
121
 
122
122
  ```javascript
123
- <FontAwesomeIcon icon="coffee" />
123
+ <FontAwesomeIcon icon="mug-saucer" />
124
124
  ```
125
125
 
126
- That simple usage is made possible when you add the `"coffee"` icon, to the
126
+ That simple usage is made possible when you add the `"mug-saucer"` icon, to the
127
127
  _library_.
128
128
 
129
- This is one of the two ways you can use Font Awesome 5 with React Native. We'll
129
+ This is one of the two ways you can use Font Awesome with React Native. We'll
130
130
  summarize both ways briefly and then get into the details of each below.
131
131
 
132
132
  1. **Explicit Import**
@@ -164,22 +164,22 @@ Now, a simple React Native component might look like this:
164
164
  import React, { Component } from 'react'
165
165
  import { View } from 'react-native'
166
166
  import { FontAwesomeIcon } from '@fortawesome/react-native-fontawesome'
167
- import { faCoffee } from '@fortawesome/free-solid-svg-icons'
167
+ import { faMugSaucer } from '@fortawesome/free-solid-svg-icons/faMugSaucer'
168
168
 
169
169
  type Props = {}
170
170
  export default class App extends Component<Props> {
171
171
  render() {
172
172
  return (
173
173
  <View>
174
- <FontAwesomeIcon icon={ faCoffee } />
174
+ <FontAwesomeIcon icon={ faMugSaucer } />
175
175
  </View>
176
176
  )
177
177
  }
178
178
  }
179
179
  ```
180
180
 
181
- Notice that the `faCoffee` icon is imported from
182
- `@fortawesome/free-solid-svg-icons` as an object and then provided to the
181
+ Notice that the `faMugSaucer` icon is imported from
182
+ `@fortawesome/free-solid-svg-icons/faMugSaucer` as an object and then provided to the
183
183
  `icon` prop as an object.
184
184
 
185
185
  Explicitly importing icons like this allows us to subset Font Awesome's
@@ -197,7 +197,7 @@ So, add them to the _library_. Do this setup once in some initializing module
197
197
  of your app, adding all of the icons you'll use in your app's React components.
198
198
 
199
199
  Suppose `App.js` initializes my app, including the library. For this example,
200
- we'll add two individual icons, `faCheckSquare` and `faCoffee`. We also add all
200
+ we'll add two individual icons, `faSquareCheck` and `faMugSaucer`. We also add all
201
201
  of the brands in `@fortawesome/free-brands-svg-icons`. This example would
202
202
  illustrate the benefits of building a library even more clearly if it involved
203
203
  fifty or a hundred icons, but we'll keep the example brief and leave it to your
@@ -221,9 +221,10 @@ In `App.js`, where our app is initialized:
221
221
  // ...
222
222
  import { library } from '@fortawesome/fontawesome-svg-core'
223
223
  import { fab } from '@fortawesome/free-brands-svg-icons'
224
- import { faCheckSquare, faCoffee } from '@fortawesome/free-solid-svg-icons'
224
+ import { faSquareCheck } from '@fortawesome/free-solid-svg-icons/faSquareCheck'
225
+ import { faMugEmpty } from '@fortawesome/free-solid-svg-icons/faMugEmpty'
225
226
 
226
- library.add(fab, faCheckSquare, faCoffee)
227
+ library.add(fab, faSquareCheck, faMugSaucer)
227
228
  ```
228
229
 
229
230
  OK, so what's happening here?
@@ -235,9 +236,9 @@ In our call to <span style="white-space:nowrap;">`library.add()`</span> we're pa
235
236
  So any of the brand icons in that package may be referenced by icon name
236
237
  as a string anywhere else in our app.
237
238
  For example: `"apple"`, `"microsoft"`, or `"google"`.
238
- - `faCheckSquare` and `faCoffee`: Adding each of these icons individually
239
+ - `faSquareCheck` and `faMugSaucer`: Adding each of these icons individually
239
240
  allows us to refer to them throughout our app by their icon string names,
240
- `"check-square"` and `"coffee"`, respectively.
241
+ `"square-check"` and `"mug-saucer"`, respectively.
241
242
 
242
243
  Now, suppose you also have React Native components `Beverage` and `Gadget` in your app.
243
244
  You don't have to re-import your icons into them. Just import the `FontAwesomeIcon`
@@ -252,8 +253,8 @@ import { FontAwesomeIcon } from '@fortawesome/react-native-fontawesome'
252
253
 
253
254
  export const Beverage = () => (
254
255
  <View>
255
- <FontAwesomeIcon icon="check-square" />
256
- <Text>Favorite beverage: </Text><FontAwesomeIcon icon="coffee" />
256
+ <FontAwesomeIcon icon="square-check" />
257
+ <Text>Favorite beverage: </Text><FontAwesomeIcon icon="mug-saucer" />
257
258
  </View>
258
259
  )
259
260
  ```
@@ -272,7 +273,7 @@ import { FontAwesomeIcon } from '@fortawesome/react-native-fontawesome'
272
273
 
273
274
  export const Gadget = () => (
274
275
  <View>
275
- <FontAwesomeIcon icon="check-square" />
276
+ <FontAwesomeIcon icon="square-check" />
276
277
  <Text>Popular gadgets come from vendors like:</Text>
277
278
  <FontAwesomeIcon icon={['fab', 'apple']} />
278
279
  <FontAwesomeIcon icon={['fab', 'microsoft']} />
@@ -283,7 +284,7 @@ export const Gadget = () => (
283
284
 
284
285
  Notice:
285
286
 
286
- - We used the `"check-square"` icon name again in this component, though we
287
+ - We used the `"square-check"` icon name again in this component, though we
287
288
  didn't have to explicitly import it into this component. With one explicit import of
288
289
  that icon in `App.js`, and adding it to the library, we've managed to use
289
290
  it by name in multiple components.
@@ -296,10 +297,10 @@ Notice:
296
297
  Adding a prefix—and the syntax we used to do it—are new. So what's
297
298
  going on here?
298
299
 
299
- First, recall when we introduced `<FontAwesomeIcon icon="coffee"/>` and learned
300
- that a prefix of `fas` was being added to `"coffee"` by default.
300
+ First, recall when we introduced `<FontAwesomeIcon icon="mug-saucer"/>` and learned
301
+ that a prefix of `fas` was being added to `"mug-saucer"` by default.
301
302
 
302
- The `"check-square"` icon is getting a default prefix of `fas` here too, which
303
+ The `"square-check"` icon is getting a default prefix of `fas` here too, which
303
304
  is what we want, because that icon also lives in the
304
305
  `@fortawesome/free-solid-svg-icons` package.
305
306
 
@@ -314,8 +315,8 @@ Now, what about that syntax?
314
315
 
315
316
  The `icon` prop expects a single object:
316
317
 
317
- - It could be an icon object, like `{faCoffee}`.
318
- - It could a string object, like `"coffee"`.
318
+ - It could be an icon object, like `{faMugSaucer}`.
319
+ - It could a string object, like `"mug-saucer"`.
319
320
  (The curly braces around a string object supplied to a prop are optional,
320
321
  so we've omitted them.)
321
322
  - Or it could be an `Array` of strings, where the first element is a prefix,
@@ -335,7 +336,7 @@ Using the color prop should be preferred over using the StyleSheet.
335
336
  #### Color Prop
336
337
 
337
338
  ```javascript
338
- <FontAwesomeIcon icon={ faCoffee } color={ 'red' } />
339
+ <FontAwesomeIcon icon={ faMugSaucer } color={ 'red' } />
339
340
  ```
340
341
 
341
342
  #### Color StyleSheet property
@@ -346,8 +347,7 @@ To set the color of an icon, provide a `StyleSheet` like this:
346
347
  import React, { Component } from 'react'
347
348
  import { View, StyleSheet } from 'react-native'
348
349
  import { FontAwesomeIcon } from '@fortawesome/react-native-fontawesome'
349
- import { faCoffee } from '@fortawesome/free-solid-svg-icons'
350
-
350
+ import { faMugSaucer } from '@fortawesome/free-solid-svg-icons/faMugSaucer'
351
351
 
352
352
  type Props = {}
353
353
 
@@ -361,7 +361,7 @@ export default class App extends Component<Props> {
361
361
  render() {
362
362
  return (
363
363
  <View>
364
- <FontAwesomeIcon icon={ faCoffee } style={ style.icon } />
364
+ <FontAwesomeIcon icon={ faMugSaucer } style={ style.icon } />
365
365
  </View>
366
366
  )
367
367
  }
@@ -375,7 +375,7 @@ Default: 16
375
375
  To adjust the size, use the `size` prop:
376
376
 
377
377
  ```javascript
378
- <FontAwesomeIcon icon={ faCoffee } size={ 32 } />
378
+ <FontAwesomeIcon icon={ faMugSaucer } size={ 32 } />
379
379
  ```
380
380
 
381
381
  Note: the `height` and `width` props have been deprecated.
@@ -385,7 +385,7 @@ Note: the `height` and `width` props have been deprecated.
385
385
  ### Duotone
386
386
 
387
387
  ```javascript
388
- <FontAwesomeIcon icon="coffee" color="blue" secondaryColor="red" secondaryOpacity={ 0.4 } />
388
+ <FontAwesomeIcon icon="mug-saucer" color="blue" secondaryColor="red" secondaryOpacity={ 0.4 } />
389
389
  ```
390
390
 
391
391
  You can specify the color and opacity for Duotone's secondary layer using the `secondaryColor` and `secondaryOpacity` props. Note that these are optional, and will simply default to using your primary color at 40% opacity.
@@ -393,19 +393,19 @@ You can specify the color and opacity for Duotone's secondary layer using the `s
393
393
  ### Masking
394
394
 
395
395
  ```javascript
396
- <FontAwesomeIcon icon="coffee" mask={['far', 'circle']} />
396
+ <FontAwesomeIcon icon="mug-saucer" mask={['far', 'circle']} />
397
397
  ```
398
398
 
399
- [More on masking...](https://fontawesome.com/how-to-use/on-the-web/styling/masking)
399
+ [More on masking...](https://fontawesome.com/v6/docs/web/style/mask#contentHeader)
400
400
 
401
401
  ### Power Transforms
402
402
 
403
403
  ```javascript
404
- <FontAwesomeIcon icon="arrows" transform="shrink-6 left-4" />
405
- <FontAwesomeIcon icon="arrow-rightr" transform={{ rotate: 42 }} />
404
+ <FontAwesomeIcon icon="arrows-up-down-left-right" transform="shrink-6 left-4" />
405
+ <FontAwesomeIcon icon="arrow-right" transform={{ rotate: 42 }} />
406
406
  ```
407
407
 
408
- [More on power transforms...](https://fontawesome.com/how-to-use/on-the-web/styling/power-transforms)
408
+ [More on power transforms...](https://fontawesome.com/v6/docs/web/style/power-transform#contentHeader)
409
409
 
410
410
  ## Frequent questions
411
411
 
@@ -415,15 +415,35 @@ With ES modules and `import` statements we can rename:
415
415
 
416
416
  ```javascript
417
417
  import { library } from '@fortawesome/fontawesome-svg-core'
418
- import { faStroopwafel as fasFaStroopwafel } from '@fortawesome/pro-solid-svg-icons'
419
- import { faStroopwafel as farFaStroopwafel } from '@fortawesome/pro-regular-svg-icons'
418
+ import { faStroopwafel as fasFaStroopwafel } from '@fortawesome/pro-solid-svg-icons/faStroopwafel'
419
+ import { faStroopwafel as farFaStroopwafel } from '@fortawesome/pro-regular-svg-icons/faStroopwafel'
420
420
 
421
421
  library.add(fasFaStroopwafel, farFaStroopwafel)
422
422
  ```
423
423
 
424
424
  ### I don't think tree-shaking is working; got any advice?
425
425
 
426
- Check out our [docs here](https://fontawesome.com/how-to-use/with-the-api/other/tree-shaking).
426
+ Check out our [docs here](https://fontawesome.com/v6/docs/apis/javascript/tree-shaking).
427
+
428
+ If you find that your build times are taking forever, check the way that you are importing icons.
429
+
430
+ In past versions of `react-native-fontawesome` we've documented importing icons like this:
431
+
432
+ ```javascript
433
+ import { faStroopwafel } from '@fortawesome/pro-solid-svg-icons'
434
+ ```
435
+
436
+ This can cause build times for your project to skyrocket because React Native is trying to tree shake. The Font Awesome
437
+ packages are so large that we _highly_ recommend that you avoid this.
438
+
439
+ Instead, use "deep imports" by default.
440
+
441
+ ```javascript
442
+ import { faStroopwafel } from '@fortawesome/pro-solid-svg-icons/faStroopwafel' // <- notice the additional module here?
443
+ ```
444
+
445
+ By directly importing from the `faStroopwafel.js` module there is no additional work that tree shaking needs to do in order to
446
+ reduce your bundle size.
427
447
 
428
448
  ## How to Help
429
449
 
@@ -440,19 +460,11 @@ And then:
440
460
 
441
461
  Community:
442
462
 
443
- | | Name | GitHub |
444
- | :---------------------------------------------------------: | ----------------- | ---------------------------------------------------- |
445
- | <img src="https://github.com/dizy.png?size=72" /> | Dizy | [@dizy](https://github.com/dizy) |
446
- | <img src="https://github.com/iamdavidmartin.png?size=72" /> | David Martin | [@iamdavidmartin](https://github.com/iamdavidmartin) |
447
- | <img src="https://github.com/puremana.png?size=72" /> | Jeremey | [@puremana](https://github.com/puremana) |
448
- | <img src="https://github.com/schonfeld.png?size=72" /> | Michael Schonfeld | [@schonfeld](https://github.com/schonfeld) |
449
- | <img src="https://github.com/golya.png?size=72" /> | Ádám Gólya | [@golya](https://github.com/golya) |
450
-
451
- The Font Awesome team:
452
-
453
- | | Name | GitHub |
454
- | :--------------------------------------------------------: | -------------- | -------------------------------------------------- |
455
- | <img src="https://github.com/supercodepoet.png?size=72" /> | Travis Chase | [@supercodepoet](https://github.com/supercodepoet) |
456
- | <img src="https://github.com/robmadole.png?size=72" /> | Rob Madole | [@robmadole](https://github.com/robmadole) |
457
- | <img src="https://github.com/mlwilkerson.png?size=72" /> | Mike Wilkerson | [@mlwilkerson](https://github.com/mlwilkerson) |
458
- | <img src="https://github.com/talbs.png?size=72" /> | Brian Talbot | [@talbs](https://github.com/talbs) |
463
+ | Name | GitHub |
464
+ | ----------------- | --------------------------------------------------------- |
465
+ | Dizy | [@dizy](https://github.com/dizy) |
466
+ | David Martin | [@iamdavidmartin](https://github.com/iamdavidmartin) |
467
+ | Jeremey | [@puremana](https://github.com/puremana) |
468
+ | Michael Schonfeld | [@schonfeld](https://github.com/schonfeld) |
469
+ | Ádám Gólya | [@golya](https://github.com/golya) |
470
+ | Font Awesome Team | [@FortAwesome](https://github.com/orgs/FortAwesome/people)|
@@ -3,8 +3,8 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
+ exports.DEFAULT_SIZE = exports.DEFAULT_SECONDARY_OPACITY = exports.DEFAULT_COLOR = void 0;
6
7
  exports["default"] = FontAwesomeIcon;
7
- exports.DEFAULT_SECONDARY_OPACITY = exports.DEFAULT_COLOR = exports.DEFAULT_SIZE = void 0;
8
8
 
9
9
  var _react = _interopRequireDefault(require("react"));
10
10
 
@@ -18,45 +18,44 @@ var _fontawesomeSvgCore = require("@fortawesome/fontawesome-svg-core");
18
18
 
19
19
  var _logger = _interopRequireDefault(require("../logger"));
20
20
 
21
+ var _excluded = ["color"];
22
+
21
23
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
22
24
 
23
25
  function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
24
26
 
25
27
  function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
26
28
 
27
- 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; }
29
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
28
30
 
29
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; 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)); }); } } return target; }
31
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
30
32
 
31
- function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
33
+ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
32
34
 
33
35
  function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
34
36
 
35
- var _Dimensions$get = _reactNative.Dimensions.get('window'),
36
- windowWidth = _Dimensions$get.width,
37
- windowHeight = _Dimensions$get.height;
38
-
39
37
  var DEFAULT_SIZE = 16;
40
38
  exports.DEFAULT_SIZE = DEFAULT_SIZE;
41
39
  var DEFAULT_COLOR = '#000';
42
40
  exports.DEFAULT_COLOR = DEFAULT_COLOR;
43
- var DEFAULT_SECONDARY_OPACITY = 0.4; // Deprecated height and width defaults
44
-
41
+ var DEFAULT_SECONDARY_OPACITY = 0.4;
45
42
  exports.DEFAULT_SECONDARY_OPACITY = DEFAULT_SECONDARY_OPACITY;
46
- var DEFAULT_HEIGHT = windowHeight * 0.1;
47
- var DEFAULT_WIDTH = windowWidth * 0.1;
48
43
 
49
44
  function objectWithKey(key, value) {
50
45
  return Array.isArray(value) && value.length > 0 || !Array.isArray(value) && value ? _defineProperty({}, key, value) : {};
51
46
  }
52
47
 
53
48
  function normalizeIconArgs(icon) {
54
- if (icon === null) {
55
- return null;
49
+ if (icon && _typeof(icon) === 'object' && icon.prefix && icon.iconName && icon.icon) {
50
+ return icon;
56
51
  }
57
52
 
58
- if (_typeof(icon) === 'object' && icon.prefix && icon.iconName) {
59
- return icon;
53
+ if (_fontawesomeSvgCore.parse.icon) {
54
+ return _fontawesomeSvgCore.parse.icon(icon);
55
+ }
56
+
57
+ if (icon === null) {
58
+ return null;
60
59
  }
61
60
 
62
61
  if (Array.isArray(icon) && icon.length === 2) {
@@ -77,6 +76,7 @@ function normalizeIconArgs(icon) {
77
76
  function FontAwesomeIcon(props) {
78
77
  var iconArgs = props.icon,
79
78
  maskArgs = props.mask,
79
+ maskId = props.maskId,
80
80
  height = props.height,
81
81
  width = props.width,
82
82
  size = props.size;
@@ -86,10 +86,12 @@ function FontAwesomeIcon(props) {
86
86
  var iconLookup = normalizeIconArgs(iconArgs);
87
87
  var transform = objectWithKey('transform', typeof props.transform === 'string' ? _fontawesomeSvgCore.parse.transform(props.transform) : props.transform);
88
88
  var mask = objectWithKey('mask', normalizeIconArgs(maskArgs));
89
- var renderedIcon = (0, _fontawesomeSvgCore.icon)(iconLookup, _objectSpread(_objectSpread({}, transform), mask));
89
+ var renderedIcon = (0, _fontawesomeSvgCore.icon)(iconLookup, _objectSpread(_objectSpread(_objectSpread({}, transform), mask), {}, {
90
+ maskId: maskId
91
+ }));
90
92
 
91
93
  if (!renderedIcon) {
92
- (0, _logger["default"])("ERROR: icon not found for icon = ", iconArgs);
94
+ (0, _logger["default"])('ERROR: icon not found for icon = ', iconArgs);
93
95
  return null;
94
96
  }
95
97
 
@@ -98,44 +100,29 @@ function FontAwesomeIcon(props) {
98
100
  var color = props.color || style.color || DEFAULT_COLOR; // This is the color that will be passed to the "fill" prop of the secondary Path element child (in Duotone Icons)
99
101
  // `null` value will result in using the primary color, at 40% opacity
100
102
 
101
- var secondaryColor = props.secondaryColor || null; // Secondary layer opacity should default to 0.4, unless a specific opacity value or a specific secondary color was given
103
+ var secondaryColor = props.secondaryColor || color; // Secondary layer opacity should default to 0.4, unless a specific opacity value or a specific secondary color was given
102
104
 
103
- var secondaryOpacity = props.secondaryOpacity || (secondaryColor ? 1 : DEFAULT_SECONDARY_OPACITY); // To avoid confusion down the line, we'll remove properties from the StyleSheet, like color, that are being overridden
105
+ var secondaryOpacity = props.secondaryOpacity || DEFAULT_SECONDARY_OPACITY; // To avoid confusion down the line, we'll remove properties from the StyleSheet, like color, that are being overridden
104
106
  // or resolved in other ways, to avoid ambiguity as to which inputs cause which outputs in the underlying rendering process.
105
107
  // In other words, we don't want color (for example) to be specified via two different inputs.
106
108
 
107
109
  var styleColor = style.color,
108
- modifiedStyle = _objectWithoutProperties(style, ["color"]);
110
+ modifiedStyle = _objectWithoutProperties(style, _excluded);
109
111
 
110
112
  var resolvedHeight, resolvedWidth;
111
113
 
112
114
  if (height || width) {
113
- if (size) {
114
- console.warn("DEPRECATION: height and width props on ".concat(FontAwesomeIcon.displayName, " have been deprecated. ") + "Since you've also provided a size prop, we'll use it to override the height and width props given. " + "You should probably go ahead and remove the height and width props to avoid confusion and resolve this warning.");
115
- resolvedHeight = resolvedWidth = size;
116
- } else {
117
- console.warn("DEPRECATION: height and width props on ".concat(FontAwesomeIcon.displayName, " have been deprecated. ") + "Use the size prop instead.");
118
- resolvedHeight = height || DEFAULT_HEIGHT;
119
- resolvedWidth = width || DEFAULT_WIDTH;
120
- }
115
+ throw new Error("Prop height and width for component ".concat(FontAwesomeIcon.displayName, " have been deprecated. ") + "Use the size prop instead like <".concat(FontAwesomeIcon.displayName, " size={").concat(width, "} />."));
121
116
  } else {
122
117
  resolvedHeight = resolvedWidth = size || DEFAULT_SIZE;
123
118
  }
124
119
 
125
- var extraProps = {
126
- height: resolvedHeight,
127
- width: resolvedWidth,
128
- fill: color,
129
- secondaryFill: secondaryColor,
130
- secondaryOpacity: secondaryOpacity,
131
- style: modifiedStyle
132
- };
133
- Object.keys(props).forEach(function (key) {
134
- if (!FontAwesomeIcon.defaultProps.hasOwnProperty(key)) {
135
- extraProps[key] = props[key];
136
- }
137
- });
138
- return convertCurry(_abstract[0], extraProps);
120
+ var rootAttributes = _abstract[0].attributes;
121
+ rootAttributes.height = resolvedHeight;
122
+ rootAttributes.width = resolvedWidth;
123
+ rootAttributes.style = modifiedStyle;
124
+ replaceCurrentColor(_abstract[0], color, secondaryColor, secondaryOpacity);
125
+ return convertCurry(_abstract[0]);
139
126
  }
140
127
 
141
128
  FontAwesomeIcon.displayName = 'FontAwesomeIcon';
@@ -151,20 +138,50 @@ FontAwesomeIcon.propTypes = {
151
138
  }), _propTypes["default"].array]),
152
139
  icon: _propTypes["default"].oneOfType([_propTypes["default"].object, _propTypes["default"].array, _propTypes["default"].string]),
153
140
  mask: _propTypes["default"].oneOfType([_propTypes["default"].object, _propTypes["default"].array, _propTypes["default"].string]),
141
+ maskId: _propTypes["default"].string,
154
142
  transform: _propTypes["default"].oneOfType([_propTypes["default"].string, _propTypes["default"].object])
155
143
  };
156
144
  FontAwesomeIcon.defaultProps = {
157
145
  icon: null,
158
146
  mask: null,
147
+ maskId: null,
159
148
  transform: null,
160
149
  style: {},
161
150
  color: null,
162
151
  secondaryColor: null,
163
152
  secondaryOpacity: null,
164
- height: undefined,
165
- width: undefined // Once the deprecation of height and width props is complete, let's put the real default prop value for size here.
166
- // For now, adding it breaks the default/override logic for height/width/size.
167
-
153
+ size: DEFAULT_SIZE
168
154
  };
169
155
 
170
- var convertCurry = _converter["default"].bind(null, _react["default"].createElement);
156
+ var convertCurry = _converter["default"].bind(null, _react["default"].createElement);
157
+
158
+ function replaceCurrentColor(obj, primaryColor, secondaryColor, secondaryOpacity) {
159
+ obj.children.forEach(function (child, childIndex) {
160
+ replaceFill(child, primaryColor, secondaryColor, secondaryOpacity);
161
+
162
+ if (Object.prototype.hasOwnProperty.call(child, 'attributes')) {
163
+ replaceFill(child.attributes, primaryColor, secondaryColor, secondaryOpacity);
164
+ }
165
+
166
+ if (Array.isArray(child.children) && child.children.length > 0) {
167
+ replaceCurrentColor(child, primaryColor, secondaryColor, secondaryOpacity);
168
+ }
169
+ });
170
+ }
171
+
172
+ function replaceFill(obj, primaryColor, secondaryColor, secondaryOpacity) {
173
+ if (hasPropertySetToValue(obj, 'fill', 'currentColor')) {
174
+ if (hasPropertySetToValue(obj, 'class', 'fa-primary')) {
175
+ obj.fill = primaryColor;
176
+ } else if (hasPropertySetToValue(obj, 'class', 'fa-secondary')) {
177
+ obj.fill = secondaryColor;
178
+ obj.fillOpacity = secondaryOpacity;
179
+ } else {
180
+ obj.fill = primaryColor;
181
+ }
182
+ }
183
+ }
184
+
185
+ function hasPropertySetToValue(obj, property, value) {
186
+ return Object.prototype.hasOwnProperty.call(obj, property) && obj[property] === value;
187
+ }
package/dist/converter.js CHANGED
@@ -11,50 +11,41 @@ var _reactNativeSvg = require("react-native-svg");
11
11
 
12
12
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
13
13
 
14
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
15
+
16
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
17
+
18
+ function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
19
+
14
20
  function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
15
21
 
16
22
  function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
17
23
 
18
24
  function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
19
25
 
20
- function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && Symbol.iterator in Object(iter)) return Array.from(iter); }
26
+ function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
21
27
 
22
28
  function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
23
29
 
24
30
  function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
25
31
 
26
- 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; }
27
-
28
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; 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)); }); } } return target; }
29
-
30
- function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
31
-
32
32
  var svgObjectMap = {
33
- "svg": _reactNativeSvg.Svg,
34
- "path": _reactNativeSvg.Path,
35
- "rect": _reactNativeSvg.Rect,
36
- "defs": _reactNativeSvg.Defs,
37
- "mask": _reactNativeSvg.Mask,
38
- "g": _reactNativeSvg.G,
39
- "clipPath": _reactNativeSvg.ClipPath
33
+ svg: _reactNativeSvg.Svg,
34
+ path: _reactNativeSvg.Path,
35
+ rect: _reactNativeSvg.Rect,
36
+ defs: _reactNativeSvg.Defs,
37
+ mask: _reactNativeSvg.Mask,
38
+ g: _reactNativeSvg.G,
39
+ clipPath: _reactNativeSvg.ClipPath
40
40
  };
41
41
 
42
42
  function convert(createElement, element) {
43
- var extraProps = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
44
-
45
43
  if (typeof element === 'string') {
46
44
  return element;
47
45
  }
48
46
 
49
- var isDuotone = (element.children || []).length === 2;
50
47
  var children = (element.children || []).map(function (child, childIndex) {
51
- var isDuotoneSecondLayer = isDuotone && childIndex === 0;
52
- var fill = isDuotoneSecondLayer ? extraProps.secondaryFill : extraProps.fill;
53
- var fillOpacity = isDuotoneSecondLayer ? extraProps.secondaryOpacity : 1;
54
- return convert(createElement, child, _objectSpread(_objectSpread({}, extraProps), {}, {
55
- fill: fill,
56
- fillOpacity: fillOpacity
57
- }));
48
+ return convert(createElement, child);
58
49
  });
59
50
  var mixins = Object.keys(element.attributes || {}).reduce(function (acc, key) {
60
51
  var val = element.attributes[key];
@@ -62,17 +53,16 @@ function convert(createElement, element) {
62
53
  switch (key) {
63
54
  case 'class':
64
55
  case 'role':
65
- case 'style':
66
56
  case 'xmlns':
67
57
  delete element.attributes[key];
68
58
  break;
69
59
 
70
60
  case 'focusable':
71
- acc.attrs[key] = val === 'true' ? true : false;
61
+ acc.attrs[key] = val === 'true';
72
62
  break;
73
63
 
74
64
  default:
75
- if (key.indexOf('aria-') === 0 || key.indexOf('data-') === 0 || 'fill' === key && 'currentColor' === val) {
65
+ if (key.indexOf('aria-') === 0 || key.indexOf('data-') === 0 || key === 'fill' && val === 'currentColor') {
76
66
  delete element.attributes[key];
77
67
  } else {
78
68
  acc.attrs[_humps["default"].camelize(key)] = val;
@@ -84,7 +74,7 @@ function convert(createElement, element) {
84
74
  }, {
85
75
  attrs: {}
86
76
  });
87
- return createElement.apply(void 0, [svgObjectMap[element.tag], _objectSpread(_objectSpread({}, mixins.attrs), extraProps)].concat(_toConsumableArray(children)));
77
+ return createElement.apply(void 0, [svgObjectMap[element.tag], _objectSpread({}, mixins.attrs)].concat(_toConsumableArray(children)));
88
78
  }
89
79
 
90
80
  var _default = convert;
package/index.d.ts CHANGED
@@ -20,8 +20,10 @@ export interface Props {
20
20
  secondaryColor?: string;
21
21
  secondaryOpacity?: number;
22
22
  mask?: IconProp;
23
+ maskId?: string;
23
24
  transform?: string | Transform;
24
25
  style?: FontAwesomeIconStyle;
26
+ testID?: string;
25
27
  }
26
28
 
27
29
  export function FontAwesomeIcon(props: Props): JSX.Element;
package/package.json CHANGED
@@ -1,11 +1,13 @@
1
1
  {
2
2
  "name": "@fortawesome/react-native-fontawesome",
3
- "version": "0.2.7",
4
- "description": "Official React Native component for Font Awesome 5",
3
+ "version": "0.3.0",
4
+ "description": "Official React Native component for Font Awesome",
5
5
  "main": "index.js",
6
6
  "scripts": {
7
- "test": "jest",
8
- "dist": "babel --config-file ./babel.dist.config.js src --ignore src/components/__tests__ --out-dir dist",
7
+ "test": "jest --forceExit",
8
+ "lint": "eslint src",
9
+ "dist:watch": "babel --watch --config-file ./babel.dist.config.js src --ignore src/components/__tests__ --out-dir dist",
10
+ "dist": "babel --config-file ./babel.dist.config.js src --ignore src/components/__tests__ --ignore src/components/__fixtures__ --out-dir dist",
9
11
  "set.rnsvg": "yarn upgrade react-native-svg@$RNSVG_VERSION"
10
12
  },
11
13
  "types": "index.d.ts",
@@ -22,14 +24,15 @@
22
24
  "David Martin <github.com/iamdavidmartin>",
23
25
  "Jeremy <github.com/puremana>",
24
26
  "Michael Schonfeld <github.com/schonfeld>",
25
- "Ádám Gólya <github.com/golya>"
27
+ "Ádám Gólya <github.com/golya>",
28
+ "Edward Emanuel <github.com/ej2>",
29
+ "Jason Lundien <github.com/jasonlundien>"
26
30
  ],
27
31
  "license": "MIT",
28
32
  "peerDependencies": {
29
- "@fortawesome/fontawesome-svg-core": "^1.2.4",
30
- "react": ">= 16.x",
31
- "react-native": "> 0.57",
32
- "react-native-svg": "> 7.0"
33
+ "@fortawesome/fontawesome-svg-core": "~1 || ~6",
34
+ "react-native": ">= 0.67",
35
+ "react-native-svg": ">= 11.x"
33
36
  },
34
37
  "devDependencies": {
35
38
  "@babel/cli": "^7.7.5",
@@ -37,15 +40,22 @@
37
40
  "@babel/preset-env": "^7.7.6",
38
41
  "@babel/preset-react": "^7.7.4",
39
42
  "@babel/runtime": "^7.7.6",
40
- "@fortawesome/fontawesome-svg-core": "^1.2.26",
43
+ "@fortawesome/fontawesome-svg-core": "^6",
41
44
  "babel-core": "^7.0.0-bridge",
42
45
  "babel-jest": "^24.9.0",
43
- "jest": "^24.9.0",
46
+ "eslint": "^8.16.0",
47
+ "eslint-config-standard": "^17.0.0",
48
+ "eslint-plugin-import": "^2.26.0",
49
+ "eslint-plugin-jest": "^26.2.2",
50
+ "eslint-plugin-n": "^15.2.0",
51
+ "eslint-plugin-promise": "^6.0.0",
52
+ "eslint-plugin-react": "^7.30.0",
53
+ "jest": "^28.1.0",
44
54
  "metro-react-native-babel-preset": "^0.57.0",
45
- "react": "16.9.0",
46
- "react-native": "^0.62.3",
47
- "react-native-svg": "^9.13.6",
48
- "react-test-renderer": "^16.9.0"
55
+ "react": "^17",
56
+ "react-native": "^0.68.0",
57
+ "react-native-svg": "^12.3.0",
58
+ "react-test-renderer": "^17"
49
59
  },
50
60
  "dependencies": {
51
61
  "humps": "^2.0.1",
package/CHANGELOG.md DELETED
@@ -1,108 +0,0 @@
1
- # Change Log
2
-
3
- All notable changes to this project will be documented in this file.
4
-
5
- The format is based on [Keep a Changelog](http://keepachangelog.com/) and this project adheres to [Semantic Versioning](http://semver.org/).
6
-
7
- ---
8
-
9
- ## [0.2.7](https://github.com/FortAwesome/react-native-fontawesome/releases/tag/0.2.7) - 2021-07-22
10
-
11
- ### Changed
12
-
13
- - Dependency updates including support for react-native 0.64 and react 17
14
-
15
- ---
16
-
17
- ## [0.2.6](https://github.com/FortAwesome/react-native-fontawesome/releases/tag/0.2.6) - 2020-10-01
18
-
19
- ### Fixed
20
-
21
- - Removed dependence on React Native for Web's ViewPropTypes #72
22
-
23
- ---
24
-
25
- ## [0.2.5](https://github.com/FortAwesome/react-native-fontawesome/releases/tag/0.2.5) - 2020-05-14
26
-
27
- ### Added
28
-
29
- - Support for Duotone icons #59
30
-
31
- ---
32
-
33
- ## [0.2.4](https://github.com/FortAwesome/react-native-fontawesome/releases/tag/0.2.4) - 2020-04-27
34
-
35
- ### Fixed
36
-
37
- - Loosen peerDependencies versions to allow newer react-native and react-native-svg packages
38
-
39
- ---
40
-
41
- ## [0.2.3](https://github.com/FortAwesome/react-native-fontawesome/releases/tag/0.2.3) - 2020-03-06
42
-
43
- ### Fixed
44
-
45
- - Support arrays in style property #28 #40 #46
46
-
47
- ---
48
-
49
- ## [0.2.2](https://github.com/FortAwesome/react-native-fontawesome/releases/tag/0.2.2) - 2020-02-17
50
-
51
- ### Fixed
52
-
53
- - Add index.d.ts to the package.json files
54
-
55
- ---
56
-
57
- ## [0.2.1](https://github.com/FortAwesome/react-native-fontawesome/releases/tag/0.2.1) - 2020-02-06
58
-
59
- ### Fixed
60
-
61
- - Convert 'focusable' attribute to boolean from string #42
62
-
63
- ## [0.2.0](https://github.com/FortAwesome/react-native-fontawesome/releases/tag/0.2.0) - 2019-12-13
64
-
65
- ### Added
66
-
67
- - TypeScript definition file #17
68
-
69
- ### Changed
70
-
71
- - Loosened peer dependencies to prevent incorrect version warnings
72
-
73
- ## [0.1.0](https://github.com/FortAwesome/react-native-fontawesome/releases/tag/0.1.0) - 2019-01-07
74
-
75
- ### Changed
76
-
77
- - Add color prop
78
- -- Delete color property on style object after resolving the fill color to avoid ambiguity
79
- -- Remove any fill="currentColor" attributes returned by fontawesome-svg-core
80
-
81
- - Add size prop
82
- -- Deprecate height and width props
83
-
84
- ## [0.0.4](https://github.com/FortAwesome/react-native-fontawesome/releases/tag/0.0.4) - 2018-10-13
85
-
86
- ### Changed
87
-
88
- - Internal clean-up, leveraging recent developments in react-native-svg
89
-
90
- ## [0.0.3](https://github.com/FortAwesome/react-native-fontawesome/releases/tag/0.0.3) - 2018-10-11
91
-
92
- ### Added
93
-
94
- - Add support for masking and power transforms
95
-
96
- ## [0.0.2](https://github.com/FortAwesome/react-native-fontawesome/releases/tag/0.0.2) - 2018-10-11
97
-
98
- ### Added
99
-
100
- - Add style prop with initial special-case support for setting icon color
101
-
102
- - Re-initialize example app to allow for using it with `react-native-svg` 7.x
103
-
104
- ## [0.0.1](https://github.com/FortAwesome/react-native-fontawesome/releases/tag/0.0.1) - 2018-10-08
105
-
106
- ### Added
107
-
108
- - Initial, minimal implementation, based on [@fortawesome/react-fontawesome](https://github.com/FortAwesome/react-fontawesome/)