From 54ff15c50bb7273ecfd1427cfa50ddda5380550e Mon Sep 17 00:00:00 2001 From: lijianan <574980606@qq.com> Date: Mon, 5 Aug 2024 18:16:09 +0800 Subject: [PATCH] feat: App support direction with CP (#50246) * feat: App support direction with CP * feat: App support direction with CP --- .../app/__tests__/__snapshots__/index.test.tsx.snap | 2 +- components/app/index.tsx | 8 ++++++-- components/app/style/index.ts | 3 +++ 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/components/app/__tests__/__snapshots__/index.test.tsx.snap b/components/app/__tests__/__snapshots__/index.test.tsx.snap index 9d7d65275a..88a0ee254a 100644 --- a/components/app/__tests__/__snapshots__/index.test.tsx.snap +++ b/components/app/__tests__/__snapshots__/index.test.tsx.snap @@ -2,7 +2,7 @@ exports[`App rtl render component should be rendered correctly in RTL direction 1`] = `
`; diff --git a/components/app/index.tsx b/components/app/index.tsx index b84ba221ee..4c74eec667 100644 --- a/components/app/index.tsx +++ b/components/app/index.tsx @@ -35,10 +35,13 @@ const App: React.FC & { useApp: () => useAppProps } = (props) => { style, component = 'div', } = props; - const { getPrefixCls } = useContext(ConfigContext); + const { direction, getPrefixCls } = useContext(ConfigContext); const prefixCls = getPrefixCls('app', customizePrefixCls); const [wrapCSSVar, hashId, cssVarCls] = useStyle(prefixCls); - const customClassName = classNames(hashId, prefixCls, className, rootClassName, cssVarCls); + + const customClassName = classNames(hashId, prefixCls, className, rootClassName, cssVarCls, { + [`${prefixCls}-rtl`]: direction === 'rtl', + }); const appConfig = useContext(AppConfigContext); @@ -74,6 +77,7 @@ const App: React.FC & { useApp: () => useAppProps } = (props) => { // ============================ Render ============================ const Component = component === false ? React.Fragment : component; + const rootProps: AppProps = { className: customClassName, style, diff --git a/components/app/style/index.ts b/components/app/style/index.ts index a2580d54df..bcb2bdc910 100644 --- a/components/app/style/index.ts +++ b/components/app/style/index.ts @@ -15,6 +15,9 @@ const genBaseStyle: GenerateStyle = (token) => { fontSize, lineHeight, fontFamily, + [`&${componentCls}-rtl`]: { + direction: 'rtl', + }, }, }; };