Skip to content

Commit

Permalink
feat: TextStyle Props Add in Table and Cell (#3112)
Browse files Browse the repository at this point in the history
  • Loading branch information
pushpender-singh-ap authored Mar 23, 2022
1 parent e21c49f commit 2876bce
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/components/DataTable/DataTableCell.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as React from 'react';
import { StyleSheet, StyleProp, ViewStyle } from 'react-native';
import { StyleSheet, StyleProp, ViewStyle, TextStyle } from 'react-native';
import Text from '../Typography/Text';
import TouchableRipple from '../TouchableRipple/TouchableRipple';
import type { $RemoveChildren } from '../../types';
Expand All @@ -18,6 +18,10 @@ type Props = $RemoveChildren<typeof TouchableRipple> & {
*/
onPress?: () => void;
style?: StyleProp<ViewStyle>;
/**
* Text content style of the `DataTableCell`.
*/
textStyle?: StyleProp<TextStyle>;
};

/**
Expand Down Expand Up @@ -51,12 +55,12 @@ type Props = $RemoveChildren<typeof TouchableRipple> & {
* MD Guidelines (https://github.com/callstack/react-native-paper/issues/2381).
*/

const DataTableCell = ({ children, style, numeric, ...rest }: Props) => (
const DataTableCell = ({ children, textStyle, style, numeric, ...rest }: Props) => (
<TouchableRipple
{...rest}
style={[styles.container, numeric && styles.right, style]}
>
<Text numberOfLines={1}>{children}</Text>
<Text style={textStyle} numberOfLines={1}>{children}</Text>
</TouchableRipple>
);

Expand Down
7 changes: 7 additions & 0 deletions src/components/DataTable/DataTableTitle.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {
View,
ViewStyle,
I18nManager,
TextStyle,
} from 'react-native';
import color from 'color';
import MaterialCommunityIcon from '../MaterialCommunityIcon';
Expand Down Expand Up @@ -35,6 +36,10 @@ type Props = React.ComponentPropsWithRef<typeof TouchableWithoutFeedback> & {
*/
onPress?: () => void;
style?: StyleProp<ViewStyle>;
/**
* Text content style of the `DataTableTitle`.
*/
textStyle?: StyleProp<TextStyle>;
/**
* @optional
*/
Expand Down Expand Up @@ -80,6 +85,7 @@ const DataTableTitle = ({
onPress,
sortDirection,
theme,
textStyle,
style,
numberOfLines = 1,
...rest
Expand Down Expand Up @@ -123,6 +129,7 @@ const DataTableTitle = ({
style={[
styles.cell,
sortDirection ? styles.sorted : { color: textColor },
textStyle,
]}
numberOfLines={numberOfLines}
>
Expand Down

0 comments on commit 2876bce

Please sign in to comment.