From 463306667992cd3273a8344d58f9056561d1725d Mon Sep 17 00:00:00 2001 From: Myroslav Hryschenko Date: Tue, 31 Oct 2023 11:50:35 +0200 Subject: [PATCH] feat(text-props): :sparkles: added pass props to two text user can pass native props to texts --- src/component/truncated_text_view.tsx | 10 +++++++++- src/types/types.ts | 12 +++++++++++- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/src/component/truncated_text_view.tsx b/src/component/truncated_text_view.tsx index 1edbc32..6960a84 100644 --- a/src/component/truncated_text_view.tsx +++ b/src/component/truncated_text_view.tsx @@ -25,7 +25,13 @@ if ( } export const TruncatedTextView = (props: TruncatedTextViewProps) => { - const { style, tailTextStyle, containerStyle } = props; + const { + style, + tailTextStyle, + containerStyle, + textPropsRoot, + textPropsChild, + } = props; const { text: fullText, lineHeight = DEFAULT_LINE_HEIGHT, @@ -129,6 +135,7 @@ export const TruncatedTextView = (props: TruncatedTextViewProps) => { style={[style, { lineHeight }]} numberOfLines={isExpanded ? 0 : numberOfLines} onTextLayout={_handleTextLayout} + {...textPropsRoot} > {fullText} {_shouldShowTailView && '\n'} @@ -149,6 +156,7 @@ export const TruncatedTextView = (props: TruncatedTextViewProps) => { {isExpanded ? expandedText : collapsedText} diff --git a/src/types/types.ts b/src/types/types.ts index ba2f9ad..dd86771 100644 --- a/src/types/types.ts +++ b/src/types/types.ts @@ -1,4 +1,4 @@ -import type { StyleProp, TextStyle, ViewStyle } from 'react-native'; +import type { StyleProp, TextStyle, TextProps, ViewStyle } from 'react-native'; export type TruncatedTextViewProps = { /** @@ -60,4 +60,14 @@ export type TruncatedTextViewProps = { * Whether to enable layout animation, default value is true */ enableLayoutAnimation?: boolean; + + /** + * Apply text props to root text + */ + textPropsRoot?: TextProps; + + /** + * Apply text props to child text + */ + textPropsChild?: TextProps; };