From 676de29eb42b42a31ef67f6ec2a17007490996c3 Mon Sep 17 00:00:00 2001 From: Saeed Rahimi Date: Thu, 2 Jan 2020 14:40:16 +0330 Subject: [PATCH] feat: added rtl direction to all of ant-design components (#19380) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * rtl demo change en-us description * change bundlesize css limit * RTL: modal component (exclude confirm) * RTL: table component * RTL: pagination component * cleanup rtl demo * fix pagination.tsx compile error * RTL: button and button-group * RTL: Steps component * fix rtl demo style * fix input suffix icon alignment * fix select component arrow issue * RTL: form component * add pagination rtl test * fix test lint error * RTL: rate component * RTL: radio and radio group components * RTL: tree-select component * some fixes to RTL components * RTL: badge component * fix rtl issue in inline form * fix input component rtl padding issue * fix switch component text rtl issue * fix table grouped header text-align * add rtl support to whole demo with RTL button * Update rtl demo responsive * RTL: page-header component * RTL: typography component * RTL: Dropdown (Partial) * update config-provider doc * RTL: input component * RTL: select component * RTL: switch component * RTL: tree component * fix rtl demo lint * rtl demo change en-us description * RTL: modal component (exclude confirm) * RTL: table component * RTL: pagination component * cleanup rtl demo * RTL: button and button-group * RTL: Steps component * fix rtl demo style * fix input suffix icon alignment * RTL: form component * RTL: rate component * RTL: radio and radio group components * RTL: tree-select component * RTL: badge component * fix rtl issue in inline form * fix input component rtl padding issue * add rtl support to whole demo with RTL button * fix lost changes after rebase * fix lint errors * RTL: Transfer Component * RTL: upload component * RTL: update avatar demo * RTL: comment component * RTL: collapse component * RTL: carousel component * update snapshots * RTL: Card component * RTL: descriptions component * RTL: Empty component * RTL: list component * RTL: slider component * slider component import/order * add shared rtlTest * RTL: Statistic component * RTL: tooltip components * RTL: popover component * RTL: timeline component * RTL: tag component * RTL: alert component * RTL: drawer component * RTL: Tab component * change direction definition * RTL: progress component * input.tsx, remove duplicate after rebase * fix demo.less after rebase * fix ant-row-rtl after rebase * fix upload issues in rtl * badge rtl demo margin fix * fix: tabs with icon margin * fix: radio-wrapper margin * fix: table component after rebase * fix: centered modal text-align * update slider snapshot * RTL: popconfirm component * RTL: back-top component * RTL: spin component * RTL: result component * RTL: skeleton component * RTL: menu component * RTL: time-picker component * RTL: calendar component * RTL: date-picker component * RTL: home page * update snapshots * test: add auto-complete rtl test * test: add avatar component rtl tests * test: add badge component rtl tests * test: add breadcrumb component rtl tests * test: add button components rtl tests * test: add card component rtl tests * test: add carousel component rtl tests * test: add cascader component rtl tests * test: add checkbox component rtl tests * test: add collapse component rtl tests * test: add comment component rtl tests * test: add dropdown component rtl tests * test: add empty component rtl tests * test: add form component rtl tests * test: add grid component rtl tests * test: add input component rtl tests * test: add search component rtl tests * test: add input-number component rtl tests * test: add layout component rtl tests * test: add list component rtl tests * test: add mentions component rtl tests * test: add modal component rtl tests * test: add page-header component rtl tests * test: add pagination component rtl tests * test: add radio component rtl tests * test: add rate component rtl tests * test: add select component rtl tests * test: add slider component rtl tests * test: add steps component rtl tests * test: add switch component rtl tests * test: add table component rtl tests * test: add transfer component rtl tests * test: add tree component rtl tests * test: add tree-select component rtl tests * test: add typography component rtl tests * test: add upload component rtl tests * test: add affix component rtl tests * update calendar tests * increase css file maxSize * update snapshots * remove workflows to allow push * remove duplicate reverse prop from slider * fix: remove table demo from config-provider * fix: remove table demo from config-provider * fix lint error * Added direction property to ConfigProvider * cascader rtl tests added * update config-provider doc * RTL: grid system * RTL: input component * RTL: switch component * fix rtl demo lint * RTL: modal component (exclude confirm) * RTL: table component * RTL: pagination component * cleanup rtl demo * fix pagination.tsx compile error * RTL: button and button-group * RTL: Steps component * fix rtl demo style * RTL: form component * add pagination rtl test * RTL: rate component * RTL: radio and radio group components * RTL: tree-select component * RTL: badge component * fix rtl issue in inline form * fix input component rtl padding issue * add rtl support to whole demo with RTL button * RTL: input component * RTL: select component * RTL: switch component * RTL: tree component * fix rtl demo lint * rtl demo change en-us description * RTL: modal component (exclude confirm) * RTL: table component * RTL: pagination component * cleanup rtl demo * RTL: button and button-group * RTL: Steps component * fix rtl demo style * fix input suffix icon alignment * RTL: form component * RTL: rate component * RTL: radio and radio group components * RTL: tree-select component * RTL: badge component * fix rtl issue in inline form * fix input component rtl padding issue * add rtl support to whole demo with RTL button * input.tsx, remove duplicate after rebase * fix ant-row-rtl after rebase * update snapshots * test: add cascader component rtl tests * test: add pagination component rtl tests * update calendar tests * update snapshots * fix: remove table demo from config-provider * fix: remove table demo from config-provider * fix lint error * update direction.md icons * dropdown and cascader default placement in rtl * update snapshots * fix lint errors * remove duplicate import * update snapshots * update snapshot * update calendar snapshot * update snapshots * integrate with new rc-picker * update snapshots * fix lint errors * update snapshot * update snapshots * update snapshots * update snapshots :| * update snapshots * fix compile error. * fix typo after rebase * update snapshots * remove workflows to allow push * update snapshots * update snapshots * fix dist error * front-page css fix * update snapshots * fix lint and test issues * restore cascader index.less * update snapshots * fix logo in rtl and demo controls * ci errors * resolve steps/index.tsx conflicts * tooltip family demo remove inline style * resolve table/Table.tsx conflicts * resolve modal/Modal.tsx conflicts * resolve cascader/index.tsx conflicts * add workflows from upstream * update snapshots * revert logo to default * fix codebox demo direction of placements * resolve tooltip overlayClassName conflicts * update snapshots * update popover test * fix: cascader miss popupClassName * fix: fix select missing dropdownClassName * chore: Update snapshot * chore: Adjust menu use rtl logic * docs: Update demo line color Co-authored-by: 二货机器人 --- components/affix/__tests__/Affix.test.js | 3 + .../__snapshots__/Affix.test.js.snap | 9 + .../__snapshots__/index.test.js.snap | 14 + components/alert/__tests__/index.test.js | 3 + components/alert/index.tsx | 3 +- components/alert/style/index.less | 34 + .../__snapshots__/index.test.js.snap | 30 + .../auto-complete/__tests__/index.test.js | 2 + components/avatar/__tests__/Avatar.test.js | 2 + .../__snapshots__/Avatar.test.js.snap | 12 + .../__tests__/__snapshots__/demo.test.js.snap | 2 +- components/avatar/demo/badge.md | 14 +- .../__snapshots__/index.test.js.snap | 3 + components/back-top/__tests__/index.test.js | 2 + components/back-top/index.tsx | 6 +- components/back-top/style/index.less | 5 + .../__snapshots__/index.test.js.snap | 6 + components/badge/__tests__/index.test.js | 2 + components/badge/demo/basic.md | 4 + components/badge/demo/no-wrapper.md | 4 + components/badge/demo/title.md | 6 + components/badge/index.tsx | 9 +- components/badge/style/index.less | 51 + .../breadcrumb/__tests__/Breadcrumb.test.js | 2 + .../__snapshots__/Breadcrumb.test.js.snap | 6 + .../__snapshots__/index.test.js.snap | 39 + components/button/__tests__/index.test.js | 8 + components/button/button-group.tsx | 3 +- components/button/button.tsx | 3 +- components/button/style/index.less | 41 + components/button/style/mixin.less | 31 + .../__snapshots__/index.test.js.snap | 950 ++++++++++++++++++ components/calendar/__tests__/index.test.js | 2 + .../__snapshots__/index.test.js.snap | 10 + components/card/__tests__/index.test.js | 2 + components/card/index.tsx | 3 +- components/card/style/index.less | 24 + .../__snapshots__/index.test.js.snap | 19 + components/carousel/__tests__/index.test.js | 2 + components/carousel/index.tsx | 9 +- components/carousel/style/index.less | 93 +- .../__snapshots__/index.test.js.snap | 401 ++++++++ components/cascader/__tests__/index.test.js | 133 +++ components/cascader/index.tsx | 39 +- components/cascader/style/index.less | 49 + .../__snapshots__/checkbox.test.js.snap | 19 + .../__snapshots__/group.test.js.snap | 6 + .../checkbox/__tests__/checkbox.test.js | 2 + components/checkbox/__tests__/group.test.js | 2 + components/collapse/Collapse.tsx | 3 +- .../__snapshots__/index.test.js.snap | 6 + components/collapse/__tests__/index.test.js | 2 + components/collapse/style/index.less | 22 + .../__tests__/__snapshots__/demo.test.js.snap | 4 +- .../__snapshots__/index.test.js.snap | 25 + components/comment/__tests__/index.test.js | 2 + components/comment/demo/basic.md | 17 +- components/comment/index.tsx | 7 +- components/comment/style/index.less | 29 + components/config-provider/context.tsx | 1 + components/config-provider/demo/direction.md | 613 +++++++++++ components/config-provider/index.en-US.md | 1 + components/config-provider/index.tsx | 3 + components/config-provider/index.zh-CN.md | 1 + .../__snapshots__/mount.test.js.snap | 188 ++++ .../date-picker/__tests__/mount.test.js | 6 + components/date-picker/generatePicker.tsx | 6 +- components/date-picker/style/index.less | 34 + components/date-picker/style/panel.less | 76 ++ components/descriptions/index.tsx | 3 +- components/descriptions/style/index.less | 8 + components/drawer/__tests__/Drawer.test.js | 2 + .../__snapshots__/Drawer.test.js.snap | 2 + components/drawer/demo/multi-level-drawer.md | 24 +- components/drawer/index.tsx | 7 +- components/drawer/style/drawer.less | 17 + .../dropdown-button.test.js.snap | 42 + .../__tests__/dropdown-button.test.js | 8 + components/dropdown/dropdown.tsx | 21 +- components/dropdown/style/index.less | 40 + .../__snapshots__/index.test.js.snap | 151 +++ components/empty/__tests__/index.test.js | 14 +- components/empty/index.tsx | 3 +- components/empty/style/index.less | 4 + components/form/Form.tsx | 3 +- .../__snapshots__/index.test.js.snap | 20 + components/form/__tests__/index.test.js | 4 + components/form/style/index.less | 39 + components/form/style/inline.less | 5 + components/form/style/vertical.less | 3 + .../__snapshots__/index.test.js.snap | 12 + components/grid/__tests__/index.test.js | 4 + components/grid/col.tsx | 3 +- components/grid/row.tsx | 3 +- components/grid/style/index.less | 8 + components/grid/style/mixin.less | 39 + .../__snapshots__/index.test.js.snap | 81 ++ .../input-number/__tests__/index.test.js | 2 + components/input/ClearableLabeledInput.tsx | 6 +- components/input/Group.tsx | 3 +- components/input/Input.tsx | 10 +- components/input/Search.tsx | 7 +- components/input/__tests__/Password.test.js | 2 + components/input/__tests__/Search.test.js | 2 + .../__snapshots__/Password.test.js.snap | 41 + .../__snapshots__/Search.test.js.snap | 37 + .../__snapshots__/index.test.js.snap | 14 + components/input/__tests__/index.test.js | 4 + components/input/style/index.less | 6 + components/input/style/mixin.less | 81 ++ components/input/style/search-input.less | 19 + .../__snapshots__/index.test.js.snap | 23 + components/layout/__tests__/index.test.js | 5 + components/layout/layout.tsx | 7 +- components/list/__tests__/Item.test.js | 26 +- .../__tests__/__snapshots__/Item.test.js.snap | 57 ++ .../__snapshots__/index.test.js.snap | 72 ++ components/list/__tests__/index.test.js | 4 + components/list/index.tsx | 3 +- components/list/style/index.less | 54 + components/list/style/responsive.less | 20 + .../__snapshots__/index.test.js.snap | 11 + components/mentions/__tests__/index.test.js | 2 + components/menu/MenuContext.tsx | 1 + components/menu/MenuItem.tsx | 5 +- .../__snapshots__/index.test.js.snap | 38 + components/menu/__tests__/index.test.js | 9 + components/menu/index.tsx | 30 +- components/menu/style/index.less | 79 ++ components/modal/Modal.tsx | 8 +- components/modal/__tests__/Modal.test.js | 2 + .../__snapshots__/Modal.test.js.snap | 2 + components/modal/style/modal.less | 23 + .../__snapshots__/index.test.js.snap | 22 + .../page-header/__tests__/index.test.js | 13 + components/page-header/index.tsx | 23 +- components/page-header/style/index.less | 59 +- components/pagination/Pagination.tsx | 32 +- .../__snapshots__/index.test.js.snap | 192 ++++ components/pagination/__tests__/index.test.js | 14 + components/pagination/style/index.less | 39 + .../__snapshots__/index.test.js.snap | 2 + components/popconfirm/__tests__/index.test.js | 2 + .../__snapshots__/index.test.js.snap | 39 + components/popover/__tests__/index.test.js | 14 +- components/popover/style/index.less | 20 + .../__snapshots__/index.test.js.snap | 27 + components/progress/__tests__/index.test.js | 2 + components/progress/demo/format.md | 5 + components/progress/progress.tsx | 3 +- components/progress/style/index.less | 22 + .../__snapshots__/radio.test.js.snap | 42 + components/radio/__tests__/radio.test.js | 5 + components/radio/group.tsx | 3 +- components/radio/radio.tsx | 3 +- components/radio/style/index.less | 23 + .../__snapshots__/index.test.js.snap | 310 ++++++ components/rate/__tests__/index.test.js | 2 + components/rate/index.tsx | 12 +- components/rate/style/index.less | 19 + .../__snapshots__/index.test.js.snap | 35 + components/result/__tests__/index.test.js | 2 + components/result/index.tsx | 6 +- components/result/style/index.less | 13 + .../__snapshots__/index.test.js.snap | 58 ++ components/select/__tests__/index.test.js | 2 + components/select/index.tsx | 8 +- components/select/style/index.less | 17 + components/select/style/multiple.less | 26 + components/select/style/single.less | 18 + components/skeleton/Skeleton.tsx | 3 +- .../__snapshots__/index.test.js.snap | 24 + components/skeleton/__tests__/index.test.js | 2 + components/skeleton/style/index.less | 27 + .../__snapshots__/index.test.js.snap | 80 ++ components/slider/__tests__/index.test.js | 12 + components/slider/index.tsx | 13 +- components/slider/style/index.less | 44 + .../__snapshots__/index.test.js.snap | 23 + components/spin/__tests__/index.test.js | 2 + components/spin/index.tsx | 3 +- components/spin/style/index.less | 15 + components/statistic/Statistic.tsx | 7 +- .../__snapshots__/index.test.js.snap | 20 + components/statistic/__tests__/index.test.js | 2 + components/statistic/style/index.less | 14 + .../__snapshots__/index.test.js.snap | 7 + components/steps/__tests__/index.test.js | 2 + components/steps/index.tsx | 16 +- components/steps/style/custom-icon.less | 5 + components/steps/style/index.less | 43 + components/steps/style/nav.less | 23 + components/steps/style/progress-dot.less | 50 + components/steps/style/small.less | 10 + components/steps/style/vertical.less | 17 + components/style/themes/default.less | 1 + .../__snapshots__/index.test.js.snap | 13 + components/switch/__tests__/index.test.js | 2 + components/switch/index.tsx | 3 +- components/switch/style/index.less | 44 +- components/table/Table.tsx | 10 +- components/table/__tests__/Table.test.js | 2 + .../__snapshots__/Table.test.js.snap | 173 ++++ components/table/style/index.less | 57 ++ components/tabs/TabBar.tsx | 16 +- .../__snapshots__/index.test.js.snap | 131 +++ components/tabs/__tests__/index.test.js | 6 + components/tabs/index.tsx | 3 +- components/tabs/style/card-style.less | 9 + components/tabs/style/index.less | 34 + .../__snapshots__/index.test.js.snap | 12 + components/tag/__tests__/index.test.js | 3 + components/tag/index.tsx | 3 +- components/tag/style/index.less | 12 + .../__snapshots__/index.test.js.snap | 44 + .../time-picker/__tests__/index.test.js | 2 + components/timeline/Timeline.tsx | 3 +- .../__snapshots__/index.test.js.snap | 23 + components/timeline/__tests__/index.test.js | 3 + components/timeline/style/index.less | 67 ++ .../__snapshots__/tooltip.test.js.snap | 2 + components/tooltip/__tests__/tooltip.test.js | 2 + components/tooltip/index.tsx | 6 + components/tooltip/style/index.less | 8 + .../__snapshots__/index.test.js.snap | 237 +++++ components/transfer/__tests__/index.test.js | 2 + components/transfer/index.tsx | 4 +- components/transfer/operation.tsx | 6 +- components/transfer/style/index.less | 43 + .../__snapshots__/index.test.js.snap | 58 ++ .../tree-select/__tests__/index.test.js | 2 + components/tree-select/index.tsx | 5 + components/tree-select/style/index.less | 19 + components/tree/DirectoryTree.tsx | 6 +- components/tree/Tree.tsx | 3 +- .../__snapshots__/directory.test.js.snap | 52 + components/tree/__tests__/directory.test.js | 4 + components/tree/style/index.less | 17 + components/typography/Base.tsx | 3 +- components/typography/Editable.tsx | 10 +- components/typography/Typography.tsx | 8 +- .../__snapshots__/index.test.js.snap | 22 + components/typography/__tests__/index.test.js | 5 + components/typography/style/index.less | 24 + components/upload/Upload.tsx | 3 +- components/upload/UploadList.tsx | 3 +- .../__snapshots__/upload.test.js.snap | 27 + components/upload/__tests__/upload.test.js | 2 + components/upload/demo/picture-style.md | 4 + components/upload/style/index.less | 112 +++ package.json | 6 +- site/theme/static/common.less | 16 + site/theme/static/demo.less | 56 ++ site/theme/static/footer.less | 14 + site/theme/static/header.less | 60 +- site/theme/static/markdown.less | 35 + site/theme/static/responsive.less | 3 +- site/theme/static/toc.less | 27 + site/theme/template/Content/ComponentDoc.jsx | 2 +- site/theme/template/Layout/Header.jsx | 30 + site/theme/template/Layout/index.jsx | 26 +- tests/shared/rtlTest.js | 25 + 262 files changed, 7560 insertions(+), 168 deletions(-) create mode 100644 components/affix/__tests__/__snapshots__/Affix.test.js.snap create mode 100644 components/auto-complete/__tests__/__snapshots__/index.test.js.snap create mode 100644 components/avatar/__tests__/__snapshots__/Avatar.test.js.snap create mode 100644 components/back-top/__tests__/__snapshots__/index.test.js.snap create mode 100644 components/checkbox/__tests__/__snapshots__/checkbox.test.js.snap create mode 100644 components/comment/__tests__/__snapshots__/index.test.js.snap create mode 100644 components/config-provider/demo/direction.md create mode 100644 components/date-picker/__tests__/__snapshots__/mount.test.js.snap create mode 100644 components/empty/__tests__/__snapshots__/index.test.js.snap create mode 100644 components/input-number/__tests__/__snapshots__/index.test.js.snap create mode 100644 components/list/__tests__/__snapshots__/index.test.js.snap create mode 100644 components/mentions/__tests__/__snapshots__/index.test.js.snap create mode 100644 components/pagination/__tests__/__snapshots__/index.test.js.snap create mode 100644 components/rate/__tests__/__snapshots__/index.test.js.snap create mode 100644 components/result/__tests__/__snapshots__/index.test.js.snap create mode 100644 components/steps/__tests__/__snapshots__/index.test.js.snap mode change 100755 => 100644 components/table/Table.tsx create mode 100644 components/timeline/__tests__/__snapshots__/index.test.js.snap create mode 100644 components/typography/__tests__/__snapshots__/index.test.js.snap create mode 100644 components/upload/__tests__/__snapshots__/upload.test.js.snap create mode 100644 tests/shared/rtlTest.js diff --git a/components/affix/__tests__/Affix.test.js b/components/affix/__tests__/Affix.test.js index 2caa5f4348..ddf03c9028 100644 --- a/components/affix/__tests__/Affix.test.js +++ b/components/affix/__tests__/Affix.test.js @@ -4,6 +4,7 @@ import Affix from '..'; import { getObserverEntities } from '../utils'; import Button from '../../button'; import { spyElementPrototype } from '../../__tests__/util/domHook'; +import rtlTest from '../../../tests/shared/rtlTest'; const events = {}; @@ -40,6 +41,8 @@ class AffixMounter extends React.Component { } describe('Affix Render', () => { + rtlTest(Affix); + let wrapper; let domMock; diff --git a/components/affix/__tests__/__snapshots__/Affix.test.js.snap b/components/affix/__tests__/__snapshots__/Affix.test.js.snap new file mode 100644 index 0000000000..bd230c7ac4 --- /dev/null +++ b/components/affix/__tests__/__snapshots__/Affix.test.js.snap @@ -0,0 +1,9 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`Affix Render rtl render component should be rendered correctly in RTL direction 1`] = ` +
+
+
+`; diff --git a/components/alert/__tests__/__snapshots__/index.test.js.snap b/components/alert/__tests__/__snapshots__/index.test.js.snap index 81d743625e..b257146da9 100644 --- a/components/alert/__tests__/__snapshots__/index.test.js.snap +++ b/components/alert/__tests__/__snapshots__/index.test.js.snap @@ -21,3 +21,17 @@ exports[`Alert ErrorBoundary 1`] = `
`; + +exports[`Alert rtl render component should be rendered correctly in RTL direction 1`] = ` +
+ + +
+`; diff --git a/components/alert/__tests__/index.test.js b/components/alert/__tests__/index.test.js index 8b88773869..c943db3f2f 100644 --- a/components/alert/__tests__/index.test.js +++ b/components/alert/__tests__/index.test.js @@ -1,10 +1,13 @@ import React from 'react'; import { mount } from 'enzyme'; import Alert from '..'; +import rtlTest from '../../../tests/shared/rtlTest'; const { ErrorBoundary } = Alert; describe('Alert', () => { + rtlTest(Alert); + beforeAll(() => { jest.useFakeTimers(); }); diff --git a/components/alert/index.tsx b/components/alert/index.tsx index a3bf3eb9a0..9253ebaddb 100755 --- a/components/alert/index.tsx +++ b/components/alert/index.tsx @@ -95,7 +95,7 @@ export default class Alert extends React.Component { (this.props.afterClose || noop)(); }; - renderAlert = ({ getPrefixCls }: ConfigConsumerProps) => { + renderAlert = ({ getPrefixCls, direction }: ConfigConsumerProps) => { const { description, prefixCls: customizePrefixCls, @@ -133,6 +133,7 @@ export default class Alert extends React.Component { [`${prefixCls}-no-icon`]: !showIcon, [`${prefixCls}-banner`]: !!banner, [`${prefixCls}-closable`]: closable, + [`${prefixCls}-rtl`]: direction === 'rtl', }, className, ); diff --git a/components/alert/style/index.less b/components/alert/style/index.less index e7cbf863e5..416be69914 100644 --- a/components/alert/style/index.less +++ b/components/alert/style/index.less @@ -11,18 +11,33 @@ word-wrap: break-word; border-radius: @border-radius-base; + &-rtl { + padding: 8px 37px 8px 15px; + direction: rtl; + } + &&-no-icon { padding: 8px 15px; } &&-closable { padding-right: 30px; + + .@{alert-prefix-cls}-rtl& { + padding-right: 15px; + padding-left: 30px; + } } &-icon { position: absolute; top: 8px + @font-size-base * @line-height-base / 2 - @font-size-base / 2; left: 16px; + + .@{alert-prefix-cls}-rtl & { + right: 16px; + left: auto; + } } &-description { @@ -81,6 +96,11 @@ outline: none; cursor: pointer; + .@{alert-prefix-cls}-rtl & { + right: auto; + left: 16px; + } + .@{iconfont-css-prefix}-close { color: @alert-close-color; transition: color 0.3s; @@ -104,6 +124,10 @@ color: @alert-text-color; line-height: @line-height-base; border-radius: @border-radius-base; + + .@{alert-prefix-cls}-rtl& { + padding: 15px 64px 15px 15px; + } } &-with-description&-no-icon { @@ -115,6 +139,11 @@ top: 16px; left: 24px; font-size: 24px; + + .@{alert-prefix-cls}-rtl& { + right: 24px; + left: auto; + } } &-with-description &-close-icon { @@ -123,6 +152,11 @@ right: 16px; font-size: @font-size-base; cursor: pointer; + + .@{alert-prefix-cls}-rtl& { + right: auto; + left: 16px; + } } &-with-description &-message { diff --git a/components/auto-complete/__tests__/__snapshots__/index.test.js.snap b/components/auto-complete/__tests__/__snapshots__/index.test.js.snap new file mode 100644 index 0000000000..cf292e7c55 --- /dev/null +++ b/components/auto-complete/__tests__/__snapshots__/index.test.js.snap @@ -0,0 +1,30 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AutoComplete with Custom Input Element Render rtl render component should be rendered correctly in RTL direction 1`] = ` + +`; diff --git a/components/auto-complete/__tests__/index.test.js b/components/auto-complete/__tests__/index.test.js index 56b1245647..946dc559c9 100644 --- a/components/auto-complete/__tests__/index.test.js +++ b/components/auto-complete/__tests__/index.test.js @@ -2,9 +2,11 @@ import React from 'react'; import { mount } from 'enzyme'; import AutoComplete from '..'; import mountTest from '../../../tests/shared/mountTest'; +import rtlTest from '../../../tests/shared/rtlTest'; describe('AutoComplete with Custom Input Element Render', () => { mountTest(AutoComplete); + rtlTest(AutoComplete); it('AutoComplete with custom Input render perfectly', () => { const wrapper = mount( diff --git a/components/avatar/__tests__/Avatar.test.js b/components/avatar/__tests__/Avatar.test.js index 6380a7bd90..faceb7f08f 100644 --- a/components/avatar/__tests__/Avatar.test.js +++ b/components/avatar/__tests__/Avatar.test.js @@ -2,9 +2,11 @@ import React from 'react'; import { mount } from 'enzyme'; import Avatar from '..'; import mountTest from '../../../tests/shared/mountTest'; +import rtlTest from '../../../tests/shared/rtlTest'; describe('Avatar Render', () => { mountTest(Avatar); + rtlTest(Avatar); let originOffsetWidth; beforeAll(() => { diff --git a/components/avatar/__tests__/__snapshots__/Avatar.test.js.snap b/components/avatar/__tests__/__snapshots__/Avatar.test.js.snap new file mode 100644 index 0000000000..34a6ce2e49 --- /dev/null +++ b/components/avatar/__tests__/__snapshots__/Avatar.test.js.snap @@ -0,0 +1,12 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`Avatar Render rtl render component should be rendered correctly in RTL direction 1`] = ` + + + +`; diff --git a/components/avatar/__tests__/__snapshots__/demo.test.js.snap b/components/avatar/__tests__/__snapshots__/demo.test.js.snap index 3fb9ed6976..fd646bf689 100644 --- a/components/avatar/__tests__/__snapshots__/demo.test.js.snap +++ b/components/avatar/__tests__/__snapshots__/demo.test.js.snap @@ -3,7 +3,7 @@ exports[`renders ./components/avatar/demo/badge.md correctly 1`] = `
- + } /> @@ -33,3 +33,15 @@ ReactDOM.render( mountNode, ); ``` + +```css +/* tile uploaded pictures */ +.avatar-item { + margin-right: 24px; +} + +[class*='-col-rtl'] .avatar-item { + margin-right: 0; + margin-left: 24px; +} +``` diff --git a/components/back-top/__tests__/__snapshots__/index.test.js.snap b/components/back-top/__tests__/__snapshots__/index.test.js.snap new file mode 100644 index 0000000000..d61834c396 --- /dev/null +++ b/components/back-top/__tests__/__snapshots__/index.test.js.snap @@ -0,0 +1,3 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`BackTop rtl render component should be rendered correctly in RTL direction 1`] = `null`; diff --git a/components/back-top/__tests__/index.test.js b/components/back-top/__tests__/index.test.js index 6029049d06..e3dd8b7b85 100644 --- a/components/back-top/__tests__/index.test.js +++ b/components/back-top/__tests__/index.test.js @@ -2,10 +2,12 @@ import React from 'react'; import { mount } from 'enzyme'; import { sleep } from '../../../tests/utils'; import mountTest from '../../../tests/shared/mountTest'; +import rtlTest from '../../../tests/shared/rtlTest'; import BackTop from '..'; describe('BackTop', () => { mountTest(BackTop); + rtlTest(BackTop); it('should scroll to top after click it', async () => { const wrapper = mount(); diff --git a/components/back-top/index.tsx b/components/back-top/index.tsx index c1255b98f5..ec2e75f55d 100755 --- a/components/back-top/index.tsx +++ b/components/back-top/index.tsx @@ -65,10 +65,12 @@ export default class BackTop extends React.Component { }); }; - renderBackTop = ({ getPrefixCls }: ConfigConsumerProps) => { + renderBackTop = ({ getPrefixCls, direction }: ConfigConsumerProps) => { const { prefixCls: customizePrefixCls, className = '', children } = this.props; const prefixCls = getPrefixCls('back-top', customizePrefixCls); - const classString = classNames(prefixCls, className); + const classString = classNames(prefixCls, className, { + [`${prefixCls}-rtl`]: direction === 'rtl', + }); const defaultElement = (
diff --git a/components/back-top/style/index.less b/components/back-top/style/index.less index 7318a74976..f630d5f655 100644 --- a/components/back-top/style/index.less +++ b/components/back-top/style/index.less @@ -14,6 +14,11 @@ height: 40px; cursor: pointer; + &-rtl { + right: auto; + left: 100px; + } + &-content { width: 40px; height: 40px; diff --git a/components/badge/__tests__/__snapshots__/index.test.js.snap b/components/badge/__tests__/__snapshots__/index.test.js.snap index d2ca4b512e..828a0447ea 100644 --- a/components/badge/__tests__/__snapshots__/index.test.js.snap +++ b/components/badge/__tests__/__snapshots__/index.test.js.snap @@ -724,6 +724,12 @@ exports[`Badge render correct with negative number 1`] = `
`; +exports[`Badge rtl render component should be rendered correctly in RTL direction 1`] = ` + +`; + exports[`Badge should be compatible with borderColor style 1`] = ` { mountTest(Badge); + rtlTest(Badge); beforeEach(() => { jest.useFakeTimers(); diff --git a/components/badge/demo/basic.md b/components/badge/demo/basic.md index e155a142f0..225190f718 100644 --- a/components/badge/demo/basic.md +++ b/components/badge/demo/basic.md @@ -37,6 +37,10 @@ ReactDOM.render( .ant-badge:not(.ant-badge-not-a-wrapper) { margin-right: 20px; } +.ant-badge.ant-badge-rtl:not(.ant-badge-not-a-wrapper) { + margin-right: 0; + margin-left: 20px; +} .head-example { width: 42px; height: 42px; diff --git a/components/badge/demo/no-wrapper.md b/components/badge/demo/no-wrapper.md index df0821cdf9..c7b4cb3f7c 100644 --- a/components/badge/demo/no-wrapper.md +++ b/components/badge/demo/no-wrapper.md @@ -40,6 +40,10 @@ ReactDOM.render( .ant-badge-not-a-wrapper:not(.ant-badge-status) { margin-right: 8px; } +.ant-badge.ant-badge-rtl:not(.ant-badge-not-a-wrapper) { + margin-right: 0; + margin-left: 20px; +} [data-theme="dark"] .site-badge-count-4 .ant-badge-count { background-color: #141414; box-shadow: 0 0 0 1px #434343 inset; diff --git a/components/badge/demo/title.md b/components/badge/demo/title.md index fdf4c06221..5884b3f281 100644 --- a/components/badge/demo/title.md +++ b/components/badge/demo/title.md @@ -31,6 +31,12 @@ ReactDOM.render( .ant-badge:not(.ant-badge-not-a-wrapper) { margin-right: 20px; } + +.ant-badge.ant-badge-rtl:not(.ant-badge-not-a-wrapper) { + margin-right: 0; + margin-left: 20px; +} + .head-example { width: 42px; height: 42px; diff --git a/components/badge/index.tsx b/components/badge/index.tsx index 8b403ea678..70981eb620 100644 --- a/components/badge/index.tsx +++ b/components/badge/index.tsx @@ -74,11 +74,12 @@ export default class Badge extends React.Component { : style; } - getBadgeClassName(prefixCls: string) { + getBadgeClassName(prefixCls: string, direction: string = 'ltr') { const { className, children } = this.props; return classNames(className, prefixCls, { [`${prefixCls}-status`]: this.hasStatus(), [`${prefixCls}-not-a-wrapper`]: !children, + [`${prefixCls}-rtl`]: direction === 'rtl', }) as string; } @@ -156,7 +157,7 @@ export default class Badge extends React.Component { ); } - renderBadge = ({ getPrefixCls }: ConfigConsumerProps) => { + renderBadge = ({ getPrefixCls, direction }: ConfigConsumerProps) => { const { prefixCls: customizePrefixCls, scrollNumberPrefixCls: customizeScrollNumberPrefixCls, @@ -200,7 +201,7 @@ export default class Badge extends React.Component { return ( @@ -212,7 +213,7 @@ export default class Badge extends React.Component { } return ( - + {children} { mountTest(Breadcrumb); + rtlTest(Breadcrumb); const errorSpy = jest.spyOn(console, 'error').mockImplementation(() => {}); diff --git a/components/breadcrumb/__tests__/__snapshots__/Breadcrumb.test.js.snap b/components/breadcrumb/__tests__/__snapshots__/Breadcrumb.test.js.snap index c2ec43d09a..73d60d3f5b 100644 --- a/components/breadcrumb/__tests__/__snapshots__/Breadcrumb.test.js.snap +++ b/components/breadcrumb/__tests__/__snapshots__/Breadcrumb.test.js.snap @@ -32,6 +32,12 @@ exports[`Breadcrumb filter React.Fragment 1`] = `
`; +exports[`Breadcrumb rtl render component should be rendered correctly in RTL direction 1`] = ` +
+`; + exports[`Breadcrumb should allow Breadcrumb.Item is null or undefined 1`] = `
`; +exports[`Button rtl render component should be rendered correctly in RTL direction 1`] = ` +); expect(wrapper).toMatchSnapshot(); diff --git a/components/button/button-group.tsx b/components/button/button-group.tsx index e5c1a74e86..a4285a3d24 100644 --- a/components/button/button-group.tsx +++ b/components/button/button-group.tsx @@ -12,7 +12,7 @@ export interface ButtonGroupProps { const ButtonGroup: React.SFC = props => ( - {({ getPrefixCls }: ConfigConsumerProps) => { + {({ getPrefixCls, direction }: ConfigConsumerProps) => { const { prefixCls: customizePrefixCls, size, className, ...others } = props; const prefixCls = getPrefixCls('btn-group', customizePrefixCls); @@ -34,6 +34,7 @@ const ButtonGroup: React.SFC = props => ( prefixCls, { [`${prefixCls}-${sizeCls}`]: sizeCls, + [`${prefixCls}-rtl`]: direction === 'rtl', }, className, ); diff --git a/components/button/button.tsx b/components/button/button.tsx index f0760bb89e..149acf37b0 100644 --- a/components/button/button.tsx +++ b/components/button/button.tsx @@ -201,7 +201,7 @@ class Button extends React.Component { return React.Children.count(children) === 1 && !icon && type !== 'link'; } - renderButton = ({ getPrefixCls, autoInsertSpaceInButton }: ConfigConsumerProps) => { + renderButton = ({ getPrefixCls, autoInsertSpaceInButton, direction }: ConfigConsumerProps) => { const { prefixCls: customizePrefixCls, type, @@ -252,6 +252,7 @@ class Button extends React.Component { [`${prefixCls}-two-chinese-chars`]: hasTwoCNChar && autoInsertSpace, [`${prefixCls}-block`]: block, [`${prefixCls}-dangerous`]: !!danger, + [`${prefixCls}-rtl`]: direction === 'rtl', }); const iconNode = loading ? : icon || null; diff --git a/components/button/style/index.less b/components/button/style/index.less index 23cba3260d..d68f06986f 100644 --- a/components/button/style/index.less +++ b/components/button/style/index.less @@ -24,6 +24,9 @@ .btn; .btn-default; + &-rtl { + direction: rtl; + } // Make sure that the target of Button's click event always be `button` // Ref: https://github.com/ant-design/ant-design/issues/7034 > i, @@ -48,6 +51,7 @@ .@{btn-prefix-cls}-group &:first-child { &:not(:last-child) { border-right-color: @btn-group-border; + &[disabled] { border-right-color: @btn-default-border; } @@ -57,8 +61,18 @@ .@{btn-prefix-cls}-group &:last-child:not(:first-child), .@{btn-prefix-cls}-group & + & { border-left-color: @btn-group-border; + + .@{btn-prefix-cls}-group-rtl& { + border-right-color: @btn-group-border; + border-left-color: @btn-default-border; + } &[disabled] { border-left-color: @btn-default-border; + + .@{btn-prefix-cls}-group-rtl& { + border-right-color: @btn-default-border; + border-left-color: @btn-group-border; + } } } } @@ -155,15 +169,37 @@ &&-loading:not(&-circle):not(&-circle-outline):not(&-icon-only) { padding-left: 29px; + + .@{btn-prefix-cls}-rtl& { + padding-right: 29px; + padding-left: @padding-md - 1px; + } + .@{iconfont-css-prefix}:not(:last-child) { margin-left: -14px; + + .@{btn-prefix-cls}-rtl& { + margin-right: -14px; + margin-left: 0; + } } } &-sm&-loading:not(&-circle):not(&-circle-outline):not(&-icon-only) { padding-left: 24px; + + .@{btn-prefix-cls}-rtl& { + padding-right: 24px; + padding-left: @padding-xs - 1px; + } + .@{iconfont-css-prefix} { margin-left: -17px; + + .@{btn-prefix-cls}-rtl& { + margin-right: -17px; + margin-left: 0; + } } } @@ -181,6 +217,11 @@ > .@{iconfont-css-prefix} + span, > span + .@{iconfont-css-prefix} { margin-left: 8px; + + .@{btn-prefix-cls}-rtl& { + margin-right: 8px; + margin-left: 0; + } } &-background-ghost { diff --git a/components/button/style/mixin.less b/components/button/style/mixin.less index cd38bd290e..b316f0f79a 100644 --- a/components/button/style/mixin.less +++ b/components/button/style/mixin.less @@ -400,6 +400,10 @@ & + .@{btnClassName}, & + & { margin-left: -1px; + .@{btnClassName}-rtl& { + margin-right: -1px; + margin-left: auto; + } } .@{btnClassName}-primary + .@{btnClassName}:not(.@{btnClassName}-primary):not([disabled]) { border-left-color: transparent; @@ -407,6 +411,9 @@ .@{btnClassName} { border-radius: 0; } + &.@{btnClassName}-group-rtl { + direction: rtl; + } > .@{btnClassName}:first-child, > span:first-child > .@{btnClassName} { margin-left: 0; @@ -421,11 +428,23 @@ > span:first-child:not(:last-child) > .@{btnClassName} { border-top-left-radius: @btn-border-radius-base; border-bottom-left-radius: @btn-border-radius-base; + .@{btnClassName}-group-rtl& { + border-top-left-radius: 0; + border-top-right-radius: @btn-border-radius-base; + border-bottom-right-radius: @btn-border-radius-base; + border-bottom-left-radius: 0; + } } > .@{btnClassName}:last-child:not(:first-child), > span:last-child:not(:first-child) > .@{btnClassName} { border-top-right-radius: @btn-border-radius-base; border-bottom-right-radius: @btn-border-radius-base; + .@{btnClassName}-group-rtl& { + border-top-left-radius: @btn-border-radius-base; + border-top-right-radius: 0; + border-bottom-right-radius: 0; + border-bottom-left-radius: @btn-border-radius-base; + } } &-sm { > .@{btnClassName}:only-child { @@ -438,11 +457,23 @@ > span:first-child:not(:last-child) > .@{btnClassName} { border-top-left-radius: @btn-border-radius-sm; border-bottom-left-radius: @btn-border-radius-sm; + .@{btnClassName}-group-rtl& { + border-top-left-radius: 0; + border-top-right-radius: @btn-border-radius-sm; + border-bottom-right-radius: @btn-border-radius-sm; + border-bottom-left-radius: 0; + } } > .@{btnClassName}:last-child:not(:first-child), > span:last-child:not(:first-child) > .@{btnClassName} { border-top-right-radius: @btn-border-radius-sm; border-bottom-right-radius: @btn-border-radius-sm; + .@{btnClassName}-group-rtl& { + border-top-left-radius: @btn-border-radius-sm; + border-top-right-radius: 0; + border-bottom-right-radius: 0; + border-bottom-left-radius: @btn-border-radius-sm; + } } } & > & { diff --git a/components/calendar/__tests__/__snapshots__/index.test.js.snap b/components/calendar/__tests__/__snapshots__/index.test.js.snap index 74dd50d29a..726a4f9cdb 100644 --- a/components/calendar/__tests__/__snapshots__/index.test.js.snap +++ b/components/calendar/__tests__/__snapshots__/index.test.js.snap @@ -951,3 +951,953 @@ exports[`Calendar Calendar should support locale 1`] = `
`; + +exports[`Calendar rtl render component should be rendered correctly in RTL direction 1`] = ` +
+
+
+
+ + + + + 2000 + +
+ +
+
+
+ + + + + Sep + +
+ +
+
+ + +
+
+
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ Su + + Mo + + Tu + + We + + Th + + Fr + + Sa +
+
+
+ 27 +
+
+
+
+
+
+ 28 +
+
+
+
+
+
+ 29 +
+
+
+
+
+
+ 30 +
+
+
+
+
+
+ 31 +
+
+
+
+
+
+ 01 +
+
+
+
+
+
+ 02 +
+
+
+
+
+
+ 03 +
+
+
+
+
+
+ 04 +
+
+
+
+
+
+ 05 +
+
+
+
+
+
+ 06 +
+
+
+
+
+
+ 07 +
+
+
+
+
+
+ 08 +
+
+
+
+
+
+ 09 +
+
+
+
+
+
+ 10 +
+
+
+
+
+
+ 11 +
+
+
+
+
+
+ 12 +
+
+
+
+
+
+ 13 +
+
+
+
+
+
+ 14 +
+
+
+
+
+
+ 15 +
+
+
+
+
+
+ 16 +
+
+
+
+
+
+ 17 +
+
+
+
+
+
+ 18 +
+
+
+
+
+
+ 19 +
+
+
+
+
+
+ 20 +
+
+
+
+
+
+ 21 +
+
+
+
+
+
+ 22 +
+
+
+
+
+
+ 23 +
+
+
+
+
+
+ 24 +
+
+
+
+
+
+ 25 +
+
+
+
+
+
+ 26 +
+
+
+
+
+
+ 27 +
+
+
+
+
+
+ 28 +
+
+
+
+
+
+ 29 +
+
+
+
+
+
+ 30 +
+
+
+
+
+
+ 01 +
+
+
+
+
+
+ 02 +
+
+
+
+
+
+ 03 +
+
+
+
+
+
+ 04 +
+
+
+
+
+
+ 05 +
+
+
+
+
+
+ 06 +
+
+
+
+
+
+ 07 +
+
+
+
+
+
+
+
+`; diff --git a/components/calendar/__tests__/index.test.js b/components/calendar/__tests__/index.test.js index d7be188f06..b7a80a3243 100644 --- a/components/calendar/__tests__/index.test.js +++ b/components/calendar/__tests__/index.test.js @@ -9,9 +9,11 @@ import Select from '../../select'; import Group from '../../radio/group'; import Button from '../../radio/radioButton'; import mountTest from '../../../tests/shared/mountTest'; +import rtlTest from '../../../tests/shared/rtlTest'; describe('Calendar', () => { mountTest(Calendar); + rtlTest(Calendar, true); function openSelect(wrapper, className) { wrapper diff --git a/components/card/__tests__/__snapshots__/index.test.js.snap b/components/card/__tests__/__snapshots__/index.test.js.snap index 18216decda..3fc36d6673 100644 --- a/components/card/__tests__/__snapshots__/index.test.js.snap +++ b/components/card/__tests__/__snapshots__/index.test.js.snap @@ -1,5 +1,15 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP +exports[`Card rtl render component should be rendered correctly in RTL direction 1`] = ` +
+
+
+`; + exports[`Card should still have padding when card which set padding to 0 is loading 1`] = `
{ mountTest(Card); + rtlTest(Card); beforeAll(() => { jest.useFakeTimers(); diff --git a/components/card/index.tsx b/components/card/index.tsx index 29dc63648e..adbccbf610 100644 --- a/components/card/index.tsx +++ b/components/card/index.tsx @@ -76,7 +76,7 @@ export default class Card extends React.Component { return containGrid; } - renderCard = ({ getPrefixCls }: ConfigConsumerProps) => { + renderCard = ({ getPrefixCls, direction }: ConfigConsumerProps) => { const { prefixCls: customizePrefixCls, className, @@ -108,6 +108,7 @@ export default class Card extends React.Component { [`${prefixCls}-contain-tabs`]: tabList && tabList.length, [`${prefixCls}-${size}`]: size !== 'default', [`${prefixCls}-type-${type}`]: !!type, + [`${prefixCls}-rtl`]: direction === 'rtl', }); const loadingBlockStyle = diff --git a/components/card/style/index.less b/components/card/style/index.less index 7e9c3cdc16..a29238250b 100644 --- a/components/card/style/index.less +++ b/components/card/style/index.less @@ -17,6 +17,10 @@ border-radius: @card-radius; transition: all 0.3s; + &-rtl { + direction: rtl; + } + &-hoverable { cursor: pointer; &:hover { @@ -76,6 +80,11 @@ color: @text-color; font-weight: normal; font-size: @font-size-base; + + .@{card-prefix-cls}-rtl & { + margin-right: auto; + margin-left: 0; + } } &-body { @@ -98,6 +107,11 @@ 1px 1px 0 0 @border-color-split, 1px 0 0 0 @border-color-split inset, 0 1px 0 0 @border-color-split inset; transition: all 0.3s; + + .@{card-prefix-cls}-rtl & { + float: right; + } + &-hoverable { &:hover { position: relative; @@ -142,6 +156,10 @@ color: @text-color-secondary; text-align: center; + .@{card-prefix-cls}-rtl & { + float: right; + } + > span { position: relative; display: block; @@ -205,6 +223,12 @@ &-avatar { float: left; padding-right: 16px; + + .@{card-prefix-cls}-rtl & { + float: right; + padding-right: 0; + padding-left: 16px; + } } &-detail { diff --git a/components/carousel/__tests__/__snapshots__/index.test.js.snap b/components/carousel/__tests__/__snapshots__/index.test.js.snap index 84ebf14cc8..50e2519af5 100644 --- a/components/carousel/__tests__/__snapshots__/index.test.js.snap +++ b/components/carousel/__tests__/__snapshots__/index.test.js.snap @@ -1,5 +1,24 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP +exports[`Carousel rtl render component should be rendered correctly in RTL direction 1`] = ` +