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

feat: added rtl direction to all of ant-design components #19380

Merged
merged 260 commits into from
Jan 2, 2020

Conversation

saeedrahimi
Copy link
Contributor

@saeedrahimi saeedrahimi commented Oct 23, 2019

🤔 This is a ...

  • New feature
  • Bug fix
  • Site / document update
  • Component style update
  • TypeScript definition update
  • Refactoring
  • Code style optimization
  • Test Case
  • Branch merge
  • Other (about what?)

🔗 Related issue link

close #4051

Previous pull request was on feature branch: #18006

💡 Background and solution

As requirement of this issue components of ant-design doesn't support right to left direction, and those components are not useful in some languages like Persian(Farsi) or Arabic.

Solution:
I started to develop Rtl style on ant-design and as @zombieJ mentioned in issue i used ConfigProvider to set direction of component.

direction property added to ConfigProvider.

<ConfigProvider direction="rtl">
      <Cascader  options={options} placeholder="select an item"/>
</ConfigProvider>

in style files added prefixed rtl styles to change direction of displayed items

  .@{inputClass}-suffix {
    right: @input-padding-horizontal-base + 1px;

    .@{inputClass}-rtl & {
      right: auto;
      left: @input-padding-horizontal-base + 1px;
    }
  }

so when RTL'ed components wrapped by ConfigProvider with direction='rtl' property, all child components (also grid-system) will shown in right-to-left direction.
ant-rtl

RTL Progress

  • Button
  • Icon
  • Typography
  • Grid
  • Layout
  • Affix
  • Breadcrumb
  • Dropdown
  • Menu
  • Pagination
  • PageHeader
  • Steps
  • AutoComplete
  • CheckBox
  • Cascader
  • DatePicker
  • Form
  • InputNumber
  • Input
  • Mention
  • Rate
  • Radio
  • Switch
  • Slider
  • Select
  • TreeSelect
  • Transfer
  • TimePicker
  • Upload
  • Avatar
  • Badge
  • Comment
  • Collapse
  • Carousel
  • Cad
  • Calendar
  • Description List
  • Empty
  • List
  • Popover
  • Statistic
  • Tree
  • Tooltip
  • Timeline
  • Tag
  • Tabs (Done)
  • Table
  • Alert
  • Drawer
  • Modal
  • Message
  • Notification
  • Progress
  • Popconfirm
  • Result
  • Spin
  • Skeleton
  • Anchor (No need to RTL)
  • BackTop
  • ConfigProvider
  • Divider (No need to RTL)
  • Front page

📝 Changelog

Language Changelog
🇺🇸 English
🇨🇳 Chinese

☑️ Self Check before Merge

  • Doc is updated/provided or not needed
  • Demo is updated/provided or not needed
  • TypeScript definition is updated/provided or not needed
  • Changelog is provided or not needed

View rendered components/config-provider/demo/direction.md
View rendered components/config-provider/index.en-US.md
View rendered components/config-provider/index.zh-CN.md

Copy link

@tests-checker tests-checker bot left a comment

Choose a reason for hiding this comment

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

Could you please add tests to make sure this change works as expected?

@buildsize
Copy link

buildsize bot commented Oct 23, 2019

File name Previous Size New Size Change
package-lock.json 981.54 KB 977.33 KB -4.22 KB (0%)

@afc163 afc163 added the 4.x In Ant Design 4.0 label Oct 23, 2019
@netlify
Copy link

netlify bot commented Oct 23, 2019

Deploy preview for ant-design ready!

Built with commit 9c56ca7

https://deploy-preview-19380--ant-design.netlify.com

@codecov
Copy link

codecov bot commented Oct 23, 2019

Codecov Report

Merging #19380 into 4.0-prepare will increase coverage by 0.04%.
The diff coverage is 100%.

Impacted file tree graph

@@               Coverage Diff               @@
##           4.0-prepare   #19380      +/-   ##
===============================================
+ Coverage        97.49%   97.54%   +0.04%     
===============================================
  Files              294      294              
  Lines             6716     6771      +55     
  Branches          1847     1862      +15     
===============================================
+ Hits              6548     6605      +57     
+ Misses             168      166       -2
Impacted Files Coverage Δ
components/config-provider/index.tsx 91.66% <ø> (ø) ⬆️
components/tree-select/index.tsx 97.43% <ø> (ø) ⬆️
components/config-provider/context.tsx 100% <ø> (ø) ⬆️
components/menu/MenuContext.tsx 100% <ø> (ø) ⬆️
components/pagination/Pagination.tsx 100% <100%> (ø) ⬆️
components/radio/radio.tsx 100% <100%> (ø) ⬆️
components/badge/index.tsx 100% <100%> (ø) ⬆️
components/table/Table.tsx 96.55% <100%> (+0.02%) ⬆️
components/menu/MenuItem.tsx 94.73% <100%> (+0.29%) ⬆️
components/descriptions/index.tsx 98.92% <100%> (ø) ⬆️
... and 51 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update f88f383...9c56ca7. Read the comment docs.

@saeedrahimi
Copy link
Contributor Author

saeedrahimi commented Oct 23, 2019

I have no idea why lint fails, there is no error on my environment.
Windows 10 v17134.1069
@zombieJ

@zombieJ
Copy link
Member

zombieJ commented Oct 24, 2019

@typescript-eslint/parser failed with markdown at 2.5.0. It's OK if not other lint failed without markdown file:

ref typescript-eslint/typescript-eslint#1123

@mahdi13
Copy link

mahdi13 commented Oct 29, 2019

