@fortawesome/react-native-fontawesome 0.2.7 → 0.3.1
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 +15 -429
- package/dist/components/FontAwesomeIcon.js +83 -65
- package/dist/converter.js +18 -28
- package/index.d.ts +2 -0
- package/package.json +26 -15
- package/CHANGELOG.md +0 -108
package/README.md
CHANGED
|
@@ -6,453 +6,39 @@
|
|
|
6
6
|
|
|
7
7
|
[](https://www.npmjs.com/package/@fortawesome/react-native-fontawesome)
|
|
8
8
|
|
|
9
|
-
> Font Awesome
|
|
9
|
+
> Font Awesome React Native component using SVG with JS
|
|
10
10
|
|
|
11
11
|
<!-- toc -->
|
|
12
12
|
|
|
13
|
-
- [
|
|
14
|
-
+ [Upgrading Font Awesome?](#upgrading-font-awesome)
|
|
15
|
-
+ [Get started](#get-started)
|
|
16
|
-
+ [Learn about our new SVG implementation](#learn-about-our-new-svg-implementation)
|
|
17
|
-
- [Installation](#installation)
|
|
18
|
-
- [Add more styles or Pro icons](#add-more-styles-or-pro-icons)
|
|
19
|
-
- [or with Yarn](#or-with-yarn)
|
|
20
|
-
- [Usage](#usage)
|
|
21
|
-
* [Explicit Import](#explicit-import)
|
|
22
|
-
* [Build a Library to Reference Icons Throughout Your App More Conveniently](#build-a-library-to-reference-icons-throughout-your-app-more-conveniently)
|
|
23
|
-
* [Color](#color)
|
|
24
|
-
+ [Color Prop](#color-prop)
|
|
25
|
-
+ [Change Color with a StyleSheet](#color-stylesheet-property)
|
|
26
|
-
* [Size](#size)
|
|
27
|
-
- [Features](#features)
|
|
28
|
-
* [Duotone](#duotone)
|
|
29
|
-
* [Masking](#masking)
|
|
30
|
-
* [Power Transforms](#power-transforms)
|
|
31
|
-
- [Frequent questions](#frequent-questions)
|
|
32
|
-
* [How do I import the same icon from two different styles?](#how-do-i-import-the-same-icon-from-two-different-styles)
|
|
33
|
-
* [I don't think tree-shaking is working; got any advice?](#i-dont-think-tree-shaking-is-working-got-any-advice)
|
|
13
|
+
- [Documentation](#documentation)
|
|
34
14
|
- [How to Help](#how-to-help)
|
|
35
15
|
- [Contributors](#contributors)
|
|
36
16
|
|
|
37
17
|
<!-- tocstop -->
|
|
38
18
|
|
|
39
|
-
##
|
|
19
|
+
## Documentation
|
|
40
20
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
#### Upgrading Font Awesome?
|
|
44
|
-
|
|
45
|
-
If you've used Font Awesome in the past (version 4 or older) there are some
|
|
46
|
-
things that you should learn before you dive in.
|
|
47
|
-
|
|
48
|
-
> https://fontawesome.com/how-to-use/on-the-web/setup/upgrading-from-version-4
|
|
49
|
-
|
|
50
|
-
#### Get started
|
|
51
|
-
|
|
52
|
-
This package is for integrating with React Native. If you aren't using React Native then it's
|
|
53
|
-
not going to help you. Head over to our "Get Started" page for some guidance.
|
|
54
|
-
|
|
55
|
-
> https://fontawesome.com/how-to-use/on-the-web/setup/getting-started
|
|
56
|
-
|
|
57
|
-
#### Learn about our new SVG implementation
|
|
58
|
-
|
|
59
|
-
This package, under the hood, uses SVG with JS and the `@fortawesome/fontawesome-svg-core` library. This implementation differs drastically from
|
|
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
|
-
|
|
62
|
-
> https://fontawesome.com/how-to-use/on-the-web/advanced/svg-javascript-core
|
|
63
|
-
|
|
64
|
-
## Installation
|
|
65
|
-
|
|
66
|
-
```
|
|
67
|
-
$ npm i --save react-native-svg # **
|
|
68
|
-
$ npm i --save @fortawesome/fontawesome-svg-core
|
|
69
|
-
$ npm i --save @fortawesome/free-solid-svg-icons
|
|
70
|
-
$ npm i --save @fortawesome/react-native-fontawesome
|
|
71
|
-
```
|
|
72
|
-
|
|
73
|
-
** `create-react-native-app` uses Expo, which bundles `react-native-svg`. So if you're using `create-react-native-app`
|
|
74
|
-
you shouldn't try to add `react-native-svg`. At the time of writing, `create-react-native-app` bundles
|
|
75
|
-
`react-native-svg` version 6, which does not include support for SVG features such as `Mask`. In order to make use of `Mask`, make sure your dependencies have `react-native-svg` 7. The example app in this repo demonstrates.
|
|
76
|
-
|
|
77
|
-
If you are using a bare react-native-cli project, run the following command to complete the setup on iOS.
|
|
78
|
-
|
|
79
|
-
```
|
|
80
|
-
$ cd ios && pod install
|
|
81
|
-
```
|
|
82
|
-
|
|
83
|
-
## Add more styles or Pro icons
|
|
84
|
-
|
|
85
|
-
Brands are separated into their own style and for customers upgrading from
|
|
86
|
-
version 4 to 5 we have a limited number of Regular icons available.
|
|
87
|
-
|
|
88
|
-
**Visit [fontawesome.com/icons](https://fontawesome.com/icons) to search for free and Pro icons**
|
|
89
|
-
|
|
90
|
-
```
|
|
91
|
-
$ npm i --save @fortawesome/free-brands-svg-icons
|
|
92
|
-
$ npm i --save @fortawesome/free-regular-svg-icons
|
|
93
|
-
```
|
|
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).
|
|
96
|
-
|
|
97
|
-
```
|
|
98
|
-
$ npm i --save @fortawesome/pro-solid-svg-icons
|
|
99
|
-
$ npm i --save @fortawesome/pro-regular-svg-icons
|
|
100
|
-
$ npm i --save @fortawesome/pro-light-svg-icons
|
|
101
|
-
```
|
|
102
|
-
|
|
103
|
-
If you'd like to use Duotone icons, you'll need to add Duotone package:
|
|
104
|
-
|
|
105
|
-
```
|
|
106
|
-
$ npm i --save @fortawesome/pro-duotone-svg-icons
|
|
107
|
-
```
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
## or with Yarn
|
|
111
|
-
|
|
112
|
-
```
|
|
113
|
-
$ yarn add @fortawesome/fontawesome-svg-core
|
|
114
|
-
$ yarn add @fortawesome/free-solid-svg-icons
|
|
115
|
-
$ yarn add @fortawesome/react-native-fontawesome
|
|
116
|
-
```
|
|
117
|
-
|
|
118
|
-
## Usage
|
|
119
|
-
|
|
120
|
-
You can use Font Awesome icons in your React Native components as simply as this:
|
|
121
|
-
|
|
122
|
-
```javascript
|
|
123
|
-
<FontAwesomeIcon icon="coffee" />
|
|
124
|
-
```
|
|
125
|
-
|
|
126
|
-
That simple usage is made possible when you add the `"coffee"` icon, to the
|
|
127
|
-
_library_.
|
|
128
|
-
|
|
129
|
-
This is one of the two ways you can use Font Awesome 5 with React Native. We'll
|
|
130
|
-
summarize both ways briefly and then get into the details of each below.
|
|
131
|
-
|
|
132
|
-
1. **Explicit Import**
|
|
133
|
-
|
|
134
|
-
Allows icons to be subsetted, optimizing your final bundle. Only the icons
|
|
135
|
-
you import are included in the bundle. However, explicitly importing icons
|
|
136
|
-
into each of many components in your app might become tedious, so you may
|
|
137
|
-
want to build a library.
|
|
138
|
-
|
|
139
|
-
2. **Build a Library**
|
|
140
|
-
|
|
141
|
-
Explicitly import icons just once in some init module. Then add them to the
|
|
142
|
-
library. Then reference any of them by icon name as a string from any
|
|
143
|
-
component. No need to import the icons into each component once they're in
|
|
144
|
-
the library.
|
|
145
|
-
|
|
146
|
-
### Explicit Import
|
|
147
|
-
|
|
148
|
-
For this example, we'll also reference the `@fortawesome/free-solid-svg-icons`
|
|
149
|
-
module, so make sure you've added it to the project as well:
|
|
150
|
-
|
|
151
|
-
```
|
|
152
|
-
$ npm i --save @fortawesome/free-solid-svg-icons
|
|
153
|
-
```
|
|
154
|
-
|
|
155
|
-
or
|
|
156
|
-
|
|
157
|
-
```
|
|
158
|
-
$ yarn add @fortawesome/free-solid-svg-icons
|
|
159
|
-
```
|
|
160
|
-
|
|
161
|
-
Now, a simple React Native component might look like this:
|
|
162
|
-
|
|
163
|
-
```javascript
|
|
164
|
-
import React, { Component } from 'react'
|
|
165
|
-
import { View } from 'react-native'
|
|
166
|
-
import { FontAwesomeIcon } from '@fortawesome/react-native-fontawesome'
|
|
167
|
-
import { faCoffee } from '@fortawesome/free-solid-svg-icons'
|
|
168
|
-
|
|
169
|
-
type Props = {}
|
|
170
|
-
export default class App extends Component<Props> {
|
|
171
|
-
render() {
|
|
172
|
-
return (
|
|
173
|
-
<View>
|
|
174
|
-
<FontAwesomeIcon icon={ faCoffee } />
|
|
175
|
-
</View>
|
|
176
|
-
)
|
|
177
|
-
}
|
|
178
|
-
}
|
|
179
|
-
```
|
|
180
|
-
|
|
181
|
-
Notice that the `faCoffee` icon is imported from
|
|
182
|
-
`@fortawesome/free-solid-svg-icons` as an object and then provided to the
|
|
183
|
-
`icon` prop as an object.
|
|
184
|
-
|
|
185
|
-
Explicitly importing icons like this allows us to subset Font Awesome's
|
|
186
|
-
thousands of icons to include only those you use in your final bundled file.
|
|
187
|
-
|
|
188
|
-
### Build a Library to Reference Icons Throughout Your App More Conveniently
|
|
189
|
-
|
|
190
|
-
You probably want to use our icons in more than one component in your app,
|
|
191
|
-
right?
|
|
192
|
-
|
|
193
|
-
But with explicit importing, it could become tedious to import into each of
|
|
194
|
-
your app's components every icon you want to reference in that component.
|
|
195
|
-
|
|
196
|
-
So, add them to the _library_. Do this setup once in some initializing module
|
|
197
|
-
of your app, adding all of the icons you'll use in your app's React components.
|
|
198
|
-
|
|
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
|
|
201
|
-
of the brands in `@fortawesome/free-brands-svg-icons`. This example would
|
|
202
|
-
illustrate the benefits of building a library even more clearly if it involved
|
|
203
|
-
fifty or a hundred icons, but we'll keep the example brief and leave it to your
|
|
204
|
-
imagination as to how this might scale up with lots of icons.
|
|
205
|
-
|
|
206
|
-
Don't forget to add `@fortawesome/free-brands-svg-icons`:
|
|
207
|
-
|
|
208
|
-
```
|
|
209
|
-
$ npm i --save @fortawesome/free-brands-svg-icons
|
|
210
|
-
```
|
|
211
|
-
|
|
212
|
-
or
|
|
213
|
-
|
|
214
|
-
```
|
|
215
|
-
$ yarn add @fortawesome/free-brands-svg-icons
|
|
216
|
-
```
|
|
217
|
-
|
|
218
|
-
In `App.js`, where our app is initialized:
|
|
219
|
-
|
|
220
|
-
```javascript
|
|
221
|
-
// ...
|
|
222
|
-
import { library } from '@fortawesome/fontawesome-svg-core'
|
|
223
|
-
import { fab } from '@fortawesome/free-brands-svg-icons'
|
|
224
|
-
import { faCheckSquare, faCoffee } from '@fortawesome/free-solid-svg-icons'
|
|
225
|
-
|
|
226
|
-
library.add(fab, faCheckSquare, faCoffee)
|
|
227
|
-
```
|
|
228
|
-
|
|
229
|
-
OK, so what's happening here?
|
|
230
|
-
|
|
231
|
-
In our call to <span style="white-space:nowrap;">`library.add()`</span> we're passing
|
|
232
|
-
|
|
233
|
-
- `fab`: which represents _all_ of the brand icons in
|
|
234
|
-
<span style="white-space:nowrap;">`@fortawesome/free-brands-svg-icons`</span>.
|
|
235
|
-
So any of the brand icons in that package may be referenced by icon name
|
|
236
|
-
as a string anywhere else in our app.
|
|
237
|
-
For example: `"apple"`, `"microsoft"`, or `"google"`.
|
|
238
|
-
- `faCheckSquare` and `faCoffee`: Adding each of these icons individually
|
|
239
|
-
allows us to refer to them throughout our app by their icon string names,
|
|
240
|
-
`"check-square"` and `"coffee"`, respectively.
|
|
241
|
-
|
|
242
|
-
Now, suppose you also have React Native components `Beverage` and `Gadget` in your app.
|
|
243
|
-
You don't have to re-import your icons into them. Just import the `FontAwesomeIcon`
|
|
244
|
-
component, and when you use it, supply the icon prop an icon name as a string.
|
|
245
|
-
|
|
246
|
-
We'll make `Beverage.js` a functional component:
|
|
247
|
-
|
|
248
|
-
```javascript
|
|
249
|
-
import React from 'react'
|
|
250
|
-
import { View, Text } from 'react-native'
|
|
251
|
-
import { FontAwesomeIcon } from '@fortawesome/react-native-fontawesome'
|
|
252
|
-
|
|
253
|
-
export const Beverage = () => (
|
|
254
|
-
<View>
|
|
255
|
-
<FontAwesomeIcon icon="check-square" />
|
|
256
|
-
<Text>Favorite beverage: </Text><FontAwesomeIcon icon="coffee" />
|
|
257
|
-
</View>
|
|
258
|
-
)
|
|
259
|
-
```
|
|
260
|
-
|
|
261
|
-
There's one another piece of magic that's happening in the background when
|
|
262
|
-
providing icon names as strings like this: the `fas` prefix (for Font Awesome
|
|
263
|
-
Solid) is being inferred as the default. Later, we'll look at what that means
|
|
264
|
-
and how we can do something different than the default.
|
|
265
|
-
|
|
266
|
-
Now suppose `Gadget.js` looks like this:
|
|
267
|
-
|
|
268
|
-
```javascript
|
|
269
|
-
import React from 'react'
|
|
270
|
-
import { View, Text } from 'react-native'
|
|
271
|
-
import { FontAwesomeIcon } from '@fortawesome/react-native-fontawesome'
|
|
272
|
-
|
|
273
|
-
export const Gadget = () => (
|
|
274
|
-
<View>
|
|
275
|
-
<FontAwesomeIcon icon="check-square" />
|
|
276
|
-
<Text>Popular gadgets come from vendors like:</Text>
|
|
277
|
-
<FontAwesomeIcon icon={['fab', 'apple']} />
|
|
278
|
-
<FontAwesomeIcon icon={['fab', 'microsoft']} />
|
|
279
|
-
<FontAwesomeIcon icon={['fab', 'google']} />
|
|
280
|
-
</View>
|
|
281
|
-
)
|
|
282
|
-
```
|
|
283
|
-
|
|
284
|
-
Notice:
|
|
285
|
-
|
|
286
|
-
- We used the `"check-square"` icon name again in this component, though we
|
|
287
|
-
didn't have to explicitly import it into this component. With one explicit import of
|
|
288
|
-
that icon in `App.js`, and adding it to the library, we've managed to use
|
|
289
|
-
it by name in multiple components.
|
|
290
|
-
- We used the `"apple"`, `"microsoft"`, and `"google"` brand icons, which were
|
|
291
|
-
never explicitly _individually_ imported, but they're available to us by
|
|
292
|
-
name as strings because `fab` was added to our library in `App.js`, and
|
|
293
|
-
`fab` includes all of those icons.
|
|
294
|
-
- We added the `fab` prefix to reference those brand icons.
|
|
295
|
-
|
|
296
|
-
Adding a prefix—and the syntax we used to do it—are new. So what's
|
|
297
|
-
going on here?
|
|
298
|
-
|
|
299
|
-
First, recall when we introduced `<FontAwesomeIcon icon="coffee"/>` and learned
|
|
300
|
-
that a prefix of `fas` was being added to `"coffee"` by default.
|
|
301
|
-
|
|
302
|
-
The `"check-square"` icon is getting a default prefix of `fas` here too, which
|
|
303
|
-
is what we want, because that icon also lives in the
|
|
304
|
-
`@fortawesome/free-solid-svg-icons` package.
|
|
305
|
-
|
|
306
|
-
However, the `"apple"`, `"microsoft"`, and `"google"` brand icons live in the
|
|
307
|
-
package `@fortawesome/free-brands-svg-icons`. So we need to specify a
|
|
308
|
-
different prefix for them—not the default `fas`, but `fab`, for Font Awesome
|
|
309
|
-
_Brand_.
|
|
310
|
-
|
|
311
|
-
When specifying a prefix with an icon name, both are given as strings.
|
|
312
|
-
|
|
313
|
-
Now, what about that syntax?
|
|
314
|
-
|
|
315
|
-
The `icon` prop expects a single object:
|
|
316
|
-
|
|
317
|
-
- It could be an icon object, like `{faCoffee}`.
|
|
318
|
-
- It could a string object, like `"coffee"`.
|
|
319
|
-
(The curly braces around a string object supplied to a prop are optional,
|
|
320
|
-
so we've omitted them.)
|
|
321
|
-
- Or it could be an `Array` of strings, where the first element is a prefix,
|
|
322
|
-
and the second element is the icon name: `{["fab", "apple"]}`
|
|
323
|
-
|
|
324
|
-
### Color
|
|
325
|
-
|
|
326
|
-
Priority: The color prop takes priority over setting color via StyleSheet. So if you end up with both set,
|
|
327
|
-
the prop wins.
|
|
328
|
-
|
|
329
|
-
In fact, when provided a style object (suppose you've declared other style properties other
|
|
330
|
-
than `color`), if the color prop has been specified, then any color property on the style object is removed
|
|
331
|
-
before the style object is passed through to the underlying SVG rendering library. This is to avoid ambiguity.
|
|
332
|
-
|
|
333
|
-
Using the color prop should be preferred over using the StyleSheet.
|
|
334
|
-
|
|
335
|
-
#### Color Prop
|
|
336
|
-
|
|
337
|
-
```javascript
|
|
338
|
-
<FontAwesomeIcon icon={ faCoffee } color={ 'red' } />
|
|
339
|
-
```
|
|
340
|
-
|
|
341
|
-
#### Color StyleSheet property
|
|
342
|
-
|
|
343
|
-
To set the color of an icon, provide a `StyleSheet` like this:
|
|
344
|
-
|
|
345
|
-
```javascript
|
|
346
|
-
import React, { Component } from 'react'
|
|
347
|
-
import { View, StyleSheet } from 'react-native'
|
|
348
|
-
import { FontAwesomeIcon } from '@fortawesome/react-native-fontawesome'
|
|
349
|
-
import { faCoffee } from '@fortawesome/free-solid-svg-icons'
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
type Props = {}
|
|
353
|
-
|
|
354
|
-
const style = StyleSheet.create({
|
|
355
|
-
icon: {
|
|
356
|
-
color: 'blue'
|
|
357
|
-
}
|
|
358
|
-
})
|
|
359
|
-
|
|
360
|
-
export default class App extends Component<Props> {
|
|
361
|
-
render() {
|
|
362
|
-
return (
|
|
363
|
-
<View>
|
|
364
|
-
<FontAwesomeIcon icon={ faCoffee } style={ style.icon } />
|
|
365
|
-
</View>
|
|
366
|
-
)
|
|
367
|
-
}
|
|
368
|
-
}
|
|
369
|
-
```
|
|
370
|
-
|
|
371
|
-
### Size
|
|
372
|
-
|
|
373
|
-
Default: 16
|
|
374
|
-
|
|
375
|
-
To adjust the size, use the `size` prop:
|
|
376
|
-
|
|
377
|
-
```javascript
|
|
378
|
-
<FontAwesomeIcon icon={ faCoffee } size={ 32 } />
|
|
379
|
-
```
|
|
380
|
-
|
|
381
|
-
Note: the `height` and `width` props have been deprecated.
|
|
382
|
-
|
|
383
|
-
## Features
|
|
384
|
-
|
|
385
|
-
### Duotone
|
|
386
|
-
|
|
387
|
-
```javascript
|
|
388
|
-
<FontAwesomeIcon icon="coffee" color="blue" secondaryColor="red" secondaryOpacity={ 0.4 } />
|
|
389
|
-
```
|
|
390
|
-
|
|
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.
|
|
392
|
-
|
|
393
|
-
### Masking
|
|
394
|
-
|
|
395
|
-
```javascript
|
|
396
|
-
<FontAwesomeIcon icon="coffee" mask={['far', 'circle']} />
|
|
397
|
-
```
|
|
398
|
-
|
|
399
|
-
[More on masking...](https://fontawesome.com/how-to-use/on-the-web/styling/masking)
|
|
400
|
-
|
|
401
|
-
### Power Transforms
|
|
402
|
-
|
|
403
|
-
```javascript
|
|
404
|
-
<FontAwesomeIcon icon="arrows" transform="shrink-6 left-4" />
|
|
405
|
-
<FontAwesomeIcon icon="arrow-rightr" transform={{ rotate: 42 }} />
|
|
406
|
-
```
|
|
407
|
-
|
|
408
|
-
[More on power transforms...](https://fontawesome.com/how-to-use/on-the-web/styling/power-transforms)
|
|
409
|
-
|
|
410
|
-
## Frequent questions
|
|
411
|
-
|
|
412
|
-
### How do I import the same icon from two different styles?
|
|
413
|
-
|
|
414
|
-
With ES modules and `import` statements we can rename:
|
|
415
|
-
|
|
416
|
-
```javascript
|
|
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'
|
|
420
|
-
|
|
421
|
-
library.add(fasFaStroopwafel, farFaStroopwafel)
|
|
422
|
-
```
|
|
423
|
-
|
|
424
|
-
### I don't think tree-shaking is working; got any advice?
|
|
425
|
-
|
|
426
|
-
Check out our [docs here](https://fontawesome.com/how-to-use/with-the-api/other/tree-shaking).
|
|
21
|
+
Official documentation is hosted at fontawesome.com: [Check it out here](https://fontawesome.com/docs/web/use-with/react-native/)
|
|
427
22
|
|
|
428
23
|
## How to Help
|
|
429
24
|
|
|
430
|
-
Review the following docs before diving in:
|
|
25
|
+
1. Review the following docs before diving in:
|
|
431
26
|
|
|
432
27
|
- [CONTRIBUTING.md](CONTRIBUTING.md)
|
|
433
28
|
- [CODE_OF_CONDUCT.md](CODE_OF_CONDUCT.md)
|
|
434
29
|
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
1. Check the existing issues and see if you can help!
|
|
30
|
+
2. Check the existing issues and see if you can help!
|
|
438
31
|
|
|
439
32
|
## Contributors
|
|
440
33
|
|
|
441
34
|
Community:
|
|
442
35
|
|
|
443
|
-
|
|
|
444
|
-
|
|
|
445
|
-
|
|
|
446
|
-
|
|
|
447
|
-
|
|
|
448
|
-
|
|
|
449
|
-
|
|
|
450
|
-
|
|
451
|
-
|
|
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) |
|
|
36
|
+
| Name | GitHub |
|
|
37
|
+
| ----------------- | --------------------------------------------------------- |
|
|
38
|
+
| Dizy | [@dizy](https://github.com/dizy) |
|
|
39
|
+
| David Martin | [@iamdavidmartin](https://github.com/iamdavidmartin) |
|
|
40
|
+
| Jeremey | [@puremana](https://github.com/puremana) |
|
|
41
|
+
| Michael Schonfeld | [@schonfeld](https://github.com/schonfeld) |
|
|
42
|
+
| Ádám Gólya | [@golya](https://github.com/golya) |
|
|
43
|
+
| Greg Marut | [@gregmarut](https://github.com/gregmarut) |
|
|
44
|
+
| 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);
|
|
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]
|
|
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";
|
|
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;
|
|
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 ===
|
|
55
|
-
return
|
|
49
|
+
if (icon && _typeof(icon) === 'object' && icon.prefix && icon.iconName && icon.icon) {
|
|
50
|
+
return icon;
|
|
56
51
|
}
|
|
57
52
|
|
|
58
|
-
if (
|
|
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) {
|
|
@@ -75,67 +74,67 @@ function normalizeIconArgs(icon) {
|
|
|
75
74
|
}
|
|
76
75
|
|
|
77
76
|
function FontAwesomeIcon(props) {
|
|
78
|
-
var
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
77
|
+
var _props = _objectSpread({
|
|
78
|
+
icon: null,
|
|
79
|
+
mask: null,
|
|
80
|
+
maskId: null,
|
|
81
|
+
transform: null,
|
|
82
|
+
style: {},
|
|
83
|
+
color: null,
|
|
84
|
+
secondaryColor: null,
|
|
85
|
+
secondaryOpacity: null,
|
|
86
|
+
size: DEFAULT_SIZE
|
|
87
|
+
}, props);
|
|
88
|
+
|
|
89
|
+
var iconArgs = _props.icon,
|
|
90
|
+
maskArgs = _props.mask,
|
|
91
|
+
maskId = _props.maskId,
|
|
92
|
+
height = _props.height,
|
|
93
|
+
width = _props.width,
|
|
94
|
+
size = _props.size;
|
|
95
|
+
|
|
96
|
+
var style = _reactNative.StyleSheet.flatten(_props.style);
|
|
85
97
|
|
|
86
98
|
var iconLookup = normalizeIconArgs(iconArgs);
|
|
87
|
-
var transform = objectWithKey('transform', typeof
|
|
99
|
+
var transform = objectWithKey('transform', typeof _props.transform === 'string' ? _fontawesomeSvgCore.parse.transform(_props.transform) : _props.transform);
|
|
88
100
|
var mask = objectWithKey('mask', normalizeIconArgs(maskArgs));
|
|
89
|
-
var renderedIcon = (0, _fontawesomeSvgCore.icon)(iconLookup, _objectSpread(_objectSpread({}, transform), mask)
|
|
101
|
+
var renderedIcon = (0, _fontawesomeSvgCore.icon)(iconLookup, _objectSpread(_objectSpread(_objectSpread({}, transform), mask), {}, {
|
|
102
|
+
maskId: maskId
|
|
103
|
+
}));
|
|
90
104
|
|
|
91
105
|
if (!renderedIcon) {
|
|
92
|
-
(0, _logger["default"])(
|
|
106
|
+
(0, _logger["default"])('ERROR: icon not found for icon = ', iconArgs);
|
|
93
107
|
return null;
|
|
94
108
|
}
|
|
95
109
|
|
|
96
110
|
var _abstract = renderedIcon["abstract"]; // This is the color that will be passed to the "fill" prop of the Svg element
|
|
97
111
|
|
|
98
|
-
var color =
|
|
112
|
+
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
113
|
// `null` value will result in using the primary color, at 40% opacity
|
|
100
114
|
|
|
101
|
-
var secondaryColor =
|
|
115
|
+
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
116
|
|
|
103
|
-
var secondaryOpacity =
|
|
117
|
+
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
118
|
// or resolved in other ways, to avoid ambiguity as to which inputs cause which outputs in the underlying rendering process.
|
|
105
119
|
// In other words, we don't want color (for example) to be specified via two different inputs.
|
|
106
120
|
|
|
107
121
|
var styleColor = style.color,
|
|
108
|
-
modifiedStyle = _objectWithoutProperties(style,
|
|
122
|
+
modifiedStyle = _objectWithoutProperties(style, _excluded);
|
|
109
123
|
|
|
110
124
|
var resolvedHeight, resolvedWidth;
|
|
111
125
|
|
|
112
126
|
if (height || width) {
|
|
113
|
-
|
|
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
|
-
}
|
|
127
|
+
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
128
|
} else {
|
|
122
129
|
resolvedHeight = resolvedWidth = size || DEFAULT_SIZE;
|
|
123
130
|
}
|
|
124
131
|
|
|
125
|
-
var
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
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);
|
|
132
|
+
var rootAttributes = _abstract[0].attributes;
|
|
133
|
+
rootAttributes.height = resolvedHeight;
|
|
134
|
+
rootAttributes.width = resolvedWidth;
|
|
135
|
+
rootAttributes.style = modifiedStyle;
|
|
136
|
+
replaceCurrentColor(_abstract[0], color, secondaryColor, secondaryOpacity);
|
|
137
|
+
return convertCurry(_abstract[0]);
|
|
139
138
|
}
|
|
140
139
|
|
|
141
140
|
FontAwesomeIcon.displayName = 'FontAwesomeIcon';
|
|
@@ -151,20 +150,39 @@ FontAwesomeIcon.propTypes = {
|
|
|
151
150
|
}), _propTypes["default"].array]),
|
|
152
151
|
icon: _propTypes["default"].oneOfType([_propTypes["default"].object, _propTypes["default"].array, _propTypes["default"].string]),
|
|
153
152
|
mask: _propTypes["default"].oneOfType([_propTypes["default"].object, _propTypes["default"].array, _propTypes["default"].string]),
|
|
153
|
+
maskId: _propTypes["default"].string,
|
|
154
154
|
transform: _propTypes["default"].oneOfType([_propTypes["default"].string, _propTypes["default"].object])
|
|
155
155
|
};
|
|
156
|
-
FontAwesomeIcon.defaultProps = {
|
|
157
|
-
icon: null,
|
|
158
|
-
mask: null,
|
|
159
|
-
transform: null,
|
|
160
|
-
style: {},
|
|
161
|
-
color: null,
|
|
162
|
-
secondaryColor: null,
|
|
163
|
-
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
156
|
|
|
168
|
-
|
|
157
|
+
var convertCurry = _converter["default"].bind(null, _react["default"].createElement);
|
|
158
|
+
|
|
159
|
+
function replaceCurrentColor(obj, primaryColor, secondaryColor, secondaryOpacity) {
|
|
160
|
+
obj.children.forEach(function (child, childIndex) {
|
|
161
|
+
replaceFill(child, primaryColor, secondaryColor, secondaryOpacity);
|
|
162
|
+
|
|
163
|
+
if (Object.prototype.hasOwnProperty.call(child, 'attributes')) {
|
|
164
|
+
replaceFill(child.attributes, primaryColor, secondaryColor, secondaryOpacity);
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
if (Array.isArray(child.children) && child.children.length > 0) {
|
|
168
|
+
replaceCurrentColor(child, primaryColor, secondaryColor, secondaryOpacity);
|
|
169
|
+
}
|
|
170
|
+
});
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
function replaceFill(obj, primaryColor, secondaryColor, secondaryOpacity) {
|
|
174
|
+
if (hasPropertySetToValue(obj, 'fill', 'currentColor')) {
|
|
175
|
+
if (hasPropertySetToValue(obj, 'class', 'fa-primary')) {
|
|
176
|
+
obj.fill = primaryColor;
|
|
177
|
+
} else if (hasPropertySetToValue(obj, 'class', 'fa-secondary')) {
|
|
178
|
+
obj.fill = secondaryColor;
|
|
179
|
+
obj.fillOpacity = secondaryOpacity;
|
|
180
|
+
} else {
|
|
181
|
+
obj.fill = primaryColor;
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
}
|
|
169
185
|
|
|
170
|
-
|
|
186
|
+
function hasPropertySetToValue(obj, property, value) {
|
|
187
|
+
return Object.prototype.hasOwnProperty.call(obj, property) && obj[property] === value;
|
|
188
|
+
}
|
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
|
|
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
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
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
|
-
|
|
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'
|
|
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'
|
|
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(
|
|
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.
|
|
4
|
-
"description": "Official React Native component for Font Awesome
|
|
3
|
+
"version": "0.3.1",
|
|
4
|
+
"description": "Official React Native component for Font Awesome",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
7
|
-
"test": "jest",
|
|
8
|
-
"
|
|
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,16 @@
|
|
|
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>",
|
|
30
|
+
"Greg Marut <github.com/gregmarut>"
|
|
26
31
|
],
|
|
27
32
|
"license": "MIT",
|
|
28
33
|
"peerDependencies": {
|
|
29
|
-
"@fortawesome/fontawesome-svg-core": "
|
|
30
|
-
"react": ">=
|
|
31
|
-
"react-native": "
|
|
32
|
-
"react-native-svg": "> 7.0"
|
|
34
|
+
"@fortawesome/fontawesome-svg-core": "~1 || ~6",
|
|
35
|
+
"react-native": ">= 0.67",
|
|
36
|
+
"react-native-svg": ">= 11.x"
|
|
33
37
|
},
|
|
34
38
|
"devDependencies": {
|
|
35
39
|
"@babel/cli": "^7.7.5",
|
|
@@ -37,15 +41,22 @@
|
|
|
37
41
|
"@babel/preset-env": "^7.7.6",
|
|
38
42
|
"@babel/preset-react": "^7.7.4",
|
|
39
43
|
"@babel/runtime": "^7.7.6",
|
|
40
|
-
"@fortawesome/fontawesome-svg-core": "^
|
|
44
|
+
"@fortawesome/fontawesome-svg-core": "^6",
|
|
41
45
|
"babel-core": "^7.0.0-bridge",
|
|
42
46
|
"babel-jest": "^24.9.0",
|
|
43
|
-
"
|
|
47
|
+
"eslint": "^8.16.0",
|
|
48
|
+
"eslint-config-standard": "^17.0.0",
|
|
49
|
+
"eslint-plugin-import": "^2.26.0",
|
|
50
|
+
"eslint-plugin-jest": "^26.2.2",
|
|
51
|
+
"eslint-plugin-n": "^15.2.0",
|
|
52
|
+
"eslint-plugin-promise": "^6.0.0",
|
|
53
|
+
"eslint-plugin-react": "^7.30.0",
|
|
54
|
+
"jest": "^28.1.0",
|
|
44
55
|
"metro-react-native-babel-preset": "^0.57.0",
|
|
45
|
-
"react": "
|
|
46
|
-
"react-native": "^0.
|
|
47
|
-
"react-native-svg": "^
|
|
48
|
-
"react-test-renderer": "^
|
|
56
|
+
"react": "^17",
|
|
57
|
+
"react-native": "^0.68.0",
|
|
58
|
+
"react-native-svg": "^12.3.0",
|
|
59
|
+
"react-test-renderer": "^17"
|
|
49
60
|
},
|
|
50
61
|
"dependencies": {
|
|
51
62
|
"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/)
|