Skip to content

Commit 31390f9

Browse files
committed
✨ Text color is now inverted color of bg color
1 parent 4895b03 commit 31390f9

File tree

3 files changed

+14
-1
lines changed

3 files changed

+14
-1
lines changed

index.js

+6-1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ import {
66
StyleSheet,
77
} from 'react-native';
88

9+
import invert from 'invert-color';
10+
911
export default class RNChipPicker extends React.Component {
1012
render() {
1113
// Check & set the colour for selected chips.
@@ -38,6 +40,9 @@ export default class RNChipPicker extends React.Component {
3840
alignSelf: 'stretch',
3941
flexDirection: 'row',
4042
backgroundColor: this.props.backgroundColor,
43+
},
44+
innerText: {
45+
color: invert(this.props.backgroundColor, true)
4146
}
4247
});
4348

@@ -59,7 +64,7 @@ export default class RNChipPicker extends React.Component {
5964
chips.push(
6065
<TouchableOpacity key={i} style={chipStyle} onPress={() => this.props.onValueSelect(item)}>
6166
<View>
62-
<Text>{item}</Text>
67+
<Text style={style.innerText}>{item}</Text>
6368
</View>
6469
</TouchableOpacity>
6570
);

package.json

+3
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,8 @@
99
"devDependencies": {
1010
"react": "16.9.0",
1111
"react-native": "^0.61.4"
12+
},
13+
"dependencies": {
14+
"invert-color": "^2.0.0"
1215
}
1316
}

yarn.lock

+5
Original file line numberDiff line numberDiff line change
@@ -2191,6 +2191,11 @@ invariant@^2.2.4:
21912191
dependencies:
21922192
loose-envify "^1.0.0"
21932193

2194+
invert-color@^2.0.0:
2195+
version "2.0.0"
2196+
resolved "https://registry.yarnpkg.com/invert-color/-/invert-color-2.0.0.tgz#894ab1f7494a6e45f5e74c2f99ec042cd67dd23e"
2197+
integrity sha512-9s6IATlhOAr0/0MPUpLdMpk81ixIu8IqwPwORssXBauFT/4ff/iyEOcojd0UYuPwkDbJvL1+blIZGhqVIaAm5Q==
2198+
21942199
invert-kv@^1.0.0:
21952200
version "1.0.0"
21962201
resolved "https://registry.yarnpkg.com/invert-kv/-/invert-kv-1.0.0.tgz#104a8e4aaca6d3d8cd157a8ef8bfab2d7a3ffdb6"

0 commit comments

Comments
 (0)