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 all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 4 additions & 2 deletions components/checkbox/Group.tsx
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
Expand Up @@ -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>
Expand Down
Expand Up @@ -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"
/>
`;
2 changes: 1 addition & 1 deletion components/checkbox/demo/controller.md
Expand Up @@ -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}
Expand Down
1 change: 1 addition & 0 deletions components/checkbox/style/index.less
@@ -1,4 +1,5 @@
@import '../../style/themes/index';
@import './mixin';
@import './rtl';

.antCheckboxFn();
22 changes: 22 additions & 0 deletions components/checkbox/style/rtl.less
@@ -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;
}
}
}
}