Skip to content
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

Update Radio Checkbox Design #30791

Merged
merged 3 commits into from
Nov 9, 2023
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
17 changes: 10 additions & 7 deletions src/components/RadioButton.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import PropTypes from 'prop-types';
import React from 'react';
import {View} from 'react-native';
import styles from '@styles/styles';
import themeColors from '@styles/themes/default';
import CONST from '@src/CONST';
import Icon from './Icon';
import * as Expensicons from './Icon/Expensicons';
Expand Down Expand Up @@ -39,13 +40,15 @@ function RadioButton(props) {
accessibilityLabel={props.accessibilityLabel}
accessibilityRole={CONST.ACCESSIBILITY_ROLE.RADIO}
>
<View style={[styles.radioButtonContainer, props.isChecked && styles.checkedContainer, props.hasError && styles.borderColorDanger, props.disabled && styles.cursorDisabled]}>
<Icon
src={Expensicons.Checkmark}
fill="white"
height={14}
width={14}
/>
<View style={[styles.radioButtonContainer, props.hasError && styles.borderColorDanger, props.disabled && styles.cursorDisabled]}>
{props.isChecked && (
<Icon
src={Expensicons.Checkmark}
fill={themeColors.checkBox}
height={14}
width={14}
/>
)}
</View>
</PressableWithFeedback>
);
Expand Down
4 changes: 2 additions & 2 deletions src/components/RadioButtonWithLabel.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,8 @@ function RadioButtonWithLabel(props) {
style={[styles.flexRow, styles.flexWrap, styles.flexShrink1, styles.alignItemsCenter]}
wrapperStyle={[styles.ml3, styles.pr2, styles.w100]}
// disable hover style when disabled
hoverDimmingValue={1}
pressDimmingValue={0.2}
hoverDimmingValue={0.8}
pressDimmingValue={0.5}
>
{Boolean(props.label) && <Text style={[styles.ml1]}>{props.label}</Text>}
{Boolean(LabelComponent) && <LabelComponent />}
Expand Down
36 changes: 36 additions & 0 deletions src/stories/RadioButtonWithLabel.stories.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import React from 'react';
import RadioButtonWithLabel from '@components/RadioButtonWithLabel';

/**
* We use the Component Story Format for writing stories. Follow the docs here:
*
* https://storybook.js.org/docs/react/writing-stories/introduction#component-story-format
*/
const story = {
title: 'Components/RadioButtonWithLabel',
component: RadioButtonWithLabel,
};

function Template(args) {
// eslint-disable-next-line react/jsx-props-no-spreading
return <RadioButtonWithLabel {...args} />;
}

// Arguments can be passed to the component by binding
// See: https://storybook.js.org/docs/react/writing-stories/introduction#using-args
const Default = Template.bind({});
const Checked = Template.bind({});
Default.args = {
isChecked: false,
label: 'This radio button is unchecked',
onInputChange: () => {},
};

Checked.args = {
isChecked: true,
label: 'This radio button is checked',
onInputChange: () => {},
};

export default story;
export {Default, Checked};
2 changes: 1 addition & 1 deletion src/styles/styles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2567,7 +2567,7 @@ const styles = (theme: ThemeDefault) =>
borderRadius: 10,
height: 20,
width: 20,
borderColor: theme.icon,
borderColor: theme.border,
borderWidth: 1,
justifyContent: 'center',
alignItems: 'center',
Expand Down
Loading