test/apps/admin/src/app.tsx

61 lines
1.9 KiB
TypeScript
Raw Normal View History

2024-05-07 16:24:43 +00:00
import { StyleProvider } from '@ant-design/cssinjs';
2024-05-10 21:52:36 +00:00
import { ConfigProvider, theme, App as AntdApp } from 'antd';
2024-05-07 16:24:43 +00:00
// import 'dayjs/locale/zh-cn';
2024-05-13 01:35:26 +00:00
import { FC, useMemo } from 'react';
2024-05-07 16:24:43 +00:00
import $styles from './app.module.css';
2024-05-13 01:35:26 +00:00
import { localeData } from './components/demo/constants';
import ContextDemo, { Locale } from './components/demo/context';
import CustomDemo from './components/demo/custom';
import { useLocale, useTheme } from './components/demo/hooks';
import ReducerDemo, { Theme } from './components/demo/reducer';
2024-05-09 22:29:02 +00:00
2024-05-13 01:35:26 +00:00
const Wrapper: FC = () => {
const locale = useLocale();
const antdLocaleData = useMemo(() => {
if (!Object.keys(localeData).find((v) => v === locale.name)) {
return localeData[0];
}
return localeData[locale.name];
}, [locale.name]);
const themeState = useTheme();
const algorithm = useMemo(() => {
const result = [themeState.compact ? theme.compactAlgorithm : theme.defaultAlgorithm];
if (themeState.mode === 'dark') result.push(theme.darkAlgorithm);
return result;
}, [themeState]);
2024-05-07 16:24:43 +00:00
return (
<ConfigProvider
2024-05-13 01:35:26 +00:00
locale={antdLocaleData}
2024-05-07 16:24:43 +00:00
theme={{
2024-05-13 01:35:26 +00:00
algorithm,
2024-05-10 21:52:36 +00:00
token: {},
2024-05-07 16:24:43 +00:00
}}
>
<StyleProvider hashPriority="high">
<AntdApp>
<div className={$styles.app}>
2024-05-13 01:35:26 +00:00
{/* <StateDemo />
2024-05-10 21:52:36 +00:00
<EffectDemo />
<RefDemo />
2024-05-11 22:07:54 +00:00
<MemoDemo />
2024-05-13 01:35:26 +00:00
<CallbackDemo /> */}
<ContextDemo />
<ReducerDemo />
<CustomDemo />
2024-05-07 16:24:43 +00:00
</div>
</AntdApp>
</StyleProvider>
</ConfigProvider>
);
};
2024-05-13 01:35:26 +00:00
const App: FC = () => (
<Locale>
<Theme>
<Wrapper />
</Theme>
</Locale>
);
2024-05-07 16:24:43 +00:00
export default App;