commit 6bd475399a72b48cbedfb6df4ca37f0930ed4ca9 Author: Exponent GitHub Bot Date: Sun Jul 10 02:20:06 2016 +0000 Initial commit fbshipit-source-id: 21ada2db87c55eb346aa4da5b67d25cb1c8fd081 diff --git a/Entypo.js b/Entypo.js new file mode 100644 index 0000000..9a0b577 --- /dev/null +++ b/Entypo.js @@ -0,0 +1,4 @@ +import { glyphMap } from 'react-native-vector-icons/Entypo'; +import createIconSet from './createIconSet'; + +export default createIconSet(glyphMap, 'entypo', require('./fonts/Entypo.ttf')); diff --git a/EvilIcons.js b/EvilIcons.js new file mode 100644 index 0000000..202f212 --- /dev/null +++ b/EvilIcons.js @@ -0,0 +1,4 @@ +import { glyphMap } from 'react-native-vector-icons/EvilIcons'; +import createIconSet from './createIconSet'; + +export default createIconSet(glyphMap, 'evilicons', require('./fonts/EvilIcons.ttf')); diff --git a/FontAwesome.js b/FontAwesome.js new file mode 100644 index 0000000..89829cb --- /dev/null +++ b/FontAwesome.js @@ -0,0 +1,4 @@ +import { glyphMap } from 'react-native-vector-icons/FontAwesome'; +import createIconSet from './createIconSet'; + +export default createIconSet(glyphMap, 'awesome', require('./fonts/FontAwesome.ttf')); diff --git a/Foundation.js b/Foundation.js new file mode 100644 index 0000000..328b618 --- /dev/null +++ b/Foundation.js @@ -0,0 +1,4 @@ +import { glyphMap } from 'react-native-vector-icons/Foundation'; +import createIconSet from './createIconSet'; + +export default createIconSet(glyphMap, 'foundation', require('./fonts/Foundation.ttf')); diff --git a/Ionicons.js b/Ionicons.js new file mode 100644 index 0000000..c30853a --- /dev/null +++ b/Ionicons.js @@ -0,0 +1,4 @@ +import { glyphMap } from 'react-native-vector-icons/Ionicons'; +import createIconSet from './createIconSet'; + +export default createIconSet(glyphMap, 'ionicons', require('./fonts/Ionicons.ttf')); diff --git a/MaterialIcons.js b/MaterialIcons.js new file mode 100644 index 0000000..8d68a18 --- /dev/null +++ b/MaterialIcons.js @@ -0,0 +1,4 @@ +import { glyphMap } from 'react-native-vector-icons/MaterialIcons'; +import createIconSet from './createIconSet'; + +export default createIconSet(glyphMap, 'material', require('./fonts/MaterialIcons.ttf')); diff --git a/Octicons.js b/Octicons.js new file mode 100644 index 0000000..0943892 --- /dev/null +++ b/Octicons.js @@ -0,0 +1,4 @@ +import { glyphMap } from 'react-native-vector-icons/Octicons'; +import createIconSet from './createIconSet'; + +export default createIconSet(glyphMap, 'octicons', require('./fonts/Octicons.ttf')); diff --git a/Zocial.js b/Zocial.js new file mode 100644 index 0000000..bfff498 --- /dev/null +++ b/Zocial.js @@ -0,0 +1,4 @@ +import { glyphMap } from 'react-native-vector-icons/Zocial'; +import createIconSet from './createIconSet'; + +export default createIconSet(glyphMap, 'zocial', require('./fonts/Zocial.ttf')); diff --git a/createIconSet.js b/createIconSet.js new file mode 100644 index 0000000..27c2599 --- /dev/null +++ b/createIconSet.js @@ -0,0 +1,47 @@ +import React from 'react'; +import { View } from 'react-native'; +import { Font } from 'exponent'; +import createIconSet from 'react-native-vector-icons/lib/create-icon-set'; + +export default function(glyphMap, fontName, exponentAssetId) { + const exponentFontName = Font.style(fontName, {ignoreWarning: true}).fontFamily; + const fontId = {[fontName]: exponentAssetId}; + let OriginalIcon = createIconSet(glyphMap, exponentFontName, 'n/a'); + + class Icon extends React.Component { + static propTypes = OriginalIcon.propTypes; + static defaultProps = OriginalIcon.defaultProps; + + state = { + fontIsLoaded: Font.isLoaded(fontName), + } + + async componentWillMount() { + if (!this.state.fontIsLoaded) { + await Font.loadAsync(fontId); + this.setState({fontIsLoaded: true}); + } + } + + setNativeProps(props) { + if (this._icon) { + this._icon.setNativeProps(props); + } + } + + render() { + if (!this.state.fontIsLoaded) { + return ; + } + + return ( + { this._icon = view; }} + {...this.props} + /> + ); + } + } + + return Icon; +} diff --git a/createIconSetFromFontello.js b/createIconSetFromFontello.js new file mode 100644 index 0000000..b52e6f3 --- /dev/null +++ b/createIconSetFromFontello.js @@ -0,0 +1,6 @@ +import { Font } from 'exponent'; +import createIconSetFromFontello from 'react-native-vector-icons/lib/create-icon-set-from-fontello'; + +export default function(config, exponentFontName, exponentAssetId) { + return createIconSetFromFontello(config, Font.style(exponentFontName).fontFamily, exponentAssetId); +} diff --git a/createIconSetFromIcoMoon.js b/createIconSetFromIcoMoon.js new file mode 100644 index 0000000..4597534 --- /dev/null +++ b/createIconSetFromIcoMoon.js @@ -0,0 +1,6 @@ +import { Font } from 'exponent'; +import createIconSetFromIcoMoon from 'react-native-vector-icons/lib/create-icon-set-from-icomoon'; + +export default function(config, exponentFontName, exponentAssetId) { + return createIconSetFromIcoMoon(config, Font.style(exponentFontName).fontFamily, exponentAssetId); +} diff --git a/fonts/Entypo.ttf b/fonts/Entypo.ttf new file mode 100644 index 0000000..1c8f5e9 Binary files /dev/null and b/fonts/Entypo.ttf differ diff --git a/fonts/EvilIcons.ttf b/fonts/EvilIcons.ttf new file mode 100644 index 0000000..b270f98 Binary files /dev/null and b/fonts/EvilIcons.ttf differ diff --git a/fonts/FontAwesome.ttf b/fonts/FontAwesome.ttf new file mode 100644 index 0000000..f221e50 Binary files /dev/null and b/fonts/FontAwesome.ttf differ diff --git a/fonts/Foundation.ttf b/fonts/Foundation.ttf new file mode 100644 index 0000000..6cce217 Binary files /dev/null and b/fonts/Foundation.ttf differ diff --git a/fonts/Ionicons.ttf b/fonts/Ionicons.ttf new file mode 100644 index 0000000..307ad88 Binary files /dev/null and b/fonts/Ionicons.ttf differ diff --git a/fonts/MaterialIcons.ttf b/fonts/MaterialIcons.ttf new file mode 100644 index 0000000..7015564 Binary files /dev/null and b/fonts/MaterialIcons.ttf differ diff --git a/fonts/Octicons.ttf b/fonts/Octicons.ttf new file mode 100644 index 0000000..0a62bb9 Binary files /dev/null and b/fonts/Octicons.ttf differ diff --git a/fonts/Zocial.ttf b/fonts/Zocial.ttf new file mode 100644 index 0000000..e4ae46c Binary files /dev/null and b/fonts/Zocial.ttf differ diff --git a/index.js b/index.js new file mode 100644 index 0000000..1bf2d84 --- /dev/null +++ b/index.js @@ -0,0 +1,13 @@ +module.exports = { + get createIconSet() { return require('./createIconSet').default; }, + get createIconSetFromIcoMoon() { return require('./createIconSetFromIcoMoon').default; }, + get createIconSetFromFontello() { return require('./createIconSetFromFontello').default; }, + get Entypo() { return require('./Entypo').default; }, + get EvilIcons() { return require('./EvilIcons').default; }, + get FontAwesome() { return require('./FontAwesome').default; }, + get Foundation() { return require('./Foundation').default; }, + get Ionicons() { return require('./Ionicons').default; }, + get MaterialIcons() { return require('./MaterialIcons').default; }, + get Octicons() { return require('./Octicons').default; }, + get Zocial() { return require('./Zocial').default; }, +}; diff --git a/package.json b/package.json new file mode 100644 index 0000000..d14beca --- /dev/null +++ b/package.json @@ -0,0 +1,24 @@ +{ + "name": "@exponent/vector-icons", + "version": "1.0.0", + "description": "Built-in support for 8 popular icon fonts and the tooling to create your own Icon components from your font and glyph map. This is a wrapper around react-native-vector-icons to make it compatible with Exponent.", + "main": "index.js", + "scripts": {}, + "repository": { + "type": "git", + "url": "https://github.com/exponentjs/exponent-vector-icons.git" + }, + "keywords": [ + "exponent" + ], + "author": "Brent Vatne", + "license": "MIT", + "bugs": { + "url": "https://github.com/exponentjs/exponent-vector-icons/issues" + }, + "homepage": "https://github.com/exponentjs/exponent-vector-icons", + "dependencies": { + "react-native-vector-icons": "2.0.3" + }, + "devDependencies": {} +}