ant-design/components/affix/style/index.tsx
Long Hao (龙濠) 18c4fe5fd9
refactor: next-affix change affix use cssinjs (#34558)
* refactor: next-affix

* fix: wrong spell

* fix: add fixme

* fix: prefixnam

* fix: change hash to classname

* fix: omit hashclassName

* fix: change name to rootclassName

* fix: rootClassName add

Co-authored-by: zengguhao.zgh <zengguhao.zgh@alibaba-inc.com>
2022-03-22 13:27:12 +08:00

44 lines
994 B
TypeScript

// 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;
}
// ============================== 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}`,
};
return [
useStyleRegister({ theme, token, hashId, path: [prefixCls] }, () => [
genSharedAffixStyle(affixToken),
]),
hashId,
];
}