From 93109f126a2e0079ff823a0fffe74369d3e8a82d Mon Sep 17 00:00:00 2001 From: Kyle Roach Date: Tue, 4 Jul 2017 16:10:19 -0400 Subject: [PATCH] Added definitions for react-native-elements --- types/react-native-elements/index.d.ts | 166 ++++++++++++++++++ .../react-native-elements-tests.tsx | 44 +++++ types/react-native-elements/tsconfig.json | 24 +++ types/react-native-elements/tslint.json | 1 + 4 files changed, 235 insertions(+) create mode 100644 types/react-native-elements/index.d.ts create mode 100644 types/react-native-elements/react-native-elements-tests.tsx create mode 100644 types/react-native-elements/tsconfig.json create mode 100644 types/react-native-elements/tslint.json diff --git a/types/react-native-elements/index.d.ts b/types/react-native-elements/index.d.ts new file mode 100644 index 0000000000..8323ef1c25 --- /dev/null +++ b/types/react-native-elements/index.d.ts @@ -0,0 +1,166 @@ +// Type definitions for react-native-elements 0.13 +// Project: https://github.com/react-native-training/react-native-elements#readme +// Definitions by: Kyle Roach +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.3 + +import * as React from 'react'; +import { ViewStyle, TextStyle } from 'react-native'; + +export interface ButtonIcon { + name?: string; + color?: string; + size?: number; + type?: 'material' | 'material-community' | 'simple-line-icon' | 'zocial' | 'font-awesome' | 'octicon' | 'ionicon' | 'foundation' | 'evilicon' | 'entypo'; + buttonStyle?: TextStyle; +} + +export interface ButtonProperties { + /** + * Specify other component such as TouchableOpacity or other + * + * @default TouchableHighlight (iOS), TouchableNativeFeedback (android) + */ + Component?: JSX.Element; + + /** + * Additional styling for button component + * + * @default null + */ + buttonStyle?: ViewStyle; + + /** + * Button title + */ + title: string; + + /** + * Makes button large + * + * @default false + */ + large?: boolean; + + /** + * Specify different font family + * + * @default System font (iOS), Sans Serif (android) + */ + fontFamily?: string; + + /** + * Specify font weight for title + * + * @default null + */ + fontWeight?: string; + + /** + * Moves icon to right of title + * + * @default false + */ + iconRight?: boolean; + + /** + * onPress method + */ + onPress(): void; + + /** + * onLongPress method + */ + onLongPress?(): void; + + /** + * Icon configuration + */ + icon?: ButtonIcon; + + /** + * Specify other icon component instead of default. The component will have all values from the icon prop + * + * @default MaterialIcon + * @see https://github.com/oblador/react-native-vector-icons#icon-component + */ + iconComponent?: JSX.Element; + + /** + * Background color of button + * + * @default #397af8 + */ + backgroundColor?: string; + + /** + * Adds border radius to button + * (Note: if you set this, don't forget to also set borderRadius to containerViewStyle prop, otherwise unexpected behaviour might occur) + * + * @default 0 + */ + borderRadius?: number; + + /** + * Font color + * + * @default #fff + */ + color?: string; + + /** + * Text styling + * + * @default null + */ + textStyle?: TextStyle; + + /** + * Font size + * + * @default 18 + */ + fontSize?: number; + + /** + * Underlay color for button press + * + * @default transparent + */ + underlayColor?: string; + + /** + * Flag to add raised button styling + * + * @default false + */ + raised?: boolean; + + /** + * Indicates button is disabled + * + * @default false + */ + disabled?: boolean; + + /** + * Disabled button styling + * + * @default null + */ + disabledStyle?: ViewStyle; + + /** + * Styling for Component container + * + * @default null + */ + containerViewStyle?: ViewStyle; +} + +/** + * Button component + * + * @desc https://react-native-training.github.io/react-native-elements/API/buttons/ + */ +export class Button extends React.Component {} diff --git a/types/react-native-elements/react-native-elements-tests.tsx b/types/react-native-elements/react-native-elements-tests.tsx new file mode 100644 index 0000000000..197b1ec202 --- /dev/null +++ b/types/react-native-elements/react-native-elements-tests.tsx @@ -0,0 +1,44 @@ +import * as React from 'react'; +import { View, StyleSheet } from 'react-native'; +import { Button } from 'react-native-elements'; + +class ButtonTest extends React.Component { + handleButtonPress() { + console.log('I got pressed'); + } + + render() { + return ( + +