Skip to content

Commit d38fa3a

Browse files
authored
Feat/add labelProps prop (#1252)
* add labelProps prop * import TextProps from ui-lib's text * remove style props from labelProps typings * prioritize labelProps over basic style
1 parent 47516f2 commit d38fa3a

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

generatedTypes/components/checkbox/index.d.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import React from 'react';
22
import { StyleProp, TouchableOpacityProps, ViewStyle, TextStyle } from 'react-native';
3+
import { TextProps } from '../text';
34
export interface CheckboxProps extends TouchableOpacityProps {
45
/**
56
* The value of the Checkbox. If true the switch will be turned on. Default value is false.
@@ -45,6 +46,10 @@ export interface CheckboxProps extends TouchableOpacityProps {
4546
* The style of the label
4647
*/
4748
labelStyle?: StyleProp<TextStyle>;
49+
/**
50+
* Props that will be passed to the checkbox Text label.
51+
*/
52+
labelProps?: Omit<TextProps, 'style'>;
4853
/**
4954
* Additional styling
5055
*/

src/components/checkbox/index.tsx

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import {Colors, Spacings} from '../../style';
1515
import Assets from '../../assets';
1616
import {asBaseComponent} from '../../commons/new';
1717
import TouchableOpacity from '../touchableOpacity';
18-
import Text from '../text';
18+
import Text, {TextProps} from '../text';
1919
import View from '../view';
2020

2121
const DEFAULT_SIZE = 24;
@@ -71,6 +71,10 @@ export interface CheckboxProps extends TouchableOpacityProps {
7171
* The style of the label
7272
*/
7373
labelStyle?: StyleProp<TextStyle>;
74+
/**
75+
* Props that will be passed to the checkbox Text label.
76+
*/
77+
labelProps?: Omit<TextProps, 'style'>;
7478
/**
7579
* Additional styling
7680
*/
@@ -236,11 +240,11 @@ class Checkbox extends Component<CheckboxProps, CheckboxState> {
236240
}
237241

238242
render() {
239-
const {label, labelStyle, containerStyle} = this.props;
243+
const {label, labelStyle, containerStyle, labelProps} = this.props;
240244
return label ? (
241245
<View row centerV style={[containerStyle]}>
242246
{this.renderCheckbox()}
243-
<Text style={[this.styles.checkboxLabel, labelStyle]} onPress={this.onPress}>
247+
<Text style={[this.styles.checkboxLabel, labelStyle]} {...labelProps} onPress={this.onPress}>
244248
{label}
245249
</Text>
246250
</View>

0 commit comments

Comments
 (0)