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

style: add checkbox grop RTL #22186

Merged
merged 6 commits into from
Mar 13, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
6 changes: 4 additions & 2 deletions components/checkbox/Group.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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>
Expand Down
2 changes: 1 addition & 1 deletion components/checkbox/demo/controller.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ class App extends React.Component {
{!this.state.checked ? 'Check' : 'Uncheck'}
</Button>
<Button
style={{ marginLeft: '10px' }}
style={{ margin: '10px' }}
afc163 marked this conversation as resolved.
Show resolved Hide resolved
type="primary"
size="small"
onClick={this.toggleDisable}
Expand Down
10 changes: 10 additions & 0 deletions components/checkbox/style/mixin.less
Original file line number Diff line number Diff line change
Expand Up @@ -171,12 +171,22 @@
&-item {
display: inline-block;
margin-right: 8px;
.@{checkbox-prefix-cls}-group-rtl & {
margin-right: 0;
margin-left: 8px;
}
&:last-child {
margin-right: 0;
.@{checkbox-prefix-cls}-group-rtl & {
margin-left: 0 !important;
}
}
}
&-item + &-item {
margin-left: 0;
.@{checkbox-prefix-cls}-group-rtl & {
margin-left: 8px;
}
Copy link
Member

Choose a reason for hiding this comment

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

感觉给每个组件单独创建一个 rtl.less,这样相关代码收在一起比较好改。

Copy link
Member Author

Choose a reason for hiding this comment

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

是啊,我先用这个改一下试试

}
}

Expand Down