2022-03-22 13:27:12 +08:00
|
|
|
// deps-lint-skip-all
|
2022-05-09 22:20:07 +08:00
|
|
|
import type { CSSObject } from '@ant-design/cssinjs';
|
|
|
|
import type { GenerateStyle, FullToken } from '../../_util/theme';
|
|
|
|
import { genComponentStyleHook, mergeToken } from '../../_util/theme';
|
2022-03-22 13:27:12 +08:00
|
|
|
|
2022-04-07 14:53:13 +08:00
|
|
|
interface AffixToken extends FullToken<'Affix'> {
|
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 => {
|
2022-04-07 14:53:13 +08:00
|
|
|
const { componentCls } = token;
|
2022-03-22 13:27:12 +08:00
|
|
|
|
|
|
|
return {
|
2022-04-07 14:53:13 +08:00
|
|
|
[componentCls]: {
|
2022-03-22 13:27:12 +08:00
|
|
|
position: 'fixed',
|
|
|
|
zIndex: token.zIndexAffix,
|
|
|
|
},
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
// ============================== Export ==============================
|
2022-04-07 14:53:13 +08:00
|
|
|
export default genComponentStyleHook('Affix', token => {
|
2022-04-11 16:04:00 +08:00
|
|
|
const affixToken = mergeToken<AffixToken>(token, {
|
2022-03-24 14:30:48 +08:00
|
|
|
zIndexAffix: token.zIndexBase + 10,
|
2022-04-11 16:04:00 +08:00
|
|
|
});
|
2022-04-07 14:53:13 +08:00
|
|
|
return [genSharedAffixStyle(affixToken)];
|
|
|
|
});
|