Skip to content

Feat/add labelProps prop #1252

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Apr 20, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions generatedTypes/components/checkbox/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import React from 'react';
import { StyleProp, TouchableOpacityProps, ViewStyle, TextStyle } from 'react-native';
import { TextProps } from '../text';
export interface CheckboxProps extends TouchableOpacityProps {
/**
* The value of the Checkbox. If true the switch will be turned on. Default value is false.
Expand Down Expand Up @@ -45,6 +46,10 @@ export interface CheckboxProps extends TouchableOpacityProps {
* The style of the label
*/
labelStyle?: StyleProp<TextStyle>;
/**
* Props that will be passed to the checkbox Text label.
*/
labelProps?: Omit<TextProps, 'style'>;
/**
* Additional styling
*/
Expand Down
10 changes: 7 additions & 3 deletions src/components/checkbox/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import {Colors, Spacings} from '../../style';
import Assets from '../../assets';
import {asBaseComponent} from '../../commons/new';
import TouchableOpacity from '../touchableOpacity';
import Text from '../text';
import Text, {TextProps} from '../text';
import View from '../view';

const DEFAULT_SIZE = 24;
Expand Down Expand Up @@ -71,6 +71,10 @@ export interface CheckboxProps extends TouchableOpacityProps {
* The style of the label
*/
labelStyle?: StyleProp<TextStyle>;
/**
* Props that will be passed to the checkbox Text label.
*/
labelProps?: Omit<TextProps, 'style'>;
/**
* Additional styling
*/
Expand Down Expand Up @@ -236,11 +240,11 @@ class Checkbox extends Component<CheckboxProps, CheckboxState> {
}

render() {
const {label, labelStyle, containerStyle} = this.props;
const {label, labelStyle, containerStyle, labelProps} = this.props;
return label ? (
<View row centerV style={[containerStyle]}>
{this.renderCheckbox()}
<Text style={[this.styles.checkboxLabel, labelStyle]} onPress={this.onPress}>
<Text style={[this.styles.checkboxLabel, labelStyle]} {...labelProps} onPress={this.onPress}>
{label}
</Text>
</View>
Expand Down