From 61f195ea22be8093be0250a7519a248829efa6d1 Mon Sep 17 00:00:00 2001 From: arvinxx Date: Mon, 6 Feb 2023 21:15:05 +0800 Subject: [PATCH] =?UTF-8?q?:bug:=20fix:=20=E4=BF=AE=E6=AD=A3=E8=87=AA?= =?UTF-8?q?=E5=AE=9A=E4=B9=89=20stylish=20=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/demos/cases/clay/default.tsx | 1 - src/containers/ThemeProvider/TokenContainer.tsx | 9 ++------- tests/containers/ThemeProvider.test.tsx | 4 ++-- 3 files changed, 4 insertions(+), 10 deletions(-) diff --git a/docs/demos/cases/clay/default.tsx b/docs/demos/cases/clay/default.tsx index 412bf9bf..c3948a05 100644 --- a/docs/demos/cases/clay/default.tsx +++ b/docs/demos/cases/clay/default.tsx @@ -10,7 +10,6 @@ const useStyles = createStyles(({ stylish, cx, css, token }) => { padding: 24px; border-radius: 24px; width: 64px; - //background: white; color: ${token.colorPrimary}; background: ${token.colorPrimaryBgHover}; `, diff --git a/src/containers/ThemeProvider/TokenContainer.tsx b/src/containers/ThemeProvider/TokenContainer.tsx index 4b385248..08c19da0 100644 --- a/src/containers/ThemeProvider/TokenContainer.tsx +++ b/src/containers/ThemeProvider/TokenContainer.tsx @@ -2,8 +2,7 @@ import { ReactElement, useMemo } from 'react'; import { useAntdTheme, useThemeMode } from '@/hooks'; import { PedestalProvider, reactCss } from '@/pedestal'; -import { SerializedStyles, Theme } from '@/types'; -import { convertStylishToString } from '@/utils/convertStylish'; +import { Theme } from '@/types'; import type { ThemeProviderProps } from './type'; @@ -35,17 +34,13 @@ const TokenContainer: (props: TokenContainerProps) => ReactElement | const customStylish = useMemo(() => { if (!stylishOrGetStylish) return {}; - let rawStylish: Record; - - rawStylish = stylishOrGetStylish({ + return stylishOrGetStylish({ token: { ...token, ...customToken }, stylish: antdStylish, appearance, isDarkMode, css: reactCss, }); - - return convertStylishToString(rawStylish); }, [stylishOrGetStylish, token, customToken, antdStylish, appearance]); const stylish = useMemo( diff --git a/tests/containers/ThemeProvider.test.tsx b/tests/containers/ThemeProvider.test.tsx index 12e5fe99..d86788f2 100644 --- a/tests/containers/ThemeProvider.test.tsx +++ b/tests/containers/ThemeProvider.test.tsx @@ -149,11 +149,11 @@ describe('ThemeProvider', () => { it('注入自定义 stylish 方法', () => { const Wrapper: FC = ({ children }) => ( - ({ x: '' })}>{children} + ({ x: css`` })}>{children} ); const { result } = renderHook(useTheme, { wrapper: Wrapper }); - expect(result.current.stylish.x).toBeUndefined(); + expect(result.current.stylish.x.styles).toEqual(''); }); });