Skip to content

Commit

Permalink
feat(Radio): disabled item state
Browse files Browse the repository at this point in the history
  • Loading branch information
zouxuoz committed Mar 19, 2020
1 parent c237a90 commit 20d8e52
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 9 deletions.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions src/components/Radio/Radio.theme.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@ const [RadioCircleTag, themeCircle] = createThemeTag(`${name}Circle`, ({ COLORS
hasError: {
borderColor: COLORS.DANGER,
},

disabled: {
backgroundColor: COLORS.GRAY_10,
},
},
}));

Expand Down
6 changes: 3 additions & 3 deletions src/components/Radio/RadioGroup.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ type RadioProps = {
/** then true when show error styles */
hasError?: boolean,
/** options to define radio items */
options?: Array<({ value: any, label: string })>,
options?: Array<({ value: any, label: string, disabled?: boolean })>,
/** disabled */
disabled?: boolean,
/** stretch */
Expand Down Expand Up @@ -53,8 +53,8 @@ class RadioGroup extends PureComponent<RadioProps> {
}

// $FlowFixMe
return options.map(({ value, label }) => (
<RadioItem key={ value } label={ label } value={ value } />
return options.map(({ value, label, disabled }) => (
<RadioItem key={ value } label={ label } value={ value } disabled={ disabled || this.props.disabled } />
));
}

Expand Down
2 changes: 1 addition & 1 deletion src/components/RadioGroupField/RadioGroupField.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ type RadioGroupFieldProps = {
/** direction of the radio items */
direction?: 'row' | 'column',
/** options to define radio items */
options?: Array<({ value: any, label: string })>,
options?: Array<({ value: any, label: string, disabled?: boolean })>,
/** disabled */
disabled?: boolean,
/** stretch */
Expand Down
14 changes: 9 additions & 5 deletions src/components/RadioGroupField/RadioGroupField.stories.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,15 @@ button.story = {
};

export const disabledStory = () => (
<RadioGroupField direction="row" input={{ value: 1 }} meta={{}} disabled>
<Radio.Item label="Radio" value={ 1 } />
<Radio.Item label="Radio" value={ 2 } />
<Radio.Item label="Radio" value={ 3 } />
</RadioGroupField>
<React.Fragment>
<RadioGroupField direction="row" input={{ value: 1 }} meta={{}} disabled>
<Radio.Item label="Radio" value={ 1 } />
<Radio.Item label="Radio" value={ 2 } />
<Radio.Item label="Radio" value={ 3 } />
</RadioGroupField>

<RadioGroupField direction="row" input={{ value: 3 }} meta={{}} options={ [{ label: '1', value: 1 }, { label: '2', value: 2, disabled: true }, { label: '3', value: 3, disabled: true }] } />
</React.Fragment>
);

disabledStory.story = {
Expand Down

0 comments on commit 20d8e52

Please sign in to comment.