mirror of
https://github.com/ant-design/ant-design.git
synced 2024-11-24 02:59:58 +08:00
style: add checkout grop RTL (#22186)
* style: add checkout grop RTL * style: add rtl.less * fix: add test * fix: add group test * Apply suggestions from code review * Apply suggestions from code review Co-authored-by: 偏右 <afc163@gmail.com>
This commit is contained in:
parent
313f71a3c1
commit
b032344d81
@ -125,7 +125,7 @@ class CheckboxGroup extends React.PureComponent<CheckboxGroupProps, CheckboxGrou
|
||||
}
|
||||
};
|
||||
|
||||
renderGroup = ({ getPrefixCls }: ConfigConsumerProps) => {
|
||||
renderGroup = ({ getPrefixCls, direction }: ConfigConsumerProps) => {
|
||||
const { props, state } = this;
|
||||
const { prefixCls: customizePrefixCls, className, style, options, ...restProps } = props;
|
||||
const prefixCls = getPrefixCls('checkbox', customizePrefixCls);
|
||||
@ -162,7 +162,9 @@ class CheckboxGroup extends React.PureComponent<CheckboxGroupProps, CheckboxGrou
|
||||
cancelValue: this.cancelValue,
|
||||
};
|
||||
|
||||
const classString = classNames(groupPrefixCls, className);
|
||||
const classString = classNames(groupPrefixCls, className, {
|
||||
[`${groupPrefixCls}-rtl`]: direction === 'rtl',
|
||||
});
|
||||
return (
|
||||
<div className={classString} style={style} {...domProps}>
|
||||
<GroupContext.Provider value={context}>{children}</GroupContext.Provider>
|
||||
|
@ -148,7 +148,7 @@ exports[`renders ./components/checkbox/demo/controller.md correctly 1`] = `
|
||||
</button>
|
||||
<button
|
||||
class="ant-btn ant-btn-primary ant-btn-sm"
|
||||
style="margin-left:10px"
|
||||
style="margin:0 10px"
|
||||
type="button"
|
||||
>
|
||||
<span>
|
||||
|
@ -48,6 +48,6 @@ exports[`CheckboxGroup passes prefixCls down to checkbox 1`] = `
|
||||
|
||||
exports[`CheckboxGroup rtl render component should be rendered correctly in RTL direction 1`] = `
|
||||
<div
|
||||
class="ant-checkbox-group"
|
||||
class="ant-checkbox-group ant-checkbox-group-rtl"
|
||||
/>
|
||||
`;
|
||||
|
@ -57,7 +57,7 @@ class App extends React.Component {
|
||||
{!this.state.checked ? 'Check' : 'Uncheck'}
|
||||
</Button>
|
||||
<Button
|
||||
style={{ marginLeft: '10px' }}
|
||||
style={{ margin: '0 10px' }}
|
||||
type="primary"
|
||||
size="small"
|
||||
onClick={this.toggleDisable}
|
||||
|
@ -1,4 +1,5 @@
|
||||
@import '../../style/themes/index';
|
||||
@import './mixin';
|
||||
@import './rtl';
|
||||
|
||||
.antCheckboxFn();
|
||||
|
22
components/checkbox/style/rtl.less
Normal file
22
components/checkbox/style/rtl.less
Normal file
@ -0,0 +1,22 @@
|
||||
@import '../../style/mixins/index';
|
||||
|
||||
.antCheckboxFn(@checkbox-prefix-cls: ~'@{ant-prefix}-checkbox') {
|
||||
.@{checkbox-prefix-cls}-group {
|
||||
&-item {
|
||||
.@{checkbox-prefix-cls}-group-rtl & {
|
||||
margin-right: 0;
|
||||
margin-left: 8px;
|
||||
}
|
||||
&:last-child {
|
||||
.@{checkbox-prefix-cls}-group-rtl & {
|
||||
margin-left: 0 !important;
|
||||
}
|
||||
}
|
||||
}
|
||||
&-item + &-item {
|
||||
.@{checkbox-prefix-cls}-group-rtl & {
|
||||
margin-left: 8px;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user