2022-11-18 09:55:42 +08:00
|
|
|
import { useStyleRegister } from '@ant-design/cssinjs';
|
2023-03-27 23:00:56 +08:00
|
|
|
import type { CSPConfig } from '..';
|
2022-11-18 09:55:42 +08:00
|
|
|
import { resetIcon } from '../../style';
|
2022-11-23 20:22:38 +08:00
|
|
|
import { useToken } from '../../theme/internal';
|
2022-11-18 09:55:42 +08:00
|
|
|
|
2023-03-27 23:00:56 +08:00
|
|
|
const useStyle = (iconPrefixCls: string, csp?: CSPConfig) => {
|
2022-11-18 09:55:42 +08:00
|
|
|
const [theme, token] = useToken();
|
2023-03-27 23:00:56 +08:00
|
|
|
|
2022-11-18 09:55:42 +08:00
|
|
|
// Generate style for icons
|
|
|
|
return useStyleRegister(
|
2023-03-27 23:00:56 +08:00
|
|
|
{
|
|
|
|
theme,
|
|
|
|
token,
|
|
|
|
hashId: '',
|
|
|
|
path: ['ant-design-icons', iconPrefixCls],
|
|
|
|
nonce: () => csp?.nonce!,
|
|
|
|
},
|
2022-11-18 09:55:42 +08:00
|
|
|
() => [
|
|
|
|
{
|
2023-01-20 10:31:27 +08:00
|
|
|
[`.${iconPrefixCls}`]: {
|
|
|
|
...resetIcon(),
|
|
|
|
[`.${iconPrefixCls} .${iconPrefixCls}-icon`]: {
|
|
|
|
display: 'block',
|
|
|
|
},
|
|
|
|
},
|
2022-11-18 09:55:42 +08:00
|
|
|
},
|
|
|
|
],
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
|
|
|
export default useStyle;
|