Skip to content

Commit

Permalink
🌐 style: improve direction UX (lobehub#1169)
Browse files Browse the repository at this point in the history
  • Loading branch information
Wxh16144 committed Feb 6, 2024
1 parent b14d6af commit e3929dc
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/layout/GlobalLayout/Locale.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { ConfigProvider } from 'antd';
import { PropsWithChildren, memo, useEffect, useState } from 'react';
import { isRtlLang } from 'rtl-detect';
import useSWR from 'swr';

import { createI18nNext } from '@/locales/create';
Expand Down Expand Up @@ -67,7 +68,14 @@ const Locale = memo<LocaleLayoutProps>(({ children, defaultLang }) => {
};
}, [i18n]);

return <ConfigProvider locale={locale}>{children}</ConfigProvider>;
// detect document direction
const documentDir = isRtlLang(lang!) ? 'rtl' : 'ltr';

return (
<ConfigProvider direction={documentDir} locale={locale}>
{children}
</ConfigProvider>
);
});

export default Locale;

0 comments on commit e3929dc

Please sign in to comment.