@saeedrahimi I check this page every day! Kindly ask you to finish it.

@zombieJ
Copy link
Member

zombieJ commented Oct 30, 2019

@saeedrahimi,
4.0-prepare synced with master. Some conflict need rebase 4.0-prepare. Thanks.

@saeedrahimi
Copy link
Contributor Author

saeedrahimi commented Oct 31, 2019

@afc163 , @zombieJ
Hi there,
ant-design-rtl-button

I thought that config-provider demo page is not suitable to demonstrate all rtl components and their functionality in rtl direction.
so i added a button to header that changes direction of the whole demo and updated some styles of site/theme to support rtl properly.
I just wanted to know your idea about these changes. is it ok to continue with this?
I wanna do my best.
Thanks.

@yoyo837
Copy link
Contributor

yoyo837 commented Nov 1, 2019

Great works, I hope that the owner can pay enough attention to this and like your contribution.

@zombieJ
Copy link
Member

zombieJ commented Nov 4, 2019

@afc163 , @zombieJ
Hi there,
ant-design-rtl-button

I thought that config-provider demo page is not suitable to demonstrate all rtl components and their functionality in rtl direction.
so i added a button to header that changes direction of the whole demo and updated some styles of site/theme to support rtl properly.
I just wanted to know your idea about these changes. is it ok to continue with this?
I wanna do my best.
Thanks.

Cool. I'm OK with this if all the components support RTL.

@saeedrahimi saeedrahimi changed the title feat: added rtl direction to ConfigProvider and some components [WIP] feat: added rtl direction to ConfigProvider and some components Nov 5, 2019
@saeedrahimi saeedrahimi changed the base branch from 4.0-prepare to feature November 11, 2019 20:11
@saeedrahimi saeedrahimi changed the base branch from feature to 4.0-prepare November 11, 2019 20:12
@yoyo837 yoyo837 mentioned this pull request Nov 12, 2019
14 tasks
@yoyo837
Copy link
Contributor

yoyo837 commented Nov 12, 2019

Note that some components have been refactored to a new major version in 4.0-prepare branch. And there are other components that are also planned to be refactored.

@saeedrahimi
Copy link
Contributor Author

Note that some components have been refactored to a new major version in 4.0-prepare branch. And there are other components that are also planned to be refactored.

thanks for note, i will double check them to ensure components working correctly.

@saeedrahimi
Copy link
Contributor Author

Hi,
There is an issue in the menu component style. the border of the menu must be at the left side.
please check this one
menu

border is in the left side in ltr direction. so it should be in right side in rtl direction.
border should not be outside of sidebar

@saeedrahimi
Copy link
Contributor Author

Thank you @zombieJ for fixing my mistakes 👍

@zombieJ zombieJ merged commit 676de29 into ant-design:4.0-prepare Jan 2, 2020
@pr-triage pr-triage bot added the PR: merged label Jan 2, 2020
@yoyo837
Copy link
Contributor

yoyo837 commented Jan 2, 2020

Amazing works!

@vahidalvandi
Copy link

vahidalvandi commented Jan 2, 2020

thank you how i can use this in nuxt and vue?

@afc163
Copy link
Member

afc163 commented Jan 3, 2020

image

Is this header misordered?

@afc163 afc163 mentioned this pull request Jan 3, 2020
14 tasks
@saeedrahimi
Copy link
Contributor Author

image

Is this header misordered?

I think @zombieJ fixed it in this commit cause i see header in correct order in next.ant.design

@afc163
Copy link
Member

afc163 commented Jan 3, 2020

Could you help to fix it to correct order?

@saeedrahimi
Copy link
Contributor Author

Could you help to fix it to correct order?

Is there any misordered item? 🤔
antd-header

ZombieJ fixed that.

@zombieJ
Copy link
Member

zombieJ commented Jan 3, 2020

That's fine. I've resolved.

@PejmanNik
Copy link

Amazing work @vahidalvandi
I just find a bug, the ant-col-rtl broken all :not([class^='ant-col-']):not([class*=' ant-col-']) selectors

@yoyo837
Copy link
Contributor

yoyo837 commented Jan 29, 2020

@PejmanNik Feel free to open a new issue about that.

@adirrapidapi
Copy link

how to make Sider in right side (rtl)?

@xrkffgg
Copy link
Member

xrkffgg commented Apr 30, 2020

how to make Sider in right side (rtl)?

@adirrapidapi
You can use https://ant.design/components/config-provider-cn/#components-config-provider-demo-direction to set rtl, so the base Slider can be in right side.
or https://ant.design/components/slider-cn/#components-slider-demo-reverse in ltr

@adirrapidapi
Copy link

@xrkffgg I added with configProvider the rtl direction but the sider it's still in left side, as you can see in this example https://stackblitz.com/edit/react-ouxpra-trwwbf?embed=1&file=index.js

@adirrapidapi
Copy link

@xrkffgg any solution?

@xrkffgg
Copy link
Member

xrkffgg commented May 7, 2020

@xrkffgg any solution?

sorry, I just saw. I'll fix it.

@xrkffgg xrkffgg mentioned this pull request May 7, 2020
14 tasks
@mehdiraized
Copy link

@saeedrahimi i have issue on nextjs

Warning: Prop `className` did not match. Server: "ant-badge ant-badge-rtl" Client: "ant-badge"

@xrkffgg
Copy link
Member

xrkffgg commented Jul 18, 2020

@mehdiraized Please create new issue https://github.com/ant-design/ant-design/issues/new/choose

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
4.x In Ant Design 4.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.