generated from arvinxx/npm-template
-
Notifications
You must be signed in to change notification settings - Fork 38
Open
Description
🐛 bug 描述
我在主工程上设置StyleProvider挂载节点为shadowRoot时,通过antd-style开发的二次封装组件样式无法正确的挂载在shadowRoot节点上
📷 复现步骤
- 主工程设置StyleProvider的container为shadowRoot
- 在独立的组件库工程上通过antd-style开发自定义组件
- 组件样式表挂载到了head标签上
🏞 期望结果
组件样式表挂载到shadowRoot节点上
💻 复现代码
// index.tsx
const shadowRoot = document.getElementById('copilot-root')?.shadowRoot;
const popupContainer = shadowRoot?.getElementById('copilot-panel');
return shadowRoot ? (
<StyleProvider container={shadowRoot}>
<XProvider
locale={zhCN}
// @ts-ignore
getPopupContainer={() => popupContainer}
theme={props.themeConfig}
>
<Foo {...props} />
</XProvider>
</StyleProvider>
) : null;// Foo.tsx
import { createStyles } from 'antd-style';
import React, { type FC } from 'react';
const Foo: FC<{ title: string }> = (props) => {
const useStyle = createStyles(({ token, css }) => ({
asd: css`
color: ${token.colorPrimary};
`,
}));
const { styles } = useStyle();
return <h4 className={styles.asd}>{props.title}</h4>;
};
export default Foo;
© 版本信息
- antd-style 版本: 3.7.1
- 浏览器环境 Chrome
- 开发环境 windows 10
🚑 其他信息
kennedy-yu and whinc
Metadata
Metadata
Assignees
Labels
No labels
