Skip to content

Commit 5b9bdd7

Browse files
committed
Merged #45 and whole Icon types are extended from base IconProps thanks to @davidgovea
1 parent ab7fd58 commit 5b9bdd7

File tree

5 files changed

+63
-31
lines changed

5 files changed

+63
-31
lines changed

example/.prettierrc.js

Lines changed: 0 additions & 6 deletions
This file was deleted.

example/App.tsx

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import React from 'react';
2-
import {View, StatusBar, SafeAreaView} from 'react-native';
3-
import Icon from 'react-native-dynamic-vector-icons';
1+
import React from "react";
2+
import { View, StatusBar, SafeAreaView } from "react-native";
3+
import Icon from "react-native-dynamic-vector-icons";
44

55
const App = () => {
66
return (
@@ -9,9 +9,10 @@ const App = () => {
99
<SafeAreaView
1010
style={{
1111
flex: 1,
12-
alignItems: 'center',
13-
justifyContent: 'center',
14-
}}>
12+
alignItems: "center",
13+
justifyContent: "center",
14+
}}
15+
>
1516
<Icon name="github" type="Feather" size={50} color="black" />
1617
<Icon name="cog" type="FontAwesome5" size={50} color="black" />
1718
</SafeAreaView>

example/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
"dependencies": {
1313
"react": "16.13.1",
1414
"react-native": "0.63.2",
15-
"react-native-dynamic-vector-icons": "^1.1.3",
15+
"react-native-dynamic-vector-icons": "^1.1.4",
1616
"react-native-vector-icons": "^7.1.0"
1717
},
1818
"devDependencies": {

lib/Icon.tsx

Lines changed: 54 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -10,30 +10,67 @@ interface IconPropsBase extends TextProps {
1010
style?: TextStyle;
1111
}
1212

13-
interface BasicIconProps extends IconPropsBase {
14-
type:
15-
| "AntDesign"
16-
| "MaterialIcons"
17-
| "EvilIcons"
18-
| "Entypo"
19-
| "FontAwesome"
20-
| "Foundation"
21-
| "Ionicons"
22-
| "MaterialCommunityIcons"
23-
| "Zocial"
24-
| "Octicons"
25-
| "SimpleLineIcons"
26-
| "Fontisto"
27-
| "Feather";
13+
interface AntDesignProps extends IconPropsBase {
14+
type: "AntDesign";
15+
}
16+
interface MaterialIconsProps extends IconPropsBase {
17+
type: "MaterialIcons";
18+
}
19+
interface EvilIconsProps extends IconPropsBase {
20+
type: "EvilIcons";
21+
}
22+
interface EntypoProps extends IconPropsBase {
23+
type: "Entypo";
24+
}
25+
interface FontAwesomeProps extends IconPropsBase {
26+
type: "FontAwesome";
27+
}
28+
interface FoundationProps extends IconPropsBase {
29+
type: "Foundation";
30+
}
31+
interface IoniconsProps extends IconPropsBase {
32+
type: "Ionicons";
33+
}
34+
interface MaterialCommunityIconsProps extends IconPropsBase {
35+
type: "MaterialCommunityIcons";
36+
}
37+
interface ZocialProps extends IconPropsBase {
38+
type: "Zocial";
39+
}
40+
interface OcticonsProps extends IconPropsBase {
41+
type: "Octicons";
42+
}
43+
interface SimpleLineIconsProps extends IconPropsBase {
44+
type: "SimpleLineIcons";
45+
}
46+
interface FontistoProps extends IconPropsBase {
47+
type: "Fontisto";
48+
}
49+
interface FeatherProps extends IconPropsBase {
50+
type: "Feather";
2851
}
2952

30-
interface Fa5IconProps extends IconPropsBase {
53+
interface FontAwesome5Props extends IconPropsBase {
3154
type: "FontAwesome5";
3255
brand?: boolean;
3356
solid?: boolean;
3457
}
3558

36-
type IconProps = BasicIconProps | Fa5IconProps;
59+
type IconProps =
60+
| AntDesignProps
61+
| MaterialIconsProps
62+
| EvilIconsProps
63+
| EntypoProps
64+
| FontAwesomeProps
65+
| FoundationProps
66+
| IoniconsProps
67+
| MaterialCommunityIconsProps
68+
| ZocialProps
69+
| OcticonsProps
70+
| SimpleLineIconsProps
71+
| FontistoProps
72+
| FeatherProps
73+
| FontAwesome5Props;
3774

3875
const Icon = (props: IconProps): JSX.Element => {
3976
const { name, color, size, onPress, style, ...textProps } = props;

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "react-native-dynamic-vector-icons",
3-
"version": "1.1.3",
3+
"version": "1.1.4",
44
"description": "Wrapper of react-native-vector-icons to use dynamic types.",
55
"keywords": [
66
"typescript",

0 commit comments

Comments
 (0)