We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
1、StyleProvider 设置 speedy 为 true 时,不符合预期
import { StyleProvider, createGlobalStyle, createStyles } from 'antd-style'; const useStyles = createStyles({ content: { color: 'red', }, }); const GlobalStyles = createGlobalStyle({ '*': { fontSize: 40, }, }); const Demo: React.FC = () => { const { styles } = useStyles(); return ( <> <GlobalStyles /> <div className={styles.content}>content</div> </> ); }; const Wrapper: React.FC = () => ( <StyleProvider speedy> <Demo /> </StyleProvider> ); export default Wrapper;
2、StyleProvider 设置 prefix 为 demo,speedy 为 true 时,局部样式符合预期,全局样式前缀错误且不符合预期
import { StyleProvider, createGlobalStyle, createStyles } from 'antd-style'; const useStyles = createStyles({ content: { color: 'red', }, }); const GlobalStyles = createGlobalStyle({ '*': { fontSize: 40, }, }); const Demo: React.FC = () => { const { styles } = useStyles(); return ( <> <GlobalStyles /> <div className={styles.content}>content</div> </> ); }; const Wrapper: React.FC = () => ( <StyleProvider prefix="demo" speedy> <Demo /> </StyleProvider> ); export default Wrapper;
临时解决方案
// @/utils/styles.tsx import { CacheProvider, Global } from '@emotion/react'; import { serializeStyles } from '@emotion/serialize'; import type { CSSStyle } from 'antd-style'; import { createInstance } from 'antd-style'; import type { GlobalTheme } from 'antd-style/es/factories/createGlobalStyle'; import { memo } from 'react'; const instance = createInstance({ key: 'demo', speedy: true, }); export const { createStyles, useTheme, ThemeProvider } = instance; export const createGlobalStyle = ( ...styles: CSSStyle<GlobalTheme> ): React.FC<any> => memo((props) => { const theme = useTheme(); return ( <Global styles={serializeStyles(styles, undefined, { ...props, theme })} /> ); }); export const StyleProvider: React.FC<React.PropsWithChildren> = ({ children, }) => ( <CacheProvider value={instance.styleManager.cache}>{children}</CacheProvider> );
import { StyleProvider, createGlobalStyle, createStyles } from '@/utils/styles'; const useStyles = createStyles({ content: { color: 'red', }, }); const GlobalStyles = createGlobalStyle({ '*': { fontSize: 40, }, }); const Demo: React.FC = () => { const { styles } = useStyles(); return ( <> <GlobalStyles /> <div className={styles.content}>content</div> </> ); }; const Wrapper: React.FC = () => ( <StyleProvider> <Demo /> </StyleProvider> ); export default Wrapper;
The text was updated successfully, but these errors were encountered:
No branches or pull requests
💻 复现代码
1、StyleProvider 设置 speedy 为 true 时,不符合预期
2、StyleProvider 设置 prefix 为 demo,speedy 为 true 时,局部样式符合预期,全局样式前缀错误且不符合预期
🏞 期望结果
临时解决方案
The text was updated successfully, but these errors were encountered: