mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-06-28 14:20:12 +00:00
Add definitions for react-native-read-more-text
This commit is contained in:
17
types/react-native-read-more-text/index.d.ts
vendored
Normal file
17
types/react-native-read-more-text/index.d.ts
vendored
Normal file
@@ -0,0 +1,17 @@
|
||||
// Type definitions for react-native-read-more-text 1.0
|
||||
// Project: https://github.com/expo/react-native-read-more-text
|
||||
// Definitions by: Jeff Held <https://github.com/solkaz>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.8
|
||||
|
||||
import * as React from "react";
|
||||
|
||||
export interface ReadMoreProps {
|
||||
children: React.ReactNode;
|
||||
numberOfLines: number;
|
||||
onReady?: () => void;
|
||||
renderRevealedFooter: (onPress: () => void) => React.ReactNode;
|
||||
renderTruncatedFooter: (onPress: () => void) => React.ReactNode;
|
||||
}
|
||||
|
||||
export default class ReadMore extends React.Component<ReadMoreProps> {}
|
||||
@@ -0,0 +1,65 @@
|
||||
// Tests taken from Usage at https://github.com/expo/react-native-read-more-text#usage
|
||||
import * as React from "react";
|
||||
import { Text, View } from "react-native";
|
||||
|
||||
import ReadMore from "react-native-read-more-text";
|
||||
|
||||
interface Props {
|
||||
text: string;
|
||||
}
|
||||
|
||||
declare const styles: any;
|
||||
declare const Colors: any;
|
||||
|
||||
export class DescriptionCard extends React.Component<Props> {
|
||||
render() {
|
||||
const { text } = this.props;
|
||||
|
||||
return (
|
||||
<View>
|
||||
<View style={styles.cardLabel}>
|
||||
<Text style={styles.cardLabelText}>Description</Text>
|
||||
</View>
|
||||
|
||||
<View style={styles.card}>
|
||||
<View style={styles.cardBody}>
|
||||
<ReadMore
|
||||
numberOfLines={3}
|
||||
renderTruncatedFooter={this._renderTruncatedFooter}
|
||||
renderRevealedFooter={this._renderRevealedFooter}
|
||||
onReady={this._handleTextReady}
|
||||
>
|
||||
<Text style={styles.cardText}>{text}</Text>
|
||||
</ReadMore>
|
||||
</View>
|
||||
</View>
|
||||
</View>
|
||||
);
|
||||
}
|
||||
|
||||
_renderTruncatedFooter = (handlePress: () => void) => {
|
||||
return (
|
||||
<Text
|
||||
style={{ color: Colors.tintColor, marginTop: 5 }}
|
||||
onPress={handlePress}
|
||||
>
|
||||
Read more
|
||||
</Text>
|
||||
);
|
||||
}
|
||||
|
||||
_renderRevealedFooter = (handlePress: () => void) => {
|
||||
return (
|
||||
<Text
|
||||
style={{ color: Colors.tintColor, marginTop: 5 }}
|
||||
onPress={handlePress}
|
||||
>
|
||||
Show less
|
||||
</Text>
|
||||
);
|
||||
}
|
||||
|
||||
_handleTextReady = () => {
|
||||
// ...
|
||||
}
|
||||
}
|
||||
17
types/react-native-read-more-text/tsconfig.json
Normal file
17
types/react-native-read-more-text/tsconfig.json
Normal file
@@ -0,0 +1,17 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": ["es6"],
|
||||
"jsx": "react-native",
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": true,
|
||||
"strictFunctionTypes": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": ["../"],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": ["index.d.ts", "react-native-read-more-text-tests.tsx"]
|
||||
}
|
||||
1
types/react-native-read-more-text/tslint.json
Normal file
1
types/react-native-read-more-text/tslint.json
Normal file
@@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
Reference in New Issue
Block a user