@react-native-vector-icons/common 0.0.1-alpha.2 → 0.0.1-alpha.4

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.
Files changed (2) hide show
  1. package/README.md +306 -0
  2. package/package.json +4 -5
package/README.md ADDED
@@ -0,0 +1,306 @@
1
+ ![Vector Icons for React Native](https://cloud.githubusercontent.com/assets/378279/12009887/33f4ae1c-ac8d-11e5-8666-7a87458753ee.png)
2
+
3
+ [![Travis](https://img.shields.io/travis/react-native-vector-icons/react-native-vector-icons.svg)](https://travis-ci.org/react-native-vector-icons/react-native-vector-icons) [![npm](https://img.shields.io/npm/v/react-native-vector-icons.svg)](https://npmjs.com/package/react-native-vector-icons) [![npm](https://img.shields.io/npm/dm/react-native-vector-icons.svg)](https://npmjs.com/package/react-native-vector-icons)
4
+
5
+ # React Native Vector Icons
6
+
7
+ Elevate your React Native applications with the power of customizable vector
8
+ icons. Ideal for embellishing buttons, logos, and navigation or tab bars, these
9
+ icons seamlessly integrate into your projects. Their versatility makes
10
+ extension and styling effortless.
11
+
12
+ For the integration of `.svg` files natively, you can explore [`react-native-vector-image`](https://github.com/oblador/react-native-vector-image).
13
+
14
+ ## Table of Contents
15
+
16
+ - [Sponsorship](#sponsorship)
17
+ - [Available Icon Sets](#available-icon-sets)
18
+ - [Installation](#installation)
19
+ - [iOS Setup](#ios-setup)
20
+ - [macOS Setup](#macos-setup)
21
+ - [Windows Setup](#windows-setup)
22
+ - [Web Setup](#web-setup)
23
+ - [Icon Component](#icon-component)
24
+ - [Usage as PNG Image/Source Object](#usage-as-png-imagesource-object)
25
+ - [Multi-Style Fonts](#multi-style-fonts)
26
+ - [Custom Fonts](#custom-fonts)
27
+ - [Animation](#animation)
28
+ - [Usage Examples](#usage-examples)
29
+ - [Generating Your Own Icon Package](#generating-your-own-icon-package)
30
+ - [Changelog](https://github.com/react-native-vector-icons/react-native-vector-icons/releases)
31
+ - [License](#license)
32
+
33
+ ## Sponsorship
34
+
35
+ Should you find this library beneficial, kindly contemplate the option of
36
+ [sponsoring](https://github.com/sponsors/oblador). Our envisioned endeavors
37
+ encompass the restructuring of the repository into a monorepo architecture.
38
+ This transition will empower independent versioning of icon sets, enhance
39
+ performance, reduce bundle size, and simplify community contributions. Your
40
+ sponsorship plays a pivotal role in materializing these advancements.
41
+
42
+ ## Available Icon Sets
43
+
44
+ [Explore all icons](https://react-native-vector-icons.github.io/react-native-vector-icons/).
45
+
46
+ RNVI comes with the following supported icons. You can [search NPM](https://www.npmjs.com/search?q=keywords%3Areact-native-vector-icons-icon) for third party icons.
47
+
48
+ - [`AntDesign`](https://ant.design/components/icon) from Ant Group (v4.3.1 with _421_ icons)
49
+ - [`Entypo`](http://entypo.com) by Daniel Bruce (v1.0.1 with _411_ icons)
50
+ - [`EvilIcons`](http://evil-icons.io) designed by Alexander Madyankin & Roman Shamin (v1.10.1 with _70_ icons)
51
+ - [`Feather`](http://feathericons.com) created by Cole Bemis & Contributors (v4.29.1 featuring _287_ icons)
52
+ - [`FontAwesome`](https://fontawesome.com/v4/icons) by Fonticons, Inc. (v4.7.0 containing _785_ icons)
53
+ - [`FontAwesome 5`](https://fontawesome.com/v5/search) from Fonticons, Inc. (v5.15.4 offering _1608_ free and _7864_ pro icons)
54
+ - [`FontAwesome 6`](https://fontawesome.com) designed by Fonticons, Inc. (v6.5.1 featuring _2037_ free and _30013_ pro icons)
55
+ - [`Fontisto`](https://github.com/kenangundogan/fontisto) created by Kenan Gündoğan (v3.0.4 featuring _617_ icons)
56
+ - [`Foundation`](http://zurb.com/playground/foundation-icon-fonts-3) by ZURB, Inc. (v3.0 with _283_ icons)
57
+ - [`Ionicons`](https://ionic.io/ionicons) crafted by Ionic (v7.2.2 containing _1338_ icons)
58
+ - [`MaterialIcons`](https://fonts.google.com/icons?icon.set=Material+Icons) by Google, Inc. (v4.0.0 featuring _2234_ icons)
59
+ - [`MaterialCommunityIcons`](https://pictogrammers.com/library/mdi/) from MaterialDesignIcons.com (v7.4.47 including _7447_ icons)
60
+ - [`Octicons`](https://primer.style/foundations/icons) designed by Github, Inc. (v19.8.0 with _320_ icons)
61
+ - [`SimpleLineIcons`](https://simplelineicons.github.io/) crafted by Sabbir & Contributors (v2.5.5 with _189_ icons)
62
+ - [`Zocial`](https://smcllns.github.io/css-social-buttons) by Sam Collins (v1.1.1 with _100_ icons)
63
+
64
+ ## Migration
65
+
66
+ See [MIGRATION.md](./MIGRATION.md) if you are migrating from `react-native-vector-icons`
67
+
68
+ ## Installation
69
+
70
+ 1. Install the common package
71
+ ```sh
72
+ npm install --save @react-native-vector-icons/common
73
+ ```
74
+ 1. Install the packages for the icons you want use
75
+ ```sh
76
+ npm install --save @react-native-vector-icons/fontawesome6 @react-native-vector-icons/evilicons
77
+ ```
78
+ 1. Depending on the platform you're targeting (iOS/Android/Windows), follow the appropriate setup instructions.
79
+ 1. If you are using one of the following fonts refer to their guides for further instructions
80
+ * [FontAwesome 5](packages/fontawesome5/README.md)
81
+ * [FontAwesome 5 Pro](packages/fontawesome5-pro/README.md)
82
+ * [FontAwesome 6](packages/fontawesome6/README.md)
83
+ * [FontAwesome 6 Pro](packages/fontawesome6-pro/README.md)
84
+ * [Fontello](packages/fontello/README.md)
85
+
86
+ ### iOS Setup
87
+
88
+ To use the bundled icons on iOS, follow these steps:
89
+
90
+ 1. Update your pods
91
+ ```sh
92
+ cd ios && pod update
93
+ ```
94
+
95
+ ### macOS Setup
96
+
97
+ TBA: It should just work???
98
+
99
+ ### Windows Setup
100
+
101
+ TBA: It should just work???
102
+
103
+ ### Web Setup
104
+
105
+ FIXME: Can we improve on this?
106
+
107
+ To integrate the library with your web project using [webpack](https://webpack.js.org/), follow these steps:
108
+
109
+ 1. In your webpack configuration file, add a section to handle TTF files using `url-loader` or `file-loader`:
110
+
111
+ ```js
112
+ {
113
+ test: /\.ttf$/,
114
+ loader: "url-loader", // or directly file-loader
115
+ include: path.resolve(__dirname, "node_modules/react-native-vector-icons"),
116
+ }
117
+ ```
118
+
119
+ 2. In your JavaScript entry point, consume the font files and inject the necessary style tag:
120
+
121
+ ```js
122
+ import Icon from '@react-native-vector-icons/fontAwesome';
123
+
124
+ // Generate the required CSS
125
+ import iconFont from '@react-native-vector-icons/fontawesome/fonts/FontAwesome.ttf';
126
+ const iconFontStyles = `@font-face {
127
+ src: url(${iconFont});
128
+ font-family: FontAwesome;
129
+ }`;
130
+
131
+ // Create a stylesheet
132
+ const style = document.createElement('style');
133
+ style.type = 'text/css';
134
+
135
+ // Append the iconFontStyles to the stylesheet
136
+ if (style.styleSheet) {
137
+ style.styleSheet.cssText = iconFontStyles;
138
+ } else {
139
+ style.appendChild(document.createTextNode(iconFontStyles));
140
+ }
141
+
142
+ // Inject the stylesheet into the document head
143
+ document.head.appendChild(style);
144
+ ```
145
+
146
+ By following these steps, you will seamlessly integrate the vector icons
147
+ library into your web project using [webpack](https://webpack.js.org/),
148
+ enabling you to effortlessly use the icons within your web application.
149
+
150
+ ## `Icon` Component
151
+
152
+ You can either use one of the bundled icons above or roll your own custom font.
153
+
154
+ ```js
155
+ import Icon from '@react-native-vector-icons/fontawesome';
156
+ const myIcon = <Icon name="rocket" size={30} color="#900" />;
157
+ ```
158
+
159
+ ### Properties
160
+
161
+ Any [Text property](https://reactnative.dev/docs/text.html) and the following:
162
+
163
+ | Prop | Description | Default |
164
+ | ----------- | ----------------------------------------------------------------------- | ----------- |
165
+ | **`size`** | Size of the icon, can also be passed as `fontSize` in the style object. | `12` |
166
+ | **`name`** | What icon to show, see Icon Explorer app or one of the links above. | _None_ |
167
+ | **`color`** | Color of the icon. | _Inherited_ |
168
+
169
+ ### Static Methods
170
+
171
+ | Prop | Description |
172
+ | ------------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
173
+ | **`getImageSource`** | Returns a promise that resolving to the source of a bitmap version of the icon for use with `Image` component et al. Usage: `const source = await Icon.getImageSource(name, size, color)` |
174
+ | **`getImageSourceSync`** | Same as `getImageSource` but synchronous. Usage: `const source = Icon.getImageSourceSync(name, size, color)` |
175
+
176
+ ### Styling
177
+
178
+ Since `Icon` builds on top of the `Text` component, most [style properties](https://reactnative.dev/docs/style.html) will work as expected, you might find it useful to play around with these:
179
+
180
+ - `backgroundColor`
181
+ - `borderWidth`
182
+ - `borderColor`
183
+ - `borderRadius`
184
+ - `padding`
185
+ - `margin`
186
+ - `color`
187
+ - `fontSize`
188
+
189
+ By combining some of these you can create for example :
190
+
191
+ ![type](https://cloud.githubusercontent.com/assets/378279/7667570/33817554-fc0d-11e4-9ad7-4eb60139cfb7.png)
192
+ ![star](https://cloud.githubusercontent.com/assets/378279/7667569/3010dd7e-fc0d-11e4-9696-cb721fe8e98d.png)
193
+
194
+ ## Usage as PNG Image/Source Object
195
+
196
+ Convenient way to plug this in into other components that rely on bitmap images rather than scalable vector icons. Takes the arguments `name`, `size` and `color` as described above.
197
+
198
+ ```jsx
199
+ const source = Icon.getImageSourceSync('user', 20, 'red');
200
+ return <Image source={source} />;
201
+ );
202
+ ```
203
+
204
+ Alternatively you may use the async method `Icon.getImageSource`.
205
+
206
+ Keep in mind that `Icon.getImageSourceSync` is blocking and might incur performance penalties. Subsequent calls will use cache however.
207
+
208
+ ## Multi-Style Fonts
209
+
210
+ Some fonts today use multiple styles, FontAwesome 5 for example, which is supported by this library. The usage is pretty much the same as the standard `Icon` component:
211
+
212
+ ```jsx
213
+ import Icon from '@react-native-vector-icons/fontawesome5';
214
+
215
+ const myIcon1 = <Icon name="comments" size={30} color="#900" />; // Defaults to solid
216
+ const myIcon2 = <Icon name="comments" size={30} color="#900" iconType="solid" />;
217
+ const myIcon3 = <Icon name="comments" size={30} color="#900" iconType="light" />; // Only in FA5 Pro
218
+ ```
219
+
220
+ ### Static methods
221
+
222
+ All static methods from `Icon` is supported by multi-styled fonts.
223
+
224
+ | Prop | Description |
225
+ | ------------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
226
+ | **`getImageSource`** | Returns a promise that resolving to the source of a bitmap version of the icon for use with `Image` component et al. Usage: `const source = await Icon.getImageSource(name, size, color)` |
227
+ | **`getImageSourceSync`** | Same as `getImageSource` but synchronous. Usage: `const source = Icon.getImageSourceSync(name, size, color)` |
228
+
229
+ ## Custom Fonts
230
+
231
+ The best approach is to use our icon generator to create your own icon package.
232
+
233
+ See [CREATE_FONT_PACKAGE.md] to learn how to create your own font packages.
234
+
235
+ You can also use `createIconSet(glyphMap, fontFamily[, fontFile])` directly in your project. This
236
+ returns your own custom font based on the `glyphMap` where the key is the icon
237
+ name and the value is either a UTF-8 character or it's character code.
238
+ `fontFamily` is the name of the postscript font **NOT** the filename. Open the font in
239
+ Font Book.app or similar to learn the name. Optionally pass the third
240
+ `fontFile` argument for android support, it should be the custom font file
241
+ name.
242
+
243
+ ```js
244
+ import { createIconSet } from '@react-native-vector-icons/common';
245
+ const glyphMap = { 'icon-name': 1234, test: '∆' };
246
+ const Icon = createIconSet(glyphMap, 'FontName', 'font-name.ttf');
247
+ ```
248
+
249
+ You should place the font ttf file into `rnvi-fonts`. You can customise this location by adding the following snippet to your package.json
250
+ ```json
251
+ {
252
+ "reactNativeVectorIcons": {
253
+ "fontDir": "src/assets/fonts"
254
+ }
255
+ }
256
+ ```
257
+
258
+ ## Animation
259
+
260
+ React Native comes with an amazing animation library called
261
+ [`Animated`](https://reactnative.dev/docs/animated.html). To use it with an
262
+ icon, simply create an animated component with this line: `const AnimatedIcon =
263
+ Animated.createAnimatedComponent(Icon)`. You can also use the higher level
264
+ animation library
265
+ [react-native-animatable](https://github.com/oblador/react-native-animatable).
266
+
267
+ ## Usage Examples
268
+
269
+ ### IconExplorer
270
+
271
+ Try the `IconExplorer` project in `Examples/IconExplorer` folder, there you can also search for any icon.
272
+
273
+ ![Screenshot of IconExplorer](https://cloud.githubusercontent.com/assets/378279/8903470/a9fe6b46-3458-11e5-901f-98b7b676d0d3.png)
274
+
275
+ ### Basic Example
276
+
277
+ ```js
278
+ import Icon from '@react-native-vector-icons/ionicons';
279
+
280
+ function ExampleView(props) {
281
+ return <Icon name="ios-person" size={30} color="#4F8EF7" />;
282
+ }
283
+ ```
284
+
285
+ ### Inline Icons
286
+
287
+ ```js
288
+ import { Text } from 'react-native';
289
+ import Icon from '@react-native-vector-icons/ionicons';
290
+
291
+ function ExampleView(props) {
292
+ return (
293
+ <Text>
294
+ Lorem <Icon name="ios-book" color="#4F8EF7" /> Ipsum
295
+ </Text>
296
+ );
297
+ }
298
+ ```
299
+
300
+ ## [Changelog](https://github.com/react-native-vector-icons/react-native-vector-icons/releases)
301
+
302
+ ## License
303
+
304
+ This project is licenced under the [MIT License](http://opensource.org/licenses/mit-license.html).
305
+
306
+ Any bundled fonts are copyright to their respective authors and mostly under MIT or [SIL OFL](http://scripts.sil.org/OFL).
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@react-native-vector-icons/common",
3
- "version": "0.0.1-alpha.2",
3
+ "version": "0.0.1-alpha.4",
4
4
  "description": "Customizable Icons for React Native with support for image source and full styling.",
5
5
  "main": "lib/commonjs/index",
6
6
  "module": "lib/module/index",
@@ -28,8 +28,8 @@
28
28
  "scripts": {
29
29
  "clean": "del-cli android/build example/android/build example/android/app/build example/ios/build lib",
30
30
  "prepare": "bob build",
31
- "preinstall": "cp ../../README.md .",
32
- "postinstall": "rm README.md",
31
+ "prepack": "cp ../../README.md .",
32
+ "postpack": "rm README.md",
33
33
  "watch": "onchange 'src/**' --initial -- yarn run prepare"
34
34
  },
35
35
  "keywords": [
@@ -101,7 +101,6 @@
101
101
  "release-it": "^17.0.1",
102
102
  "svg2ttf": "^6.0.3",
103
103
  "svgicons2svgfont": "^12.0.0",
104
- "turbo": "^1.11.2",
105
104
  "typescript": "^5.3.3"
106
105
  },
107
106
  "peerDependencies": {
@@ -166,5 +165,5 @@
166
165
  }
167
166
  },
168
167
  "packageManager": "yarn@4.0.1",
169
- "gitHead": "d3df16c8ea56afc562da15ee8c78d7ec7749385a"
168
+ "gitHead": "660207464c8301bcbead39ce21fa98f6e37a5d99"
170
169
  }