2022-03-22 13:27:12 +08:00
|
|
|
// deps-lint-skip-all
|
|
|
|
import { CSSObject } from '@ant-design/cssinjs';
|
|
|
|
import {
|
|
|
|
DerivativeToken,
|
|
|
|
useStyleRegister,
|
|
|
|
useToken,
|
|
|
|
UseComponentStyleResult,
|
|
|
|
GenerateStyle,
|
|
|
|
} from '../../_util/theme';
|
|
|
|
|
|
|
|
interface AffixToken extends DerivativeToken {
|
|
|
|
affixCls: string;
|
2022-03-24 14:30:48 +08:00
|
|
|
zIndexAffix: number;
|
2022-03-22 13:27:12 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
// ============================== Shared ==============================
|
|
|
|
const genSharedAffixStyle: GenerateStyle<AffixToken> = (token): CSSObject => {
|
|
|
|
const { affixCls } = token;
|
|
|
|
|
|
|
|
return {
|
|
|
|
[affixCls]: {
|
|
|
|
position: 'fixed',
|
|
|
|
zIndex: token.zIndexAffix,
|
|
|
|
},
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
// ============================== Export ==============================
|
|
|
|
export default function useStyle(prefixCls: string): UseComponentStyleResult {
|
|
|
|
const [theme, token, hashId] = useToken();
|
|
|
|
|
|
|
|
const affixToken: AffixToken = {
|
|
|
|
...token,
|
|
|
|
|
|
|
|
affixCls: `.${prefixCls}`,
|
2022-03-24 14:30:48 +08:00
|
|
|
zIndexAffix: token.zIndexBase + 10,
|
2022-03-22 13:27:12 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
return [
|
|
|
|
useStyleRegister({ theme, token, hashId, path: [prefixCls] }, () => [
|
|
|
|
genSharedAffixStyle(affixToken),
|
|
|
|
]),
|
|
|
|
hashId,
|
|
|
|
];
|
|
|
|
}
|