Skip to content
New issue

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

👑 [需求] createStyles传入的函数里面的参数能不能增加antdPrefixCls #135

Open
DBvc opened this issue Jan 9, 2024 · 1 comment

Comments

@DBvc
Copy link
Contributor

DBvc commented Jan 9, 2024

🥰 需求描述

目前在基于antd做二次封装,有些二次封装的组件需要覆盖内部的antd的组件的样式,比如这样

// 组件内的定义
const { createStyles } = createInstance({
  key: 'my-custom-component',
  prefixCls: 'my-custom-component',
})

const useStyles = createStyles(({ css, prefixCls }) => ({
  dropdownStyle: css`
   .${prefixCls}-select-item-option {
     padding: 5px 16px;
   }
  `
})
<ThemeProvider prefix='project-a'>
   <App />
</ThemeProvider>

组件内是希望通过类名来覆盖内部的antd的组件的样式,在3.6.0之前,createStyles里面拿到的通过ThemeProvider传入的prefixCls project-a, 3.6.0之后拿到的prefixCls就是 my-custom-component 了,这样就覆盖不了内部的antd组件的样式了

所以实际上两个prefixCls我都需要, createInstance传入的prefixCls来控制自己实现的部分,antdPrefixCls来覆盖antd的组件

希望能把两个都返回,或者有没有其他方法能满足我的需求

🧐 解决方案

同时返回两种prefixCls

🚑 其他信息

@arvinxx
Copy link
Collaborator

arvinxx commented Jan 26, 2024

可以,我后续实现下

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants