From b1467d6ec8c29f13ae894918ace83222b13d7783 Mon Sep 17 00:00:00 2001
From: EmilyyyLiu <100924403+EmilyyyLiu@users.noreply.github.com>
Date: Tue, 3 Jun 2025 14:09:56 +0800
Subject: [PATCH] feat(Divider): unify orientation attribute usage (#53645)
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
* feat[Divider]: Unified use of orientation attribute
* feat: Restore the size type missed in the merge
* feat: Delete unnecessary demo adjustments
* docs: change text
* feat: deprecated warning
* Update components/divider/index.zh-CN.md
Signed-off-by: thinkasany <480968828@qq.com>
* Update components/divider/index.en-US.md
Signed-off-by: thinkasany <480968828@qq.com>
* feat: use useOrientation and change test,doc
* feat: change demos orientation attribut
* docs: change token and demo (orientationMargin->titlePlacementMargin)
* feat: change demos titlePlacement="left/right" -> "start/end"
* docs: titlePlacement align
* feat: Resolve merge conflicts
* fix: lint error
* fix: demo lint error
* feat: use mergedStyles.content
* test: update snapshot
* rerun ci
* test: update snapshot
* fix: delete titlePlacementMargin and udpate snapshots
* feat: change demos orientationMargin-> styles.content.margin
* Update components/divider/demo/vertical.md
Co-authored-by: thinkasany <480968828@qq.com>
Signed-off-by: EmilyyyLiu <100924403+EmilyyyLiu@users.noreply.github.com>
* feat: Call warning using list
* docs: `vertical` to make the divider vertical.
* docs: Modify punctuation usage
* docs: Add deprecated description
* docs: Clarify the possible values for titlePlacement in the example
* feat: replase { margin: '0' } ->{ margin: 0 }
---------
Signed-off-by: thinkasany <480968828@qq.com>
Signed-off-by: EmilyyyLiu <100924403+EmilyyyLiu@users.noreply.github.com>
Co-authored-by: 刘欢
diff --git a/components/config-provider/demo/locale.tsx b/components/config-provider/demo/locale.tsx
index 12ebd6af5b..cc26da59ae 100644
--- a/components/config-provider/demo/locale.tsx
+++ b/components/config-provider/demo/locale.tsx
@@ -188,7 +188,7 @@ const Page: React.FC = () => {
/>
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed nonne merninisti licere mihi ista probare, quae sunt a te dicta? Refert tamen, quo modo.
-Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed nonne merninisti licere mihi ista probare, quae sunt a te dicta? Refert tamen, quo modo.
-Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed nonne merninisti licere mihi ista probare, quae sunt a te dicta? Refert tamen, quo modo.
-Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed nonne merninisti licere mihi ista probare, quae sunt a te dicta? Refert tamen, quo modo.
-
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed nonne merninisti licere mihi ista
diff --git a/components/divider/demo/customize-style.tsx b/components/divider/demo/customize-style.tsx
index 29621bb498..f2b7d492d0 100644
--- a/components/divider/demo/customize-style.tsx
+++ b/components/divider/demo/customize-style.tsx
@@ -8,11 +8,11 @@ const App: React.FC = () => (
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed nonne merninisti licere mihi ista probare, quae sunt a te dicta? Refert tamen, quo modo.
-
diff --git a/components/divider/demo/vertical.md b/components/divider/demo/vertical.md
index dfe2c4cc27..2b2e3d3286 100644
--- a/components/divider/demo/vertical.md
+++ b/components/divider/demo/vertical.md
@@ -1,7 +1,7 @@
## zh-CN
-使用 `type="vertical"` 设置为行内的垂直分割线。
+使用 `orientation="vertical"` 或者 `vertical` 设置为行内的垂直分割线。
## en-US
-Use `type="vertical"` to make the divider vertical.
+Use `orientation="vertical"` or `vertical` to make the divider vertical.
diff --git a/components/divider/demo/vertical.tsx b/components/divider/demo/vertical.tsx
index b919fd2f81..bf5fd9469c 100644
--- a/components/divider/demo/vertical.tsx
+++ b/components/divider/demo/vertical.tsx
@@ -4,9 +4,9 @@ import { Divider } from 'antd';
const App: React.FC = () => (
<>
Text
-
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed nonne merninisti licere mihi ista probare, quae sunt a te dicta? Refert tamen, quo modo.
-Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed nonne merninisti licere mihi ista probare, quae sunt a te dicta? Refert tamen, quo modo.
-Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed nonne merninisti licere mihi ista probare, quae sunt a te dicta? Refert tamen, quo modo.
-
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed nonne merninisti licere mihi ista
diff --git a/components/divider/index.en-US.md b/components/divider/index.en-US.md
index e3fa2fce94..857e937629 100644
--- a/components/divider/index.en-US.md
+++ b/components/divider/index.en-US.md
@@ -37,13 +37,15 @@ Common props ref:[Common props](/docs/react/common-props)
| children | The wrapped title | ReactNode | - | |
| className | The className of container | string | - | |
| dashed | Whether line is dashed | boolean | false | |
-| variant | Whether line is dashed, dotted or solid | `dashed` \| `dotted` \| `solid` | solid | 5.20.0 |
-| orientation | The position of title inside divider | `start` \| `end` \| `center` | `center` | `start` `end`: 5.24.0 |
-| orientationMargin | The margin-left/right between the title and its closest border, while the `orientation` should not be `center`, If a numeric value of type `string` is provided without a unit, it is assumed to be in pixels (px) by default. | string \| number | - | |
+| orientation | Whether line is horizontal or vertical | `horizontal` \| `vertical` | `horizontal` | - |
+| ~~orientationMargin~~ | The margin-left/right between the title and its closest border, while the `titlePlacement` should not be `center`, If a numeric value of type `string` is provided without a unit, it is assumed to be in pixels (px) by default. | string \| number | - | |
| plain | Divider text show as plain style | boolean | true | 4.2.0 |
| style | The style object of container | CSSProperties | - | |
| size | The size of divider. Only valid for horizontal layout | `small` \| `middle` \| `large` | - | 5.25.0 |
-| type | The direction type of divider | `horizontal` \| `vertical` | `horizontal` | |
+| titlePlacement | The position of title inside divider | `start` \| `end` \| `center` | `center` | - |
+| ~~type~~ | The direction type of divider | `horizontal` \| `vertical` | `horizontal` | - |
+| variant | Whether line is dashed, dotted or solid | `dashed` \| `dotted` \| `solid` | solid | 5.20.0 |
+| vertical | Orientation, Simultaneously configure with `orientation` and prioritize `orientation` | boolean | false | - |
## Semantic DOM
diff --git a/components/divider/index.tsx b/components/divider/index.tsx
index 66c12a29a4..dee06ebf68 100644
--- a/components/divider/index.tsx
+++ b/components/divider/index.tsx
@@ -2,6 +2,8 @@ import * as React from 'react';
import cls from 'classnames';
import useMergeSemantic from '../_util/hooks/useMergeSemantic';
+import useOrientation from '../_util/hooks/useOrientation';
+import type { Orientation } from '../_util/hooks/useOrientation';
import { devUseWarning } from '../_util/warning';
import { useComponentConfig } from '../config-provider/context';
import useSize from '../config-provider/hooks/useSize';
@@ -10,18 +12,21 @@ import useStyle from './style';
type SemanticName = 'root' | 'rail' | 'content';
+export type TitlePlacement =
+ | 'left'
+ | 'right'
+ | 'center'
+ | 'start' // 👈 5.24.0+
+ | 'end'; // 👈 5.24.0+
+const titlePlacementList = ['left', 'right', 'center', 'start', 'end'];
export interface DividerProps {
prefixCls?: string;
- type?: 'horizontal' | 'vertical';
- /**
- * @default center
- */
- orientation?:
- | 'left'
- | 'right'
- | 'center'
- | 'start' // 👈 5.24.0+
- | 'end'; // 👈 5.24.0+
+ /** @deprecated please use `orientation`*/
+ type?: Orientation;
+ orientation?: Orientation;
+ vertical?: boolean;
+ titlePlacement?: TitlePlacement;
+ /** @deprecated please use `styles.content.margin` */
orientationMargin?: string | number;
className?: string;
rootClassName?: string;
@@ -40,7 +45,6 @@ export interface DividerProps {
}
const sizeClassNameMap: RecordHeader
Header