feat: App support direction with CP (#50246)

* feat: App support direction with CP

* feat: App support direction with CP
This commit is contained in:
lijianan 2024-08-05 18:16:09 +08:00 committed by GitHub
parent 6cb0040590
commit 54ff15c50b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 10 additions and 3 deletions

View File

@ -2,7 +2,7 @@
exports[`App rtl render component should be rendered correctly in RTL direction 1`] = `
<div
class="ant-app"
class="ant-app ant-app-rtl"
/>
`;

View File

@ -35,10 +35,13 @@ const App: React.FC<AppProps> & { useApp: () => useAppProps } = (props) => {
style,
component = 'div',
} = props;
const { getPrefixCls } = useContext<ConfigConsumerProps>(ConfigContext);
const { direction, getPrefixCls } = useContext<ConfigConsumerProps>(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<AppConfig>(AppConfigContext);
@ -74,6 +77,7 @@ const App: React.FC<AppProps> & { useApp: () => useAppProps } = (props) => {
// ============================ Render ============================
const Component = component === false ? React.Fragment : component;
const rootProps: AppProps = {
className: customClassName,
style,

View File

@ -15,6 +15,9 @@ const genBaseStyle: GenerateStyle<AppToken> = (token) => {
fontSize,
lineHeight,
fontFamily,
[`&${componentCls}-rtl`]: {
direction: 'rtl',
},
},
};
};