ant-design/components/tabs/style/motion.ts

47 lines
1.1 KiB
TypeScript
Raw Normal View History

2022-08-08 19:08:43 +08:00
import type { TabsToken } from '.';
import { initSlideMotion } from '../../style/motion';
import type { GenerateStyle } from '../../theme/internal';
2022-08-08 19:08:43 +08:00
const genMotionStyle: GenerateStyle<TabsToken> = (token) => {
2022-08-08 19:08:43 +08:00
const { componentCls, motionDurationSlow } = token;
return [
{
[componentCls]: {
[`${componentCls}-switch`]: {
'&-appear, &-enter': {
transition: 'none',
2022-08-08 19:08:43 +08:00
'&-start': {
opacity: 0,
},
'&-active': {
opacity: 1,
transition: `opacity ${motionDurationSlow}`,
},
2022-08-08 19:08:43 +08:00
},
'&-leave': {
position: 'absolute',
transition: 'none',
inset: 0,
2022-08-08 19:08:43 +08:00
'&-start': {
opacity: 1,
},
'&-active': {
opacity: 0,
transition: `opacity ${motionDurationSlow}`,
},
2022-08-08 19:08:43 +08:00
},
},
},
},
// Follow code may reuse in other components
[initSlideMotion(token, 'slide-up'), initSlideMotion(token, 'slide-down')],
];
2022-08-08 19:08:43 +08:00
};
export default genMotionStyle;