🆕 Add style for Checkbox & Radio Group options (#21219)

close #19739
This commit is contained in:
偏右 2020-02-04 17:34:02 +08:00 committed by GitHub
parent 6d685c7e8a
commit fd8d71717b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 7 additions and 2 deletions

View File

@ -11,6 +11,7 @@ export type CheckboxValueType = string | number | boolean;
export interface CheckboxOptionType {
label: React.ReactNode;
value: CheckboxValueType;
style?: React.CSSProperties;
disabled?: boolean;
onChange?: (e: CheckboxChangeEvent) => void;
}
@ -152,6 +153,7 @@ class CheckboxGroup extends React.Component<CheckboxGroupProps, CheckboxGroupSta
checked={state.value.indexOf(option.value) !== -1}
onChange={option.onChange}
className={`${groupPrefixCls}-item`}
style={option.style}
>
{option.label}
</Checkbox>

View File

@ -25,6 +25,7 @@ exports[`CheckboxGroup passes prefixCls down to checkbox 1`] = `
</label>
<label
class="my-checkbox-group-item my-checkbox-wrapper"
style="font-size:12px"
>
<span
class="my-checkbox"

View File

@ -90,7 +90,7 @@ describe('CheckboxGroup', () => {
it('passes prefixCls down to checkbox', () => {
const options = [
{ label: 'Apple', value: 'Apple' },
{ label: 'Orange', value: 'Orange' },
{ label: 'Orange', value: 'Orange', style: { fontSize: 12 } },
];
const wrapper = render(<Checkbox.Group prefixCls="my-checkbox" options={options} />);

View File

@ -25,6 +25,7 @@ exports[`Radio Group passes prefixCls down to radio 1`] = `
</label>
<label
class="my-radio-wrapper"
style="font-size:12px"
>
<span
class="my-radio"

View File

@ -170,7 +170,7 @@ describe('Radio Group', () => {
});
it('passes prefixCls down to radio', () => {
const options = [{ label: 'Apple', value: 'Apple' }, { label: 'Orange', value: 'Orange' }];
const options = [{ label: 'Apple', value: 'Apple' }, { label: 'Orange', value: 'Orange', style: { fontSize: 12 } }];
const wrapper = render(<RadioGroup prefixCls="my-radio" options={options} />);

View File

@ -133,6 +133,7 @@ class RadioGroup extends React.Component<RadioGroupProps, RadioGroupState> {
disabled={option.disabled || this.props.disabled}
value={option.value}
checked={this.state.value === option.value}
style={option.style}
>
{option.label}
</Radio>