File size: 2,924 Bytes
1e92f2d |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 |
import type { CSSObject } from '@ant-design/cssinjs';
import { Keyframes } from '@ant-design/cssinjs';
import type { NotificationToken } from '.';
import type { GenerateStyle } from '../../theme/internal';
const genNotificationPlacementStyle: GenerateStyle<NotificationToken, CSSObject> = (token) => {
const { componentCls, notificationMarginEdge, animationMaxHeight } = token;
const noticeCls = `${componentCls}-notice`;
const rightFadeIn = new Keyframes('antNotificationFadeIn', {
'0%': {
transform: `translate3d(100%, 0, 0)`,
opacity: 0,
},
'100%': {
transform: `translate3d(0, 0, 0)`,
opacity: 1,
},
});
const topFadeIn = new Keyframes('antNotificationTopFadeIn', {
'0%': {
top: -animationMaxHeight,
opacity: 0,
},
'100%': {
top: 0,
opacity: 1,
},
});
const bottomFadeIn = new Keyframes('antNotificationBottomFadeIn', {
'0%': {
bottom: token.calc(animationMaxHeight).mul(-1).equal(),
opacity: 0,
},
'100%': {
bottom: 0,
opacity: 1,
},
});
const leftFadeIn = new Keyframes('antNotificationLeftFadeIn', {
'0%': {
transform: `translate3d(-100%, 0, 0)`,
opacity: 0,
},
'100%': {
transform: `translate3d(0, 0, 0)`,
opacity: 1,
},
});
return {
[componentCls]: {
[`&${componentCls}-top, &${componentCls}-bottom`]: {
marginInline: 0,
[noticeCls]: {
marginInline: 'auto auto',
},
},
[`&${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,
},
},
[`&${componentCls}-topLeft, &${componentCls}-bottomLeft`]: {
marginRight: {
value: 0,
_skip_check_: true,
},
marginLeft: {
value: notificationMarginEdge,
_skip_check_: true,
},
[noticeCls]: {
marginInlineEnd: 'auto',
marginInlineStart: 0,
},
[`${componentCls}-fade-enter${componentCls}-fade-enter-active, ${componentCls}-fade-appear${componentCls}-fade-appear-active`]:
{
animationName: leftFadeIn,
},
},
},
};
};
export default genNotificationPlacementStyle;
|