diff --git a/.dumi/theme/SiteThemeProvider.tsx b/.dumi/theme/SiteThemeProvider.tsx new file mode 100644 index 0000000000..0b08a59f54 --- /dev/null +++ b/.dumi/theme/SiteThemeProvider.tsx @@ -0,0 +1,35 @@ +import type { FC, PropsWithChildren } from 'react'; +import React, { useContext } from 'react'; +import { ConfigContext } from 'antd/es/config-provider'; +import { ThemeProvider } from 'antd-style'; +import { theme } from 'antd'; + +const SiteThemeProvider: FC = ({ children }) => { + const { getPrefixCls, iconPrefixCls } = useContext(ConfigContext); + const rootPrefixCls = getPrefixCls(); + const { token } = theme.useToken(); + + return ( + + {children} + + ); +}; + +export default SiteThemeProvider; diff --git a/.dumi/theme/common/Link.tsx b/.dumi/theme/common/Link.tsx index 75171cb81f..68b7bfe3f0 100644 --- a/.dumi/theme/common/Link.tsx +++ b/.dumi/theme/common/Link.tsx @@ -5,10 +5,11 @@ import { useNavigate } from 'dumi'; export type LinkProps = { to?: string; children?: React.ReactNode; + className?: string; }; const Link = forwardRef((props, ref) => { - const { to, children } = props; + const { to, children, ...rest } = props; const navigate = useNavigate(); const handleClick = (e: MouseEvent) => { @@ -21,7 +22,7 @@ const Link = forwardRef((props, ref) => { }; return ( - + {children} ); diff --git a/.dumi/theme/common/PrevAndNext.tsx b/.dumi/theme/common/PrevAndNext.tsx index 4752705ee6..01ed50f062 100644 --- a/.dumi/theme/common/PrevAndNext.tsx +++ b/.dumi/theme/common/PrevAndNext.tsx @@ -1,15 +1,13 @@ import type { ReactElement } from 'react'; import React, { useMemo } from 'react'; -import { ClassNames, css } from '@emotion/react'; import type { MenuProps } from 'antd'; import type { MenuItemType } from 'antd/es/menu/hooks/useItems'; import { LeftOutlined, RightOutlined } from '@ant-design/icons'; +import { createStyles, css } from 'antd-style'; +import classNames from 'classnames'; import useMenu from '../../hooks/useMenu'; -import useSiteToken from '../../hooks/useSiteToken'; - -const useStyle = () => { - const { token } = useSiteToken(); +const useStyle = createStyles(({ token }) => { const { colorSplit, iconCls, fontSizeIcon } = token; return { @@ -22,7 +20,7 @@ const useStyle = () => { border-top: 1px solid ${colorSplit}; display: flex; `, - pageNav: ` + pageNav: css` flex: 1; height: 72px; line-height: 72px; @@ -37,7 +35,7 @@ const useStyle = () => { margin-inline-start: 4px; } `, - prevNav: ` + prevNav: css` text-align: start; .footer-nav-icon-after { @@ -57,7 +55,7 @@ const useStyle = () => { right: 0.2em; } `, - nextNav: ` + nextNav: css` text-align: end; .footer-nav-icon-before { @@ -79,7 +77,7 @@ const useStyle = () => { } `, }; -}; +}); const flattenMenu = (menuItems: MenuProps['items']): MenuProps['items'] | null => { if (Array.isArray(menuItems)) { @@ -97,7 +95,7 @@ const flattenMenu = (menuItems: MenuProps['items']): MenuProps['items'] | null = }; const PrevAndNext: React.FC = () => { - const styles = useStyle(); + const { styles } = useStyle(); const [menuItems, selectedKey] = useMenu({ before: , @@ -122,21 +120,15 @@ const PrevAndNext: React.FC = () => { }, [menuItems, selectedKey]); return ( -
- - {({ css: classCss, cx }) => ( - <> - {prev && - React.cloneElement(prev.label as ReactElement, { - className: cx(classCss(styles.pageNav), classCss(styles.prevNav)), - })} - {next && - React.cloneElement(next.label as ReactElement, { - className: cx(classCss(styles.pageNav), classCss(styles.nextNav)), - })} - - )} - +
+ {prev && + React.cloneElement(prev.label as ReactElement, { + className: classNames(styles.pageNav, styles.prevNav), + })} + {next && + React.cloneElement(next.label as ReactElement, { + className: classNames(styles.pageNav, styles.nextNav), + })}
); }; diff --git a/.dumi/theme/layouts/GlobalLayout.tsx b/.dumi/theme/layouts/GlobalLayout.tsx index 23c96a4fb3..db77ca2a0e 100644 --- a/.dumi/theme/layouts/GlobalLayout.tsx +++ b/.dumi/theme/layouts/GlobalLayout.tsx @@ -9,6 +9,7 @@ import { App, ConfigProvider, theme as antdTheme } from 'antd'; import type { DirectionType } from 'antd/es/config-provider'; import { createSearchParams, useOutlet, useSearchParams } from 'dumi'; import React, { useCallback, useEffect, useMemo } from 'react'; +import SiteThemeProvider from '../SiteThemeProvider'; import useLocation from '../../hooks/useLocation'; import type { ThemeName } from '../common/ThemeSwitch'; import ThemeSwitch from '../common/ThemeSwitch'; @@ -117,15 +118,17 @@ const GlobalLayout: React.FC = () => { algorithm: getAlgorithm(theme), }} > - - {outlet} - {!pathname.startsWith('/~demos') && ( - updateSiteConfig({ theme: nextTheme })} - /> - )} - + + + {outlet} + {!pathname.startsWith('/~demos') && ( + updateSiteConfig({ theme: nextTheme })} + /> + )} + + diff --git a/components/dropdown/__tests__/__snapshots__/demo-extend.test.ts.snap b/components/dropdown/__tests__/__snapshots__/demo-extend.test.ts.snap index 7d18144fed..1cc5a9a235 100644 --- a/components/dropdown/__tests__/__snapshots__/demo-extend.test.ts.snap +++ b/components/dropdown/__tests__/__snapshots__/demo-extend.test.ts.snap @@ -6006,7 +6006,7 @@ Array [