mirror of
https://github.com/ant-design/ant-design.git
synced 2024-12-03 00:09:39 +08:00
18c4fe5fd9
* 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>
44 lines
994 B
TypeScript
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,
|
|
];
|
|
}
|