diff --git a/build/createIconSet.d.ts b/build/createIconSet.d.ts index 83cf502..2c70ec2 100644 --- a/build/createIconSet.d.ts +++ b/build/createIconSet.d.ts @@ -1,27 +1,6 @@ import React, { ComponentClass } from "react"; -import { TextProps, TouchableHighlightProps, ViewProps, OpaqueColorValue } from "react-native"; +import { TextProps, TouchableHighlightProps, ViewProps, OpaqueColorValue, TextStyle, ViewStyle } from "react-native"; export { DEFAULT_ICON_COLOR, DEFAULT_ICON_SIZE } from "./vendor/react-native-vector-icons/lib/create-icon-set"; -export interface IconButtonProps extends ViewProps, TouchableHighlightProps { - /** - * Size of the icon, can also be passed as fontSize in the style object. - * - * @default 12 - */ - size?: number; - /** - * Name of the icon to show - * - * See Icon Explorer app - * {@link https://expo.github.io/vector-icons/} - */ - name: GLYPHS; - /** - * Color of the icon. Can be a string or OpaqueColorValue (returned from - * PlatformColor(..)) - * - */ - color?: string | OpaqueColorValue; -} export interface IconProps extends TextProps { /** * Size of the icon, can also be passed as fontSize in the style object. @@ -43,6 +22,43 @@ export interface IconProps extends TextProps { */ color?: string | OpaqueColorValue; } +export interface IconButtonProps extends IconProps, ViewProps, TouchableHighlightProps { + /** + * Text and icon color + * Use iconStyle or nest a Text component if you need different colors. + * Can be a string or OpaqueColorValue (returned from PlatformColor(..)) + * + * @default 'white' + */ + color?: string | OpaqueColorValue; + /** + * Border radius of the button + * Set to 0 to disable. + * + * @default 5 + */ + borderRadius?: number; + /** + * Styles applied to the icon only + * Good for setting margins or a different color. + * + * @default {marginRight: 10} + */ + iconStyle?: TextStyle; + /** + * Style prop inherited from TextProps and TouchableWithoutFeedbackProperties + * Only exist here so we can have ViewStyle or TextStyle + * + */ + style?: ViewStyle | TextStyle; + /** + * Background color of the button. Can be a string or OpaqueColorValue (returned from + * PlatformColor(..)) + * + * @default '#007AFF' + */ + backgroundColor?: string | OpaqueColorValue; +} export declare type GlyphMap = { [K in G]: number; }; diff --git a/build/createIconSet.js.map b/build/createIconSet.js.map index 85877d1..a396886 100644 --- a/build/createIconSet.js.map +++ b/build/createIconSet.js.map @@ -1 +1 @@ -{"version":3,"file":"createIconSet.js","sourceRoot":"","sources":["../src/createIconSet.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAClC,OAAO,KAAyB,MAAM,OAAO,CAAC;AAC9C,OAAO,EAAE,IAAI,EAAmE,MAAM,cAAc,CAAC;AAErG,OAAO,aAAa,MAAM,wDAAwD,CAAC;AACnF,OAAO,yBAAyB,MAAM,oDAAoD,CAAC;AAE3F,OAAO,EACL,kBAAkB,EAClB,iBAAiB,EAClB,MAAM,wDAAwD,CAAC;AA+DhE,MAAM,CAAC,OAAO,WACZ,QAAqB,EACrB,QAAY,EACZ,WAAW,EACX,SAAe;;IAEf,MAAM,IAAI,GAAG,EAAE,CAAC,QAAQ,CAAC,EAAE,WAAW,EAAE,CAAC;IACzC,MAAM,gBAAgB,GAAG,aAAa,CAAC,QAAQ,EAAE,QAAQ,EAAE,IAAI,EAAE,SAAS,CAAC,CAAC;IAE5E,YAAO,MAAM,IAAK,SAAQ,KAAK,CAAC,SAAuB;YAAhD;;gBASL,aAAQ,GAAG,KAAK,CAAC;gBAGjB,UAAK,GAAG;oBACN,YAAY,EAAE,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC;iBACtC,CAAC;YAkCJ,CAAC;YAhCC,KAAK,CAAC,iBAAiB;gBACrB,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC;gBACrB,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,YAAY,EAAE;oBAC5B,MAAM,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;oBAC3B,IAAI,CAAC,QAAQ,IAAI,IAAI,CAAC,QAAQ,CAAC,EAAE,YAAY,EAAE,IAAI,EAAE,CAAC,CAAC;iBACxD;YACH,CAAC;YAED,oBAAoB;gBAClB,IAAI,CAAC,QAAQ,GAAG,KAAK,CAAC;YACxB,CAAC;YAED,cAAc,CAAC,KAAK;gBAClB,IAAI,IAAI,CAAC,KAAK,EAAE;oBACd,IAAI,CAAC,KAAK,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC;iBAClC;YACH,CAAC;YAED,MAAM;gBACJ,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,YAAY,EAAE;oBAC5B,OAAO,CAAC,IAAI,CAAC,AAAD,EAAG,CAAC;iBACjB;gBAED,OAAO,CACL,CAAC,gBAAgB,CACf,GAAG,CAAC,CAAC,IAAI,CAAC,EAAE;oBACV,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC;gBACpB,CAAC,CAAC,CACF,IAAI,IAAI,CAAC,KAAK,CAAC,EACf,CACH,CAAC;YACJ,CAAC;SACF;QA/CQ,eAAY,GAAG,gBAAgB,CAAC,YAAa;QAC7C,SAAM,GAAG,yBAAyB,CAAC,EAAI,CAAE;QACzC,WAAQ,GAAG,QAAS;QACpB,iBAAc,GAAG,GAAG,EAAE,CAAC,QAAS;QAChC,gBAAa,GAAG,GAAG,EAAE,CAAC,QAAS;QAC/B,WAAQ,GAAG,GAAG,EAAE,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAE;QACtC,OAAI,GAAG,IAAK;WAyCnB;AACJ,CAAC","sourcesContent":["import * as Font from \"expo-font\";\nimport React, { ComponentClass } from \"react\";\nimport { Text, TextProps, TouchableHighlightProps, ViewProps, OpaqueColorValue } from \"react-native\";\n\nimport createIconSet from \"./vendor/react-native-vector-icons/lib/create-icon-set\";\nimport createIconButtonComponent from \"./vendor/react-native-vector-icons/lib/icon-button\";\n\nexport {\n DEFAULT_ICON_COLOR,\n DEFAULT_ICON_SIZE\n} from \"./vendor/react-native-vector-icons/lib/create-icon-set\";\n\nexport interface IconButtonProps extends ViewProps, TouchableHighlightProps {\n /**\n * Size of the icon, can also be passed as fontSize in the style object.\n *\n * @default 12\n */\n size?: number;\n\n /**\n * Name of the icon to show\n *\n * See Icon Explorer app\n * {@link https://expo.github.io/vector-icons/}\n */\n name: GLYPHS;\n\n /**\n * Color of the icon. Can be a string or OpaqueColorValue (returned from\n * PlatformColor(..))\n *\n */\n color?: string | OpaqueColorValue;\n}\n\nexport interface IconProps extends TextProps {\n /**\n * Size of the icon, can also be passed as fontSize in the style object.\n *\n * @default 12\n */\n size?: number;\n\n /**\n * Name of the icon to show\n *\n * See Icon Explorer app\n * {@link https://expo.github.io/vector-icons/}\n */\n name: GLYPHS;\n\n /**\n * Color of the icon. Can be a string or OpaqueColorValue (returned from\n * PlatformColor(..))\n *\n */\n color?: string | OpaqueColorValue;\n}\n\nexport type GlyphMap = { [K in G]: number }\n\nexport interface Icon {\n defaultProps: any;\n Button: ComponentClass>;\n glyphMap: GlyphMap;\n getRawGlyphMap: () => GlyphMap;\n getFontFamily: () => FN;\n loadFont: () => Promise;\n font: { [x: string]: any };\n new (props: IconProps): React.Component>;\n}\n\nexport default function(\n glyphMap: GlyphMap,\n fontName: FN,\n expoAssetId,\n fontStyle?: any\n): Icon {\n const font = { [fontName]: expoAssetId };\n const RNVIconComponent = createIconSet(glyphMap, fontName, null, fontStyle);\n\n return class Icon extends React.Component> {\n static defaultProps = RNVIconComponent.defaultProps;\n static Button = createIconButtonComponent(Icon);\n static glyphMap = glyphMap;\n static getRawGlyphMap = () => glyphMap;\n static getFontFamily = () => fontName;\n static loadFont = () => Font.loadAsync(font);\n static font = font;\n\n _mounted = false;\n _icon?: any;\n\n state = {\n fontIsLoaded: Font.isLoaded(fontName)\n };\n\n async componentDidMount() {\n this._mounted = true;\n if (!this.state.fontIsLoaded) {\n await Font.loadAsync(font);\n this._mounted && this.setState({ fontIsLoaded: true });\n }\n }\n\n componentWillUnmount() {\n this._mounted = false;\n }\n\n setNativeProps(props) {\n if (this._icon) {\n this._icon.setNativeProps(props);\n }\n }\n\n render() {\n if (!this.state.fontIsLoaded) {\n return ;\n }\n\n return (\n {\n this._icon = view;\n }}\n {...this.props}\n />\n );\n }\n };\n}\n"]} \ No newline at end of file +{"version":3,"file":"createIconSet.js","sourceRo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,KAAK,CAAC,CAAC;iBAClC;YACH,CAAC;YAED,MAAM;gBACJ,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,YAAY,EAAE;oBAC5B,OAAO,CAAC,IAAI,CAAC,AAAD,EAAG,CAAC;iBACjB;gBAED,OAAO,CACL,CAAC,gBAAgB,CACf,GAAG,CAAC,CAAC,IAAI,CAAC,EAAE;oBACV,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC;gBACpB,CAAC,CAAC,CACF,IAAI,IAAI,CAAC,KAAK,CAAC,EACf,CACH,CAAC;YACJ,CAAC;SACF;QA/CQ,eAAY,GAAG,gBAAgB,CAAC,YAAa;QAC7C,SAAM,GAAG,yBAAyB,CAAC,EAAI,CAAE;QACzC,WAAQ,GAAG,QAAS;QACpB,iBAAc,GAAG,GAAG,EAAE,CAAC,QAAS;QAChC,gBAAa,GAAG,GAAG,EAAE,CAAC,QAAS;QAC/B,WAAQ,GAAG,GAAG,EAAE,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAE;QACtC,OAAI,GAAG,IAAK;WAyCnB;AACJ,CAAC","sourcesContent":["import * as Font from \"expo-font\";\nimport React, { ComponentClass } from \"react\";\nimport { Text, TextProps, TouchableHighlightProps, ViewProps, OpaqueColorValue, TextStyle, ViewStyle } from \"react-native\";\n\nimport createIconSet from \"./vendor/react-native-vector-icons/lib/create-icon-set\";\nimport createIconButtonComponent from \"./vendor/react-native-vector-icons/lib/icon-button\";\n\nexport {\n DEFAULT_ICON_COLOR,\n DEFAULT_ICON_SIZE\n} from \"./vendor/react-native-vector-icons/lib/create-icon-set\";\n\nexport interface IconProps extends TextProps {\n /**\n * Size of the icon, can also be passed as fontSize in the style object.\n *\n * @default 12\n */\n size?: number;\n\n /**\n * Name of the icon to show\n *\n * See Icon Explorer app\n * {@link https://expo.github.io/vector-icons/}\n */\n name: GLYPHS;\n\n /**\n * Color of the icon. Can be a string or OpaqueColorValue (returned from\n * PlatformColor(..))\n *\n */\n color?: string | OpaqueColorValue;\n}\n\nexport interface IconButtonProps extends IconProps, ViewProps, TouchableHighlightProps {\n /**\n * Text and icon color\n * Use iconStyle or nest a Text component if you need different colors.\n * Can be a string or OpaqueColorValue (returned from PlatformColor(..))\n *\n * @default 'white'\n */\n color?: string | OpaqueColorValue;\n\n /**\n * Border radius of the button\n * Set to 0 to disable.\n *\n * @default 5\n */\n borderRadius?: number;\n\n /**\n * Styles applied to the icon only\n * Good for setting margins or a different color.\n *\n * @default {marginRight: 10}\n */\n iconStyle?: TextStyle;\n\n /**\n * Style prop inherited from TextProps and TouchableWithoutFeedbackProperties\n * Only exist here so we can have ViewStyle or TextStyle\n *\n */\n style?: ViewStyle | TextStyle;\n\n /**\n * Background color of the button. Can be a string or OpaqueColorValue (returned from\n * PlatformColor(..))\n *\n * @default '#007AFF'\n */\n backgroundColor?: string | OpaqueColorValue;\n}\n\nexport type GlyphMap = { [K in G]: number }\n\nexport interface Icon {\n defaultProps: any;\n Button: ComponentClass>;\n glyphMap: GlyphMap;\n getRawGlyphMap: () => GlyphMap;\n getFontFamily: () => FN;\n loadFont: () => Promise;\n font: { [x: string]: any };\n new (props: IconProps): React.Component>;\n}\n\nexport default function(\n glyphMap: GlyphMap,\n fontName: FN,\n expoAssetId,\n fontStyle?: any\n): Icon {\n const font = { [fontName]: expoAssetId };\n const RNVIconComponent = createIconSet(glyphMap, fontName, null, fontStyle);\n\n return class Icon extends React.Component> {\n static defaultProps = RNVIconComponent.defaultProps;\n static Button = createIconButtonComponent(Icon);\n static glyphMap = glyphMap;\n static getRawGlyphMap = () => glyphMap;\n static getFontFamily = () => fontName;\n static loadFont = () => Font.loadAsync(font);\n static font = font;\n\n _mounted = false;\n _icon?: any;\n\n state = {\n fontIsLoaded: Font.isLoaded(fontName)\n };\n\n async componentDidMount() {\n this._mounted = true;\n if (!this.state.fontIsLoaded) {\n await Font.loadAsync(font);\n this._mounted && this.setState({ fontIsLoaded: true });\n }\n }\n\n componentWillUnmount() {\n this._mounted = false;\n }\n\n setNativeProps(props) {\n if (this._icon) {\n this._icon.setNativeProps(props);\n }\n }\n\n render() {\n if (!this.state.fontIsLoaded) {\n return ;\n }\n\n return (\n {\n this._icon = view;\n }}\n {...this.props}\n />\n );\n }\n };\n}\n"]} \ No newline at end of file diff --git a/package.json b/package.json index 3d89df1..bd53f6c 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "@expo/vector-icons", "sideEffects": false, - "version": "12.0.2", + "version": "12.0.3", "description": "Built-in support for 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 Expo.", "main": "build/IconsLazy.js", "module": "build/Icons.js",