Skip to content

Commit

Permalink
feat: add prop textStyle to Chip (callstack#954)
Browse files Browse the repository at this point in the history
  • Loading branch information
brunohkbx authored and Trancever committed Jun 27, 2019
1 parent c23d4eb commit cb9923b
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 0 deletions.
14 changes: 14 additions & 0 deletions example/src/Examples/ChipExample.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,13 @@ class ChipExample extends React.Component<Props> {
>
Outlined unselected chip with custom color
</Chip>
<Chip
onPress={() => {}}
style={styles.chip}
textStyle={styles.tiny}
>
With custom size
</Chip>
</View>
</List.Section>
</ScrollView>
Expand All @@ -193,6 +200,13 @@ const styles = StyleSheet.create({
chip: {
margin: 4,
},
tiny: {
marginVertical: 2,
marginRight: 2,
marginLeft: 2,
minHeight: 19,
lineHeight: 19,
},
});

export default withTheme(ChipExample);
7 changes: 7 additions & 0 deletions src/components/Chip.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,12 @@ type Props = React.ComponentProps<typeof Surface> & {
* Function to execute on close button press. The close button appears only when this prop is specified.
*/
onClose?: () => void;
/**
* Style of chip's text
*/
textStyle?: any;
style?: StyleProp<ViewStyle>;

/**
* @optional
*/
Expand Down Expand Up @@ -139,6 +144,7 @@ class Chip extends React.Component<Props, State> {
accessibilityLabel,
onPress,
onClose,
textStyle,
style,
theme,
testID,
Expand Down Expand Up @@ -277,6 +283,7 @@ class Chip extends React.Component<Props, State> {
marginRight: onClose ? 4 : 8,
marginLeft: avatar || icon || selected ? 4 : 8,
},
textStyle,
]}
>
{children}
Expand Down
5 changes: 5 additions & 0 deletions src/components/__tests__/__snapshots__/Chip.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ exports[`renders chip with close button 1`] = `
"marginLeft": 4,
"marginRight": 4,
},
undefined,
],
]
}
Expand Down Expand Up @@ -286,6 +287,7 @@ exports[`renders chip with icon 1`] = `
"marginLeft": 4,
"marginRight": 8,
},
undefined,
],
]
}
Expand Down Expand Up @@ -364,6 +366,7 @@ exports[`renders chip with onPress 1`] = `
"marginLeft": 8,
"marginRight": 8,
},
undefined,
],
]
}
Expand Down Expand Up @@ -446,6 +449,7 @@ exports[`renders outlined disabled chip 1`] = `
"marginLeft": 8,
"marginRight": 8,
},
undefined,
],
]
}
Expand Down Expand Up @@ -573,6 +577,7 @@ exports[`renders selected chip 1`] = `
"marginLeft": 4,
"marginRight": 8,
},
undefined,
],
]
}
Expand Down

0 comments on commit cb9923b

Please sign in to comment.