diff --git a/components/calendar/__tests__/__snapshots__/index.test.js.snap b/components/calendar/__tests__/__snapshots__/index.test.js.snap index 2f1bbdf3ae..98a0e1071d 100644 --- a/components/calendar/__tests__/__snapshots__/index.test.js.snap +++ b/components/calendar/__tests__/__snapshots__/index.test.js.snap @@ -942,7 +942,7 @@ exports[`Calendar Calendar should support locale 1`] = ` exports[`Calendar rtl render component should be rendered correctly in RTL direction 1`] = `
(generateConfig: GenerateConfig) { onPanelChange, onSelect, } = props; - const { getPrefixCls } = React.useContext(ConfigContext); + const { getPrefixCls, direction } = React.useContext(ConfigContext); const prefixCls = getPrefixCls('picker', customizePrefixCls); const calendarPrefixCls = `${prefixCls}-calendar`; const today = generateConfig.getNow(); @@ -239,6 +239,7 @@ function generateCalendar(generateConfig: GenerateConfig) { className={classNames(calendarPrefixCls, className, { [`${calendarPrefixCls}-full`]: fullscreen, [`${calendarPrefixCls}-mini`]: !fullscreen, + [`${calendarPrefixCls}-rtl`]: direction === 'rtl', })} style={style} > diff --git a/components/calendar/style/index.less b/components/calendar/style/index.less index 2c3bbd3983..4828a5b7ff 100644 --- a/components/calendar/style/index.less +++ b/components/calendar/style/index.less @@ -14,7 +14,6 @@ justify-content: flex-end; padding: @padding-sm 0; - .@{calendar-prefix-cls}-year-select { min-width: 80px; } @@ -190,3 +189,4 @@ } } +@import './rtl'; diff --git a/components/calendar/style/rtl.less b/components/calendar/style/rtl.less new file mode 100644 index 0000000000..3296f75126 --- /dev/null +++ b/components/calendar/style/rtl.less @@ -0,0 +1,44 @@ +@import '../../style/themes/index'; +@import '../../style/mixins/index'; + +@calendar-prefix-cls: ~'@{ant-prefix}-picker-calendar'; +@calendar-picker-prefix-cls: ~'@{ant-prefix}-picker'; + +.@{calendar-prefix-cls} { + &-rtl { + direction: rtl; + } + + &-header { + .@{calendar-prefix-cls}-month-select { + .@{calendar-prefix-cls}-rtl & { + margin-right: @padding-xs; + margin-left: 0; + } + } + + .@{calendar-prefix-cls}-mode-switch { + .@{calendar-prefix-cls}-rtl & { + margin-right: @padding-xs; + margin-left: 0; + } + } + } + + // ========================== Full ========================== + &-full { + .@{calendar-picker-prefix-cls}-panel { + .@{calendar-prefix-cls}-rtl& { + text-align: left; + } + + .@{calendar-picker-prefix-cls}-body { + th { + .@{calendar-prefix-cls}-rtl& { + padding: 0 0 5px 12px; + } + } + } + } + } +}