Skip to content
This repository was archived by the owner on Feb 4, 2021. It is now read-only.

Allow the RadioButton label to be able to display a view element #90

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
21 changes: 12 additions & 9 deletions lib/RadioButton.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const typos = StyleSheet.create(TYPO);
export default class RadioButton extends Component {

static propTypes = {
label: PropTypes.string,
label: PropTypes.oneOfType([PropTypes.string, PropTypes.element]),
theme: PropTypes.oneOf(THEME_NAME),
primary: PropTypes.oneOf(PRIMARY_COLORS),
value: PropTypes.oneOfType([PropTypes.string, PropTypes.number]).isRequired,
Expand Down Expand Up @@ -101,18 +101,21 @@ export default class RadioButton extends Component {
/>
</IconToggle>
<View style={styles.labelContainer}>
<Text
{typeof(this.props.label) !== 'string'
? this.props.label
: <Text
style={[
typos.paperFontBody1,
styles.label,
COLOR[`${theme}PrimaryOpacity`],
disabled && COLOR[`${theme}DisabledOpacity`], {
color: LABEL_COLOR
}
]}
typos.paperFontBody1,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

formatting?

styles.label,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

formatting?

COLOR[`${theme}PrimaryOpacity`],
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

formatting?

disabled && COLOR[`${theme}DisabledOpacity`], {
color: LABEL_COLOR
}
]}
>
{this.props.label}
</Text>
}
</View>
</View>
</TouchableHighlight>
Expand Down
2 changes: 1 addition & 1 deletion lib/RadioButtonGroup.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export default class RadioButtonGroup extends Component {
selected: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
items: PropTypes.arrayOf(PropTypes.shape({
value: PropTypes.oneOfType([PropTypes.string, PropTypes.number]).isRequired,
label: PropTypes.string,
label: PropTypes.oneOfType([PropTypes.string, PropTypes.element]),
disabled: PropTypes.bool
}))
};
Expand Down