2022-05-17 20:15:34 +08:00
|
|
|
import type { CSSObject } from '@ant-design/cssinjs';
|
|
|
|
import { Keyframes } from '@ant-design/cssinjs';
|
|
|
|
import type { NotificationToken } from '.';
|
2022-11-23 20:22:38 +08:00
|
|
|
import type { GenerateStyle } from '../../theme/internal';
|
2022-05-17 20:15:34 +08:00
|
|
|
|
2022-11-19 13:47:33 +08:00
|
|
|
const genNotificationPlacementStyle: GenerateStyle<NotificationToken, CSSObject> = (token) => {
|
2023-09-18 10:46:47 +08:00
|
|
|
const { componentCls, width, notificationMarginEdge, animationMaxHeight } = token;
|
2022-05-17 20:15:34 +08:00
|
|
|
|
2023-09-13 15:19:18 +08:00
|
|
|
const noticeCls = `${componentCls}-notice`;
|
|
|
|
|
|
|
|
const rightFadeIn = new Keyframes('antNotificationFadeIn', {
|
2022-05-17 20:15:34 +08:00
|
|
|
'0%': {
|
2023-09-13 15:19:18 +08:00
|
|
|
transform: `translate3d(100%, 0, 0)`,
|
2022-05-20 17:40:03 +08:00
|
|
|
opacity: 0,
|
2022-05-17 20:15:34 +08:00
|
|
|
},
|
|
|
|
|
|
|
|
'100%': {
|
2023-09-13 15:19:18 +08:00
|
|
|
transform: `translate3d(0, 0, 0)`,
|
2022-05-20 17:40:03 +08:00
|
|
|
opacity: 1,
|
2022-05-17 20:15:34 +08:00
|
|
|
},
|
|
|
|
});
|
|
|
|
|
2023-09-13 15:19:18 +08:00
|
|
|
const topFadeIn = new Keyframes('antNotificationTopFadeIn', {
|
2022-05-17 20:15:34 +08:00
|
|
|
'0%': {
|
2023-09-18 10:46:47 +08:00
|
|
|
bottom: -animationMaxHeight,
|
2022-05-20 17:40:03 +08:00
|
|
|
opacity: 0,
|
2022-05-17 20:15:34 +08:00
|
|
|
},
|
|
|
|
|
|
|
|
'100%': {
|
2023-09-18 10:46:47 +08:00
|
|
|
bottom: 0,
|
2022-05-20 17:40:03 +08:00
|
|
|
opacity: 1,
|
2022-05-17 20:15:34 +08:00
|
|
|
},
|
|
|
|
});
|
|
|
|
|
2023-09-13 15:19:18 +08:00
|
|
|
const bottomFadeIn = new Keyframes('antNotificationBottomFadeIn', {
|
2022-05-17 20:15:34 +08:00
|
|
|
'0%': {
|
2023-09-13 15:19:18 +08:00
|
|
|
bottom: -token.animationMaxHeight,
|
2022-05-20 17:40:03 +08:00
|
|
|
opacity: 0,
|
2022-05-17 20:15:34 +08:00
|
|
|
},
|
|
|
|
|
|
|
|
'100%': {
|
2023-09-13 15:19:18 +08:00
|
|
|
bottom: 0,
|
2022-05-20 17:40:03 +08:00
|
|
|
opacity: 1,
|
2022-05-17 20:15:34 +08:00
|
|
|
},
|
|
|
|
});
|
|
|
|
|
2023-09-13 15:19:18 +08:00
|
|
|
const leftFadeIn = new Keyframes('antNotificationLeftFadeIn', {
|
|
|
|
'0%': {
|
|
|
|
transform: `translate3d(-100%, 0, 0)`,
|
|
|
|
opacity: 0,
|
2022-05-17 20:15:34 +08:00
|
|
|
},
|
|
|
|
|
2023-09-13 15:19:18 +08:00
|
|
|
'100%': {
|
|
|
|
transform: `translate3d(0, 0, 0)`,
|
|
|
|
opacity: 1,
|
2022-05-17 20:15:34 +08:00
|
|
|
},
|
2023-09-13 15:19:18 +08:00
|
|
|
});
|
2022-05-17 20:15:34 +08:00
|
|
|
|
2023-09-13 15:19:18 +08:00
|
|
|
return {
|
|
|
|
[componentCls]: {
|
|
|
|
[`&${componentCls}-top, &${componentCls}-bottom`]: {
|
|
|
|
marginInline: 0,
|
|
|
|
[noticeCls]: {
|
|
|
|
marginInline: 'auto auto',
|
2022-05-17 20:15:34 +08:00
|
|
|
},
|
2023-09-13 15:19:18 +08:00
|
|
|
},
|
|
|
|
|
|
|
|
[`&${componentCls}-top`]: {
|
|
|
|
[`${componentCls}-fade-enter${componentCls}-fade-enter-active, ${componentCls}-fade-appear${componentCls}-fade-appear-active`]:
|
|
|
|
{
|
|
|
|
animationName: topFadeIn,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
[`&${componentCls}-bottom`]: {
|
|
|
|
[`${componentCls}-fade-enter${componentCls}-fade-enter-active, ${componentCls}-fade-appear${componentCls}-fade-appear-active`]:
|
|
|
|
{
|
|
|
|
animationName: bottomFadeIn,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
[`&${componentCls}-topRight, &${componentCls}-bottomRight`]: {
|
|
|
|
[`${componentCls}-fade-enter${componentCls}-fade-enter-active, ${componentCls}-fade-appear${componentCls}-fade-appear-active`]:
|
|
|
|
{
|
|
|
|
animationName: rightFadeIn,
|
|
|
|
},
|
|
|
|
},
|
2022-05-17 20:15:34 +08:00
|
|
|
|
2023-09-13 15:19:18 +08:00
|
|
|
[`&${componentCls}-topLeft, &${componentCls}-bottomLeft`]: {
|
|
|
|
marginInlineEnd: 0,
|
|
|
|
marginInlineStart: notificationMarginEdge,
|
2022-05-17 20:15:34 +08:00
|
|
|
|
2023-09-13 15:19:18 +08:00
|
|
|
[noticeCls]: {
|
|
|
|
marginInlineEnd: 'auto',
|
|
|
|
marginInlineStart: 0,
|
2022-05-17 20:15:34 +08:00
|
|
|
},
|
2023-09-13 15:19:18 +08:00
|
|
|
|
|
|
|
[`${componentCls}-fade-enter${componentCls}-fade-enter-active, ${componentCls}-fade-appear${componentCls}-fade-appear-active`]:
|
|
|
|
{
|
|
|
|
animationName: leftFadeIn,
|
|
|
|
},
|
|
|
|
},
|
2022-05-17 20:15:34 +08:00
|
|
|
},
|
|
|
|
};
|
|
|
|
};
|
|
|
|
export default genNotificationPlacementStyle;
|