antd-style
antd-style copied to clipboard
👑 [需求] createStyles传入的函数里面的参数能不能增加antdPrefixCls
🥰 需求描述
目前在基于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